git.iko.soy/typeable/pandoc
on master help sign in
Changed how ASCIIMathML is handled:

+ -m|--asciimathml option now takes an *optional* argument, the URL to an asciiMathML.js script. This is much better in situations where multiple files with math must be served, as the script can be cached. + If the argument is provided, a link is inserted; otherwise, the whole script is inserted as before. + Nothing is inserted unless there is inline LaTeX. git-svn-id: https://pandoc.googlecode.com/svn/trunk@799 788f1e2b-df1e-0410-8736-df70ead52e1b

commitf2e21a8476d758cc5503983c7581adb18321a0f3 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 26 Jul 2007, 02:19 (19 years ago) parent831fe2c
3 files changed+28−11
src/Main.hs+14−10 src/Text/Pandoc/Shared.hs+4 src/Text/Pandoc/Writers/HTML.hs+10−1
src/Main.hs+14−10
@@ -31,7 +31,6 @@ writers.
3131module Main where
3232import Text.Pandoc
3333import Text.Pandoc.UTF8
34−import Text.Pandoc.ASCIIMathML
3534import Text.Pandoc.Shared ( joinWithSep, tabsToSpaces )
3635import Text.Regex ( mkRegex, matchRegex )
3736import System.Environment ( getArgs, getProgName, getEnvironment )
@@ -102,7 +101,8 @@ data Opt = Opt
102101 , optNumberSections :: Bool -- ^ Number sections in LaTeX
103102 , optIncremental :: Bool -- ^ Use incremental lists in S5
104103 , optSmart :: Bool -- ^ Use smart typography
105− , optASCIIMathML :: Bool -- ^ Use ASCIIMathML in HTML
104+ , optUseASCIIMathML :: Bool -- ^ Use ASCIIMathML
105+ , optASCIIMathMLURL :: Maybe String -- ^ URL to ASCIIMathML.js
106106 , optDumpArgs :: Bool -- ^ Output command-line arguments
107107 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
108108 , optStrict :: Bool -- ^ Use strict markdown syntax
@@ -129,7 +129,8 @@ defaultOpts = Opt
129129 , optNumberSections = False
130130 , optIncremental = False
131131 , optSmart = False
132− , optASCIIMathML = False
132+ , optUseASCIIMathML = False
133+ , optASCIIMathMLURL = Nothing
133134 , optDumpArgs = False
134135 , optIgnoreArgs = False
135136 , optStrict = False
@@ -195,9 +196,11 @@ options =
195196 "" -- "Use smart quotes, dashes, and ellipses"
196197
197198 , Option "m" ["asciimathml"]
198− (NoArg
199− (\opt -> return opt { optASCIIMathML = True,
200− optStandalone = True }))
199+ (OptArg
200+ (\arg opt -> return opt { optUseASCIIMathML = True,
201+ optASCIIMathMLURL = arg,
202+ optStandalone = True })
203+ "URL")
201204 "" -- "Use ASCIIMathML script in html output"
202205
203206 , Option "i" ["incremental"]
@@ -399,7 +402,8 @@ main = do
399402 , optNumberSections = numberSections
400403 , optIncremental = incremental
401404 , optSmart = smart
402− , optASCIIMathML = math
405+ , optUseASCIIMathML = useAsciiMathML
406+ , optASCIIMathMLURL = asciiMathMLURL
403407 , optDumpArgs = dumpArgs
404408 , optIgnoreArgs = ignoreArgs
405409 , optStrict = strict
@@ -455,11 +459,9 @@ main = do
455459 then ""
456460 else "<link rel=\"stylesheet\" href=\"" ++ css ++
457461 "\" type=\"text/css\" media=\"all\" />\n"
458− let asciiMathML = if math then asciiMathMLScript else ""
459462 let header = (if (customHeader == "DEFAULT")
460463 then defaultHeader
461− else customHeader) ++
462− csslink ++ asciiMathML ++ includeHeader
464+ else customHeader) ++ csslink ++ includeHeader
463465 let writerOptions = WriterOptions { writerStandalone = standalone &&
464466 (not strict),
465467 writerHeader = header,
@@ -468,6 +470,8 @@ main = do
468470 writerTableOfContents = toc &&
469471 (not strict) &&
470472 writerName/="s5",
473+ writerUseASCIIMathML = useAsciiMathML,
474+ writerASCIIMathMLURL = asciiMathMLURL,
471475 writerS5 = (writerName=="s5"),
472476 writerIgnoreNotes = False,
473477 writerIncremental = incremental,
src/Text/Pandoc/Shared.hs+4
@@ -421,6 +421,8 @@ data WriterOptions = WriterOptions
421421 , writerIncludeAfter :: String -- ^ String to include after the body
422422 , writerTableOfContents :: Bool -- ^ Include table of contents
423423 , writerS5 :: Bool -- ^ We're writing S5
424+ , writerUseASCIIMathML :: Bool -- ^ Use ASCIIMathML
425+ , writerASCIIMathMLURL :: Maybe String -- ^ URL to asciiMathML.js
424426 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
425427 , writerIncremental :: Bool -- ^ Incremental S5 lists
426428 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
@@ -438,6 +440,8 @@ defaultWriterOptions =
438440 writerTabStop = 4,
439441 writerTableOfContents = False,
440442 writerS5 = False,
443+ writerUseASCIIMathML = False,
444+ writerASCIIMathMLURL = Nothing,
441445 writerIgnoreNotes = False,
442446 writerIncremental = False,
443447 writerNumberSections = False,
src/Text/Pandoc/Writers/HTML.hs+10−1
@@ -29,6 +29,7 @@ Conversion of 'Pandoc' documents to HTML.
2929-}
3030module Text.Pandoc.Writers.HTML ( writeHtml, writeHtmlString ) where
3131import Text.Pandoc.Definition
32+import Text.Pandoc.ASCIIMathML
3233import Text.Pandoc.Shared
3334import Text.Pandoc.Entities (decodeEntities)
3435import Text.Regex ( mkRegex, matchRegex )
@@ -358,7 +359,15 @@ inlineToHtml opts inline =
358359 primHtmlChar "rdquo") in
359360 do contents <- inlineListToHtml opts lst
360361 return $ leftQuote +++ contents +++ rightQuote
361− (TeX str) -> return $ stringToHtml str
362+ (TeX str) -> do if writerUseASCIIMathML opts
363+ then addToHeader $
364+ case writerASCIIMathMLURL opts of
365+ Just path -> script ! [src path,
366+ thetype "text/javascript"] $
367+ noHtml
368+ Nothing -> primHtml asciiMathMLScript
369+ else return ()
370+ return $ stringToHtml str
362371 (HtmlInline str) -> return $ primHtml str
363372 (Link txt (src,tit)) ->
364373 do linkText <- inlineListToHtml opts txt