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:
parent
6e079a67e8
commit
ef028fee59
2 changed files with 22 additions and 14 deletions
30
Main.hs
30
Main.hs
|
@ -98,8 +98,7 @@ data Opt = Opt
|
|||
, optNumberSections :: Bool -- ^ Number sections in LaTeX
|
||||
, optIncremental :: Bool -- ^ Use incremental lists in S5
|
||||
, optSmart :: Bool -- ^ Use smart typography
|
||||
, optUseASCIIMathML :: Bool -- ^ Use ASCIIMathML
|
||||
, optASCIIMathMLURL :: Maybe String -- ^ URL to ASCIIMathML.js
|
||||
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
|
||||
, optDumpArgs :: Bool -- ^ Output command-line arguments
|
||||
, optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
|
||||
, optStrict :: Bool -- ^ Use strict markdown syntax
|
||||
|
@ -127,8 +126,7 @@ defaultOpts = Opt
|
|||
, optNumberSections = False
|
||||
, optIncremental = False
|
||||
, optSmart = False
|
||||
, optUseASCIIMathML = False
|
||||
, optASCIIMathMLURL = Nothing
|
||||
, optHTMLMathMethod = PlainMath
|
||||
, optDumpArgs = False
|
||||
, optIgnoreArgs = False
|
||||
, optStrict = False
|
||||
|
@ -196,12 +194,23 @@ options =
|
|||
|
||||
, Option "m" ["asciimathml"]
|
||||
(OptArg
|
||||
(\arg opt -> return opt { optUseASCIIMathML = True,
|
||||
optASCIIMathMLURL = arg,
|
||||
optStandalone = True })
|
||||
(\arg opt -> return opt { optHTMLMathMethod =
|
||||
ASCIIMathML arg })
|
||||
"URL")
|
||||
"" -- "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"]
|
||||
(NoArg
|
||||
(\opt -> return opt { optIncremental = True }))
|
||||
|
@ -406,8 +415,7 @@ main = do
|
|||
, optNumberSections = numberSections
|
||||
, optIncremental = incremental
|
||||
, optSmart = smart
|
||||
, optUseASCIIMathML = useASCIIMathML
|
||||
, optASCIIMathMLURL = asciiMathMLURL
|
||||
, optHTMLMathMethod = mathMethod
|
||||
, optDumpArgs = dumpArgs
|
||||
, optIgnoreArgs = ignoreArgs
|
||||
, optStrict = strict
|
||||
|
@ -450,10 +458,6 @@ main = do
|
|||
Just cols -> read cols
|
||||
Nothing -> stateColumns defaultParserState
|
||||
|
||||
let mathMethod = if useASCIIMathML
|
||||
then ASCIIMathML asciiMathMLURL
|
||||
else PlainMath
|
||||
|
||||
let tabFilter _ [] = ""
|
||||
tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs)
|
||||
-- remove DOS line endings
|
||||
|
|
|
@ -404,9 +404,13 @@ inlineToHtml opts inline =
|
|||
(return $ case writerHTMLMathMethod opts of
|
||||
ASCIIMathML _ ->
|
||||
stringToHtml ("$" ++ str ++ "$")
|
||||
MimeTeX url ->
|
||||
image ! [src (url ++ "?" ++ str),
|
||||
alt str, title str]
|
||||
GladTeX ->
|
||||
tag "eq" << str
|
||||
_ -> stringToHtml ("$" ++ str ++ "$"))
|
||||
PlainMath ->
|
||||
stringToHtml str)
|
||||
(TeX str) -> return noHtml
|
||||
(HtmlInline str) -> return $ primHtml str
|
||||
(Link [Code str] (src,tit)) | "mailto:" `isPrefixOf` src ->
|
||||
|
|
Loading…
Reference in a new issue