Fixed Katex standalone script (#6399)

Global macros are now persistent when using the HTML Writer with the --katex
option.
This commit is contained in:
Lucas Escot 2020-05-28 20:31:23 +02:00 committed by GitHub
parent 287a3fcc51
commit de0df52998
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
, " });"
, "}}});"