aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-18 06:45:56 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-18 06:45:56 +0000
commit56217f100404bc277c53518436ea93973c7705ac (patch)
treee41352966698134d6a7031f2b29e52ba16be1868 /src/Text/Pandoc
parentd704f47b86f49a46fab91969ae3fc92957cc8149 (diff)
downloadpandoc-56217f100404bc277c53518436ea93973c7705ac.tar.gz
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
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/LaTeXMathML.hs13
-rw-r--r--src/Text/Pandoc/Shared.hs1
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs20
3 files changed, 19 insertions, 15 deletions
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 <http://math.etsu.edu/LaTeXMathML/>)
-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 $ "<script type=\"text/javascript\">\n" ++ jsCom ++ jsPacked ++
- "</script>\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 $ "<EQ>" ++ str ++ "</EQ>"
+ 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"]) )