From 56217f100404bc277c53518436ea93973c7705ac Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Thu, 18 Mar 2010 06:45:56 +0000 Subject: Added --mathml option; removed Text.Pandoc.LaTeXMathML. * Added data/MathMLinHTML.js, which is included when no URL is provided for --mathml. This allows MathML to be displayed in better browsers, as text/html. * The module was no longer necessary; its functionality (two lines) was incorporated into pandoc.hs. * Consolidated the two LaTeXMathML.js files into one. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1909 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/LaTeXMathML.hs | 13 ------------- src/Text/Pandoc/Shared.hs | 1 + src/Text/Pandoc/Writers/HTML.hs | 20 ++++++++++++++++++-- 3 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 src/Text/Pandoc/LaTeXMathML.hs (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/LaTeXMathML.hs b/src/Text/Pandoc/LaTeXMathML.hs deleted file mode 100644 index 0c8f74bdf..000000000 --- a/src/Text/Pandoc/LaTeXMathML.hs +++ /dev/null @@ -1,13 +0,0 @@ --- | Definitions for use of LaTeXMathML in HTML. --- (See ) -module Text.Pandoc.LaTeXMathML ( latexMathMLScript ) where -import System.FilePath ( () ) -import Text.Pandoc.Shared (readDataFile) - --- | String containing LaTeXMathML javascript. -latexMathMLScript :: Maybe FilePath -> IO String -latexMathMLScript datadir = do - jsCom <- readDataFile datadir $ "data" "LaTeXMathML.js.comment" - jsPacked <- readDataFile datadir $ "data" "LaTeXMathML.js.packed" - return $ "\n" diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index a27a2c907..f093ddbee 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -979,6 +979,7 @@ data HTMLMathMethod = PlainMath | JsMath (Maybe String) -- url of jsMath load script | GladTeX | MimeTeX String -- url of mimetex.cgi + | MathML (Maybe String) -- url of MathMLinHTML.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 020edea65..ddffa471b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -42,6 +42,8 @@ import Data.List ( isPrefixOf, intersperse ) import Data.Maybe ( catMaybes ) import Control.Monad.State import Text.XHtml.Transitional hiding ( stringToHtml ) +import Text.TeXMath +import Text.XML.Light.Output data WriterState = WriterState { stNotes :: [Html] -- ^ List of notes @@ -111,17 +113,20 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do LaTeXMathML (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml + MathML (Just url) -> + script ! + [src url, thetype "text/javascript"] $ noHtml JsMath (Just url) -> script ! [src url, thetype "text/javascript"] $ noHtml - _ -> case lookup "latexmathml-script" (writerVariables opts) of + _ -> case lookup "mathml-script" (writerVariables opts) of Just s -> script ! [thetype "text/javascript"] << primHtml s Nothing -> noHtml else noHtml let newvars = [("highlighting","yes") | stHighlighting st] ++ - [("math", renderHtmlFragment math) | stMath st] + [("math", renderHtmlFragment math) | stMath st] return (tit, auths, date, toc, thebody, newvars) inTemplate :: TemplateTarget a @@ -450,6 +455,17 @@ inlineToHtml opts inline = alt str, title str] GladTeX -> return $ primHtml $ "" ++ str ++ "" + MathML _ -> 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 _ -> inlineToHtml opts + (Math t str) PlainMath -> inlineListToHtml opts (readTeXMath str) >>= return . (thespan ! [theclass "math"]) ) -- cgit v1.2.3