git.iko.soy/typeable/pandoc
on master help sign in
Fixed Katex standalone script (#6399)

Global macros are now persistent when using the HTML Writer with the --katex option.

commitde0df52998571054fd7c9a157481fe9fabeede88 authorLucas Escot <flupe@users.noreply.github.com> dateThu 28 May 2020, 20:31 (6 years ago) parent287a3fc
1 file changed+2
src/Text/Pandoc/Writers/HTML.hs+2
src/Text/Pandoc/Writers/HTML.hs+2
@@ -281,12 +281,14 @@ pandocToHtml opts (Pandoc meta blocks) = do
281281 H.script $ text $ T.unlines [
282282 "document.addEventListener(\"DOMContentLoaded\", function () {"
283283 , " var mathElements = document.getElementsByClassName(\"math\");"
284+ , " var macros = [];"
284285 , " for (var i = 0; i < mathElements.length; i++) {"
285286 , " var texText = mathElements[i].firstChild;"
286287 , " if (mathElements[i].tagName == \"SPAN\") {"
287288 , " katex.render(texText.data, mathElements[i], {"
288289 , " displayMode: mathElements[i].classList.contains('display'),"
289290 , " throwOnError: false,"
291+ , " macros: macros,"
290292 , " fleqn: " <> katexFlushLeft
291293 , " });"
292294 , "}}});"