git.iko.soy/typeable/pandoc
on master help sign in
KaTeX math: respect classoption=fleqn variable
bfbff31mb21
MANUAL.txt+6
@@ -1988,6 +1988,12 @@ ODT or pptx.
1988[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics
1988[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics
1989[Language subtag lookup]: https://r12a.github.io/app-subtags/
1989[Language subtag lookup]: https://r12a.github.io/app-subtags/
1990
1990
1991+### Variables for HTML math
1992+
1993+`classoption`
1994+: when using [KaTeX](#option--katex), you can render display math equations
1995+ flush left using [YAML metadata](#layout) or with `-M classoption=fleqn`.
1996+
1991### Variables for HTML slides
1997### Variables for HTML slides
1992
1998
1993These affect HTML output when [producing slide shows with pandoc].
1999These affect HTML output when [producing slide shows with pandoc].
src/Text/Pandoc/Writers/HTML.hs+6−2
@@ -281,8 +281,12 @@ pandocToHtml opts (Pandoc meta blocks) = do
281 H.script !
281 H.script !
282 A.src (toValue $ url ++ "katex.min.js") $ mempty
282 A.src (toValue $ url ++ "katex.min.js") $ mempty
283 nl opts
283 nl opts
284+ let katexFlushLeft =
285+ case lookupContext "classoption" metadata of
286+ Just clsops | "fleqn" `elem` (clsops :: [Text]) -> "true"
287+ _ -> "false"
284− H.script
288+ H.script $
285− "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 }}});"
289+ "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 }}});"
286 nl opts
290 nl opts
287 H.link ! A.rel "stylesheet" !
291 H.link ! A.rel "stylesheet" !
288 A.href (toValue $ url ++ "katex.min.css")
292 A.href (toValue $ url ++ "katex.min.css")