From f53fb554fe0acf88d7c697236bbd1373e78f3d83 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 13 Aug 2008 03:02:42 +0000 Subject: Support for display math; changed ASCIIMathML -> LaTeXMathML: Resolves Issue #47. + Added a DisplayMath/InlineMath selector to Math inlines. + Markdown parser yields DisplayMath for $$...$$. + LaTeX parser yields DisplayMath when appropriate. Removed mathBlock parsers, since the same effect is achieved by the math inline parsers, now that they handle display math. + Writers handle DisplayMath as appropriate for the format. + Changed -m option to use LaTeXMathML rather than ASCIIMathML. LaTeXMathML is closer to LaTeX in its display of math, and supports many non-math LaTeX environments. + Modified HTML writer to print raw TeX when LaTeXMathML is being used instead of suppressing it. + Removed ASCIIMathML files from data/ and added LaTeXMathML. + Replaced ASCIIMathML with LaTeXMathML in source files. + Modified README and pandoc man page source. + Modified web page. + Added --latexmathml option (kept --asciimathml as a synonym for backwards compatibility) + Modified tests accordingly; added new tests for display math. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1409 788f1e2b-df1e-0410-8736-df70ead52e1b --- Text/Pandoc/Writers/HTML.hs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'Text/Pandoc/Writers/HTML.hs') diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index e5ed4468e..4af644a91 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -30,7 +30,7 @@ Conversion of 'Pandoc' documents to HTML. -} module Text.Pandoc.Writers.HTML ( writeHtml , writeHtmlString ) where import Text.Pandoc.Definition -import Text.Pandoc.ASCIIMathML +import Text.Pandoc.LaTeXMathML import Text.Pandoc.CharacterReferences ( decodeCharacterReferences ) import Text.Pandoc.Shared import Text.Pandoc.Readers.TeXMath @@ -123,9 +123,9 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) = '\n':(unlines $ S.toList cssLines) math = if stMath newstate then case writerHTMLMathMethod opts of - ASCIIMathML Nothing -> - primHtml asciiMathMLScript - ASCIIMathML (Just url) -> + LaTeXMathML Nothing -> + primHtml latexMathMLScript + LaTeXMathML (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml @@ -268,7 +268,7 @@ inlineListToIdentifier' (x:xs) = Apostrophe -> "" Ellipses -> "" LineBreak -> "-" - Math _ -> "" + Math _ _ -> "" TeX _ -> "" HtmlInline _ -> "" Link lst _ -> inlineListToIdentifier' lst @@ -455,10 +455,13 @@ inlineToHtml opts inline = primHtmlChar "rdquo") in do contents <- inlineListToHtml opts lst return $ leftQuote +++ contents +++ rightQuote - (Math str) -> modify (\st -> st {stMath = True}) >> + (Math t str) -> + modify (\st -> st {stMath = True}) >> (case writerHTMLMathMethod opts of - ASCIIMathML _ -> - return $ stringToHtml ("$" ++ str ++ "$") + LaTeXMathML _ -> + return $ if t == InlineMath + then primHtml ("$" ++ str ++ "$") + else primHtml ("$$" ++ str ++ "$$") MimeTeX url -> return $ image ! [src (url ++ "?" ++ str), alt str, title str] @@ -467,7 +470,10 @@ inlineToHtml opts inline = PlainMath -> inlineListToHtml opts (readTeXMath str) >>= return . (thespan ! [theclass "math"])) - (TeX _) -> return noHtml + (TeX str) -> case writerHTMLMathMethod opts of + LaTeXMathML _ -> do modify (\st -> st {stMath = True}) + return $ primHtml str + _ -> return noHtml (HtmlInline str) -> return $ primHtml str (Link [Code str] (s,_)) | "mailto:" `isPrefixOf` s -> return $ obfuscateLink opts str s -- cgit v1.2.3