aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authormb21 <mb21@users.noreply.github.com>2019-10-13 20:05:57 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2019-10-14 08:47:40 -0700
commitbfbff3106d14765950c68f772d04637b8a0b177b (patch)
tree6a84c50f8246f5bd93b2d52858dd9ca836d5f8ad /src/Text
parentb976486f1fa3ee4ae123800fa5a4d3cd1c3ba877 (diff)
downloadpandoc-bfbff3106d14765950c68f772d04637b8a0b177b.tar.gz
KaTeX math: respect classoption=fleqn variable
closes #5815
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index d7a7e19ea..84d5ca4dd 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -281,8 +281,12 @@ pandocToHtml opts (Pandoc meta blocks) = do
H.script !
A.src (toValue $ url ++ "katex.min.js") $ mempty
nl opts
- H.script
- "document.addEventListener(\"DOMContentLoaded\", function () {\n var mathElements = document.getElementsByClassName(\"math\");\n for (var i = 0; i < mathElements.length; i++) {\n var texText = mathElements[i].firstChild;\n if (mathElements[i].tagName == \"SPAN\") { katex.render(texText.data, mathElements[i], { displayMode: mathElements[i].classList.contains(\"display\"), throwOnError: false } );\n }}});"
+ let katexFlushLeft =
+ case lookupContext "classoption" metadata of
+ Just clsops | "fleqn" `elem` (clsops :: [Text]) -> "true"
+ _ -> "false"
+ H.script $
+ "document.addEventListener(\"DOMContentLoaded\", function () {\n var mathElements = document.getElementsByClassName(\"math\");\n for (var i = 0; i < mathElements.length; i++) {\n var texText = mathElements[i].firstChild;\n if (mathElements[i].tagName == \"SPAN\") { katex.render(texText.data, mathElements[i], { displayMode: mathElements[i].classList.contains(\"display\"), throwOnError: false, fleqn: " <> katexFlushLeft <> " } );\n }}});"
nl opts
H.link ! A.rel "stylesheet" !
A.href (toValue $ url ++ "katex.min.css")