diff options
author | Lila <lila91142@gmail.com> | 2020-05-19 07:45:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 22:45:44 -0700 |
commit | f4185fcef0aa5c00e37a1bf8bbc8b8c6459fffe7 (patch) | |
tree | 4a09047038b339afef449f0b2b0591271afe0087 /src | |
parent | 57fa394eb0afbc8368091b9c90e132e29e2b72aa (diff) | |
download | pandoc-f4185fcef0aa5c00e37a1bf8bbc8b8c6459fffe7.tar.gz |
Use CSS in favor of <br> for display math (#6372)
Some CSS to ensure that display math is
displayed centered and on a new line is now included
in the default HTML-based templates; this may be
overridden if the user wants a different behavior.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 1f0ee5410..dbda5067f 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -318,6 +318,10 @@ pandocToHtml opts (Pandoc meta blocks) = do defField "mathjaxurl" (T.takeWhile (/='?') u) _ -> defField "mathjax" False) $ + (case writerHTMLMathMethod opts of + PlainMath -> defField "displaymath-css" True + WebTeX _ -> defField "displaymath-css" True + _ -> id) $ defField "quotes" (stQuotes st) $ -- for backwards compatibility we populate toc -- with the contents of the toc, rather than a @@ -1108,14 +1112,11 @@ inlineToHtml opts inline = do let s = case t of InlineMath -> "\\textstyle " DisplayMath -> "\\displaystyle " - let m = imtag ! A.style "vertical-align:middle" - ! A.src (toValue $ url <> T.pack (urlEncode (T.unpack $ s <> str))) - ! A.alt (toValue str) - ! A.title (toValue str) - let brtag = if html5 then H5.br else H.br - return $ case t of - InlineMath -> m - DisplayMath -> brtag >> m >> brtag + return $ imtag ! A.style "vertical-align:middle" + ! A.src (toValue $ url <> T.pack (urlEncode (T.unpack $ s <> str))) + ! A.alt (toValue str) + ! A.title (toValue str) + ! A.class_ mathClass GladTeX -> return $ customParent (textTag "eq") ! @@ -1142,11 +1143,7 @@ inlineToHtml opts inline = do DisplayMath -> str PlainMath -> do x <- lift (texMathToInlines t str) >>= inlineListToHtml opts - let m = H.span ! A.class_ mathClass $ x - let brtag = if html5 then H5.br else H.br - return $ case t of - InlineMath -> m - DisplayMath -> brtag >> m >> brtag + return $ H.span ! A.class_ mathClass $ x (RawInline f str) -> do ishtml <- isRawHtml f if ishtml |