diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-10-26 21:06:51 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-10-26 21:07:51 -0700 |
commit | 9cf27c92c136cce4785744542eaf962c05f1052c (patch) | |
tree | 4707badbb043be45abaa39c8636ffb1d28239bd7 /src/Text | |
parent | 905d194db5f083ba49dfd5360d23aeba5b9b41ae (diff) | |
download | pandoc-9cf27c92c136cce4785744542eaf962c05f1052c.tar.gz |
Added support for MathJax for displaying math in HTML.
Added --mathjax option.
Added MathJax to HTMLMathMethod.
Supported MathJax in HTML writer.
Resolves Issue #259.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 17 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 633708046..0fdaf42f3 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -459,6 +459,7 @@ data HTMLMathMethod = PlainMath | GladTeX | WebTeX String -- url of TeX->image script. | MathML (Maybe String) -- url of MathMLinHTML.js + | MathJax String -- url of MathJax.js deriving (Show, Read, Eq) -- | Methods for obfuscating email addresses in HTML. diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index eaaf18426..7374cb343 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -134,6 +134,8 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do MathML (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml + MathJax url -> + script ! [src url, thetype "text/javascript"] $ noHtml JsMath (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml @@ -464,8 +466,7 @@ inlineToHtml opts inline = stringToHtml "”") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote - (Math t str) -> - modify (\st -> st {stMath = True}) >> + (Math t str) -> modify (\st -> st {stMath = True}) >> (case writerHTMLMathMethod opts of LaTeXMathML _ -> -- putting LaTeXMathML in container with class "LaTeX" prevents @@ -502,6 +503,18 @@ inlineToHtml opts inline = Left _ -> inlineListToHtml opts (readTeXMath str) >>= return . (thespan ! [theclass "math"]) + MathJax _ -> do + let dt = if t == InlineMath + then DisplayInline + else DisplayBlock + let conf = useShortEmptyTags (const False) + defaultConfigPP + case texMathToMathML dt str of + Right r -> return $ primHtml $ + ppcElement conf r + Left _ -> inlineListToHtml opts + (readTeXMath str) >>= return . + (thespan ! [theclass "math"]) PlainMath -> do x <- inlineListToHtml opts (readTeXMath str) let m = thespan ! [theclass "math"] $ x |