Added --gladtex and --mimetex options.

+ New HTMLMathMethod structure in WriterOptions keeps track of how to
  display math in HTML output.
+ If none of the special options are selected, default to displaying
  TeX math verbatim, with no enclosing $'s, in HTML.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@1125 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-12-01 03:11:52 +00:00
parent 6e079a67e8
commit ef028fee59
2 changed files with 22 additions and 14 deletions

30
Main.hs
View file

@ -98,8 +98,7 @@ data Opt = Opt
, optNumberSections :: Bool -- ^ Number sections in LaTeX , optNumberSections :: Bool -- ^ Number sections in LaTeX
, optIncremental :: Bool -- ^ Use incremental lists in S5 , optIncremental :: Bool -- ^ Use incremental lists in S5
, optSmart :: Bool -- ^ Use smart typography , optSmart :: Bool -- ^ Use smart typography
, optUseASCIIMathML :: Bool -- ^ Use ASCIIMathML , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
, optASCIIMathMLURL :: Maybe String -- ^ URL to ASCIIMathML.js
, optDumpArgs :: Bool -- ^ Output command-line arguments , optDumpArgs :: Bool -- ^ Output command-line arguments
, optIgnoreArgs :: Bool -- ^ Ignore command-line arguments , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
, optStrict :: Bool -- ^ Use strict markdown syntax , optStrict :: Bool -- ^ Use strict markdown syntax
@ -127,8 +126,7 @@ defaultOpts = Opt
, optNumberSections = False , optNumberSections = False
, optIncremental = False , optIncremental = False
, optSmart = False , optSmart = False
, optUseASCIIMathML = False , optHTMLMathMethod = PlainMath
, optASCIIMathMLURL = Nothing
, optDumpArgs = False , optDumpArgs = False
, optIgnoreArgs = False , optIgnoreArgs = False
, optStrict = False , optStrict = False
@ -196,12 +194,23 @@ options =
, Option "m" ["asciimathml"] , Option "m" ["asciimathml"]
(OptArg (OptArg
(\arg opt -> return opt { optUseASCIIMathML = True, (\arg opt -> return opt { optHTMLMathMethod =
optASCIIMathMLURL = arg, ASCIIMathML arg })
optStandalone = True })
"URL") "URL")
"" -- "Use ASCIIMathML script in html output" "" -- "Use ASCIIMathML script in html output"
, Option "" ["mimetex"]
(OptArg
(\arg opt -> return opt { optHTMLMathMethod = MimeTeX
(fromMaybe "/cgi-bin/mimetex.cgi" arg)})
"URL")
"" -- "Use mimetex for HTML math"
, Option "" ["gladtex"]
(NoArg
(\opt -> return opt { optHTMLMathMethod = GladTeX }))
"" -- "Use gladtex for HTML math"
, Option "i" ["incremental"] , Option "i" ["incremental"]
(NoArg (NoArg
(\opt -> return opt { optIncremental = True })) (\opt -> return opt { optIncremental = True }))
@ -406,8 +415,7 @@ main = do
, optNumberSections = numberSections , optNumberSections = numberSections
, optIncremental = incremental , optIncremental = incremental
, optSmart = smart , optSmart = smart
, optUseASCIIMathML = useASCIIMathML , optHTMLMathMethod = mathMethod
, optASCIIMathMLURL = asciiMathMLURL
, optDumpArgs = dumpArgs , optDumpArgs = dumpArgs
, optIgnoreArgs = ignoreArgs , optIgnoreArgs = ignoreArgs
, optStrict = strict , optStrict = strict
@ -450,10 +458,6 @@ main = do
Just cols -> read cols Just cols -> read cols
Nothing -> stateColumns defaultParserState Nothing -> stateColumns defaultParserState
let mathMethod = if useASCIIMathML
then ASCIIMathML asciiMathMLURL
else PlainMath
let tabFilter _ [] = "" let tabFilter _ [] = ""
tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs) tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs)
-- remove DOS line endings -- remove DOS line endings

View file

@ -404,9 +404,13 @@ inlineToHtml opts inline =
(return $ case writerHTMLMathMethod opts of (return $ case writerHTMLMathMethod opts of
ASCIIMathML _ -> ASCIIMathML _ ->
stringToHtml ("$" ++ str ++ "$") stringToHtml ("$" ++ str ++ "$")
MimeTeX url ->
image ! [src (url ++ "?" ++ str),
alt str, title str]
GladTeX -> GladTeX ->
tag "eq" << str tag "eq" << str
_ -> stringToHtml ("$" ++ str ++ "$")) PlainMath ->
stringToHtml str)
(TeX str) -> return noHtml (TeX str) -> return noHtml
(HtmlInline str) -> return $ primHtml str (HtmlInline str) -> return $ primHtml str
(Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src -> (Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->