aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorLucas Escot <flupe@users.noreply.github.com>2020-05-28 20:31:23 +0200
committerGitHub <noreply@github.com>2020-05-28 11:31:23 -0700
commitde0df52998571054fd7c9a157481fe9fabeede88 (patch)
treeca60f5eeaa50dc50892996c23702d6ba4b0b4dc8 /src/Text
parent287a3fcc51ac030d83a07508b49d284bfa160153 (diff)
downloadpandoc-de0df52998571054fd7c9a157481fe9fabeede88.tar.gz
Fixed Katex standalone script (#6399)
Global macros are now persistent when using the HTML Writer with the --katex option.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs2
1 files changed, 2 insertions, 0 deletions
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
, " });"
, "}}});"