git.iko.soy/typeable/pandoc
on master help sign in
Added HTMLMathMethod writer option.

This selects between asciimathml, mimetex, gladtex, and plain math. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1123 788f1e2b-df1e-0410-8736-df70ead52e1b

commit0b15448d646ba2e2b8db523e9065f820cfa179ba authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 1 Dec 2007, 03:11 (19 years ago) parent7ddd01e
3 files changed+31−17
Main.hs+7−4 Text/Pandoc/Shared.hs+9−4 Text/Pandoc/Writers/HTML.hs+15−9
Main.hs+7−4
@@ -31,7 +31,7 @@ writers.
3131module Main where
3232import Text.Pandoc
3333import Text.Pandoc.UTF8
34−import Text.Pandoc.Shared ( joinWithSep )
34+import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
3535import Text.Regex ( mkRegex, matchRegex )
3636import System.Environment ( getArgs, getProgName, getEnvironment )
3737import System.Exit ( exitWith, ExitCode (..) )
@@ -406,7 +406,7 @@ main = do
406406 , optNumberSections = numberSections
407407 , optIncremental = incremental
408408 , optSmart = smart
409− , optUseASCIIMathML = useAsciiMathML
409+ , optUseASCIIMathML = useASCIIMathML
410410 , optASCIIMathMLURL = asciiMathMLURL
411411 , optDumpArgs = dumpArgs
412412 , optIgnoreArgs = ignoreArgs
@@ -450,6 +450,10 @@ main = do
450450 Just cols -> read cols
451451 Nothing -> stateColumns defaultParserState
452452
453+ let mathMethod = if useASCIIMathML
454+ then ASCIIMathML asciiMathMLURL
455+ else PlainMath
456+
453457 let tabFilter _ [] = ""
454458 tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs)
455459 -- remove DOS line endings
@@ -487,8 +491,7 @@ main = do
487491 writerTableOfContents = toc &&
488492 (not strict) &&
489493 writerName/="s5",
490− writerUseASCIIMathML = useAsciiMathML,
491− writerASCIIMathMLURL = asciiMathMLURL,
494+ writerHTMLMathMethod = mathMethod,
492495 writerS5 = (writerName=="s5"),
493496 writerIgnoreNotes = False,
494497 writerIncremental = incremental,
Text/Pandoc/Shared.hs+9−4
@@ -92,6 +92,7 @@ module Text.Pandoc.Shared (
9292 hierarchicalize,
9393 isHeaderBlock,
9494 -- * Writer options
95+ HTMLMathMethod (..),
9596 WriterOptions (..),
9697 defaultWriterOptions
9798 ) where
@@ -796,6 +797,12 @@ isHeaderBlock _ = False
796797-- Writer options
797798--
798799
800+data HTMLMathMethod = PlainMath
801+ | ASCIIMathML (Maybe String) -- url of ASCIIMathML.js
802+ | GladTeX
803+ | MimeTeX String -- url of mimetex.cgi
804+ deriving (Show, Read, Eq)
805+
799806-- | Options for writers
800807data WriterOptions = WriterOptions
801808 { writerStandalone :: Bool -- ^ Include header and footer
@@ -804,8 +811,7 @@ data WriterOptions = WriterOptions
804811 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
805812 , writerTableOfContents :: Bool -- ^ Include table of contents
806813 , writerS5 :: Bool -- ^ We're writing S5
807− , writerUseASCIIMathML :: Bool -- ^ Use ASCIIMathML
808− , writerASCIIMathMLURL :: Maybe String -- ^ URL to asciiMathML.js
814+ , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
809815 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
810816 , writerIncremental :: Bool -- ^ Incremental S5 lists
811817 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -825,8 +831,7 @@ defaultWriterOptions =
825831 , writerTabStop = 4
826832 , writerTableOfContents = False
827833 , writerS5 = False
828− , writerUseASCIIMathML = False
829− , writerASCIIMathMLURL = Nothing
834+ , writerHTMLMathMethod = PlainMath
830835 , writerIgnoreNotes = False
831836 , writerIncremental = False
832837 , writerNumberSections = False
Text/Pandoc/Writers/HTML.hs+15−9
@@ -100,11 +100,14 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) =
100100 else style ! [thetype "text/css"] $ primHtml $
101101 '\n':(unlines $ S.toList cssLines)
102102 math = if stMath newstate
103− then case writerASCIIMathMLURL opts of
104− Just path -> script ! [src path,
105− thetype "text/javascript"] $
106− noHtml
107− Nothing -> primHtml asciiMathMLScript
103+ then case writerHTMLMathMethod opts of
104+ ASCIIMathML Nothing ->
105+ primHtml asciiMathMLScript
106+ ASCIIMathML (Just url) ->
107+ script !
108+ [src url, thetype "text/javascript"] $
109+ noHtml
110+ _ -> noHtml
108111 else noHtml
109112 head = header $ metadata +++ math +++ css +++
110113 primHtml (writerHeader opts)
@@ -397,10 +400,13 @@ inlineToHtml opts inline =
397400 primHtmlChar "rdquo")
398401 in do contents <- inlineListToHtml opts lst
399402 return $ leftQuote +++ contents +++ rightQuote
400− (Math str) -> (if writerUseASCIIMathML opts
401− then modify (\st -> st {stMath = True})
402− else return ()) >>
403− return (stringToHtml ("$" ++ str ++ "$"))
403+ (Math str) -> modify (\st -> st {stMath = True}) >>
404+ (return $ case writerHTMLMathMethod opts of
405+ ASCIIMathML _ ->
406+ stringToHtml ("$" ++ str ++ "$")
407+ GladTeX ->
408+ tag "eq" << str
409+ _ -> stringToHtml ("$" ++ str ++ "$"))
404410 (TeX str) -> return noHtml
405411 (HtmlInline str) -> return $ primHtml str
406412 (Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->