From b7356d3ddf788d83b41b1100d718087bd83a7506 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 9 May 2018 11:29:20 -0700 Subject: Restored and undeprecated gladtex for HTML math. - Added `GladTeX` constructor to `Text.Pandoc.Options.HTMLMathMethod` [API change, reverts removal in v2.2] - Restored and undeprecated `--gladtex` option, removed in v2.2. Closes #4607. --- src/Text/Pandoc/App.hs | 6 ++++++ src/Text/Pandoc/Options.hs | 1 + src/Text/Pandoc/Writers/HTML.hs | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 920462d48..a59fd9bbe 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -1403,6 +1403,12 @@ options = "URL") "" -- Use KaTeX for HTML Math + , Option "" ["gladtex"] + (NoArg + (\opt -> + return opt { optHTMLMathMethod = GladTeX })) + "" -- "Use gladtex for HTML math" + , Option "" ["abbreviations"] (ReqArg (\arg opt -> return opt { optAbbreviations = Just arg }) diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 4797a3094..e5ca1764c 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -107,6 +107,7 @@ data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Gener data HTMLMathMethod = PlainMath | WebTeX String -- url of TeX->image script. + | GladTeX | MathML | MathJax String -- url of MathJax.js | KaTeX String -- url of KaTeX files diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 535071ae2..a09ad2fda 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -58,7 +58,7 @@ import qualified Data.Text.Lazy as TL import Network.HTTP (urlEncode) import Network.URI (URI (..), parseURIReference, unEscapeString) import Numeric (showHex) -import Text.Blaze.Internal (customLeaf, MarkupM(Empty)) +import Text.Blaze.Internal (customLeaf, customParent, MarkupM(Empty)) #if MIN_VERSION_blaze_markup(0,6,3) #else import Text.Blaze.Internal (preEscapedString, preEscapedText) @@ -1029,6 +1029,13 @@ inlineToHtml opts inline = do return $ case t of InlineMath -> m DisplayMath -> brtag >> m >> brtag + GladTeX -> + return $ + customParent (textTag "eq") ! + customAttribute "env" + (toValue $ if t == InlineMath + then ("math" :: Text) + else "displaymath") $ strToHtml str MathML -> do let conf = useShortEmptyTags (const False) defaultConfigPP -- cgit v1.2.3