change indentation of math part in Writers/HTML.hs
This commit is contained in:
parent
bfbff3106d
commit
25cb84d8d9
1 changed files with 43 additions and 32 deletions
|
@ -267,39 +267,50 @@ pandocToHtml opts (Pandoc meta blocks) = do
|
||||||
notes <- footnoteSection opts (reverse (stNotes st))
|
notes <- footnoteSection opts (reverse (stNotes st))
|
||||||
let thebody = blocks' >> notes
|
let thebody = blocks' >> notes
|
||||||
let math = case writerHTMLMathMethod opts of
|
let math = case writerHTMLMathMethod opts of
|
||||||
MathJax url
|
MathJax url
|
||||||
| slideVariant /= RevealJsSlides ->
|
| slideVariant /= RevealJsSlides ->
|
||||||
-- mathjax is handled via a special plugin in revealjs
|
-- mathjax is handled via a special plugin in revealjs
|
||||||
H.script ! A.src (toValue url)
|
H.script ! A.src (toValue url)
|
||||||
! A.type_ "text/javascript"
|
! A.type_ "text/javascript"
|
||||||
$ case slideVariant of
|
$ case slideVariant of
|
||||||
SlideousSlides ->
|
SlideousSlides ->
|
||||||
preEscapedString
|
preEscapedString
|
||||||
"MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"
|
"MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"
|
||||||
_ -> mempty
|
_ -> mempty
|
||||||
KaTeX url -> do
|
KaTeX url -> do
|
||||||
H.script !
|
H.script !
|
||||||
A.src (toValue $ url ++ "katex.min.js") $ mempty
|
A.src (toValue $ url ++ "katex.min.js") $ mempty
|
||||||
nl opts
|
nl opts
|
||||||
let katexFlushLeft =
|
let katexFlushLeft =
|
||||||
case lookupContext "classoption" metadata of
|
case lookupContext "classoption" metadata of
|
||||||
Just clsops | "fleqn" `elem` (clsops :: [Text]) -> "true"
|
Just clsops | "fleqn" `elem` (clsops :: [Text]) -> "true"
|
||||||
_ -> "false"
|
_ -> "false"
|
||||||
H.script $
|
H.script $ text $ T.unlines [
|
||||||
"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 }}});"
|
"document.addEventListener(\"DOMContentLoaded\", function () {"
|
||||||
nl opts
|
, " var mathElements = document.getElementsByClassName(\"math\");"
|
||||||
H.link ! A.rel "stylesheet" !
|
, " for (var i = 0; i < mathElements.length; i++) {"
|
||||||
A.href (toValue $ url ++ "katex.min.css")
|
, " var texText = mathElements[i].firstChild;"
|
||||||
|
, " if (mathElements[i].tagName == \"SPAN\") {"
|
||||||
|
, " katex.render(texText.data, mathElements[i], {"
|
||||||
|
, " displayMode: mathElements[i].classList.contains('display'),"
|
||||||
|
, " throwOnError: false,"
|
||||||
|
, " fleqn: " <> katexFlushLeft
|
||||||
|
, " });"
|
||||||
|
, "}}});"
|
||||||
|
]
|
||||||
|
nl opts
|
||||||
|
H.link ! A.rel "stylesheet" !
|
||||||
|
A.href (toValue $ url ++ "katex.min.css")
|
||||||
|
|
||||||
_ -> case lookupContext "mathml-script"
|
_ -> case lookupContext "mathml-script"
|
||||||
(writerVariables opts) of
|
(writerVariables opts) of
|
||||||
Just s | not (stHtml5 st) ->
|
Just s | not (stHtml5 st) ->
|
||||||
H.script ! A.type_ "text/javascript"
|
H.script ! A.type_ "text/javascript"
|
||||||
$ preEscapedString
|
$ preEscapedString
|
||||||
("/*<![CDATA[*/\n" ++ T.unpack s ++
|
("/*<![CDATA[*/\n" ++ T.unpack s ++
|
||||||
"/*]]>*/\n")
|
"/*]]>*/\n")
|
||||||
| otherwise -> mempty
|
| otherwise -> mempty
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
let context = (if stHighlighting st
|
let context = (if stHighlighting st
|
||||||
then case writerHighlightStyle opts of
|
then case writerHighlightStyle opts of
|
||||||
Just sty -> defField "highlighting-css"
|
Just sty -> defField "highlighting-css"
|
||||||
|
|
Loading…
Add table
Reference in a new issue