From de0df52998571054fd7c9a157481fe9fabeede88 Mon Sep 17 00:00:00 2001 From: Lucas Escot <flupe@users.noreply.github.com> Date: Thu, 28 May 2020 20:31:23 +0200 Subject: [PATCH] Fixed Katex standalone script (#6399) Global macros are now persistent when using the HTML Writer with the --katex option. --- src/Text/Pandoc/Writers/HTML.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index dbda5067f..9f51c28de 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -281,12 +281,14 @@ pandocToHtml opts (Pandoc meta blocks) = do H.script $ text $ T.unlines [ "document.addEventListener(\"DOMContentLoaded\", function () {" , " var mathElements = document.getElementsByClassName(\"math\");" + , " var macros = [];" , " for (var i = 0; i < mathElements.length; i++) {" , " var texText = mathElements[i].firstChild;" , " if (mathElements[i].tagName == \"SPAN\") {" , " katex.render(texText.data, mathElements[i], {" , " displayMode: mathElements[i].classList.contains('display')," , " throwOnError: false," + , " macros: macros," , " fleqn: " <> katexFlushLeft , " });" , "}}});"