git.iko.soy/typeable/pandoc
on master help sign in
Added --jsmath option.

- Added --jsmath option to Main.hs - Added JsMath to HTMLMathMethod in Text.Pandoc.Shared. - Handle math appropriately in HTML writer when JsMath selected. - Documented the option in README and man page. Resolves Issue #68. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1472 788f1e2b-df1e-0410-8736-df70ead52e1b

commit4f28d47b90d8dde0de21d5db966520959ead8684 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 28 Oct 2008, 21:54 (18 years ago) parent096413b
5 files changed+47−11
Main.hs+6 README+27−11 Text/Pandoc/Shared.hs+1 Text/Pandoc/Writers/HTML.hs+8 man/man1/pandoc.1.md+5
Main.hs+6
@@ -257,6 +257,12 @@ options =
257257 "URL")
258258 "" -- "Use mimetex for HTML math"
259259
260+ , Option "" ["jsmath"]
261+ (OptArg
262+ (\arg opt -> return opt { optHTMLMathMethod = JsMath arg})
263+ "URL")
264+ "" -- "Use jsMath for HTML math"
265+
260266 , Option "" ["gladtex"]
261267 (NoArg
262268 (\opt -> return opt { optHTMLMathMethod = GladTeX }))
README+27−11
@@ -328,19 +328,28 @@ For further documentation, see the `pandoc(1)` man page.
328328 no *url* is provided, the contents of the script will be inserted
329329 directly; this provides portability at the price of efficiency. If
330330 you plan to use math on several pages, it is much better to link to
331− a copy of `LaTeXMathML.js`, which can be cached. (See `--gladtex`
332− and `--mimetex` for alternative ways of dealing with math in HTML.)
331+ a copy of `LaTeXMathML.js`, which can be cached. (See `--jsmath`,
332+ `--gladtex`, and `--mimetex` for alternative ways of dealing with
333+ math in HTML.)
334+
335+`--jsmath`*=[url]*
336+: causes `pandoc` to use the [jsMath] script to display
337+ TeX math in HTML or S5. The *url* should point to the jsMath load
338+ script (e.g. `jsMath/easy/load.js`). If it is provided, a link to it
339+ will be included in the header of standalone HTML documents.
340+ (See `--latexmathml`, `--mimetex`, and `--gladtex` for alternative
341+ ways of dealing with math in HTML.)
333342
334343`--gladtex`*[=url]*
335344: causes TeX formulas to be enclosed in `<eq>` tags in HTML or S5 output.
336345 This output can then be processed by [gladTeX] to produce links to
337− images with the typeset formulas. (See `--latexmathml` and
346+ images with the typeset formulas. (See `--latexmathml`, `--jsmath`, and
338347 `--mimetex` for alternative ways of dealing with math in HTML.)
339348
340349`--mimetex`*[=url]*
341350: causes TeX formulas to be replaced by `<img>` tags linking to the
342351 [mimeTeX] CGI script, which will produce images with the typeset
343− formulas. (See `--latexmathml` and `--gladtex` for alternative
352+ formulas. (See `--latexmathml`, `--jsmath`, and `--gladtex` for alternative
344353 ways of dealing with math in HTML.)
345354
346355`-i` or `--incremental`
@@ -397,6 +406,7 @@ For further documentation, see the `pandoc(1)` man page.
397406
398407[Smartypants]: http://daringfireball.net/projects/smartypants/
399408[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
409+[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
400410[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
401411[mimeTeX]: http://www.forkosh.com/mimetex.html
402412
@@ -924,18 +934,24 @@ command-line options selected:
924934 styled differently from the surrounding text if needed.
925935
9269362. If the `--latexmathml` option is used, TeX math will be displayed
927− between $ characters, as in LaTeX, and the [LaTeXMathML] script will
928− be used to render it as formulas. (This trick does not work in all
929− browsers, but it works in Firefox. In browsers that do not support
930− LaTeXMathML, TeX math will appear verbatim between $ characters.)
931−
932−3. If the `--mimetex` option is used, the [mimeTeX] CGI script will
937+ between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
938+ The [LaTeXMathML] script will be used to render it as formulas.
939+ (This trick does not work in all browsers, but it works in Firefox.
940+ In browsers that do not support LaTeXMathML, TeX math will appear
941+ verbatim between $ characters.)
942+
943+3. If the `--jsmath` option is used, TeX math will be put inside
944+ `<span>` tags (for inline math) or `<div>` tags (for display math)
945+ with class `math`. The [jsMath] script will be used to render
946+ it.
947+
948+4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
933949 be called to generate images for each TeX formula. This should
934950 work in all browsers. The `--mimetex` option takes an optional URL
935951 as argument. If no URL is specified, it will be assumed that the
936952 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
937953
938−4. If the `--gladtex` option is used, TeX formulas will be enclosed
954+5. If the `--gladtex` option is used, TeX formulas will be enclosed
939955 in `<eq>` tags in the HTML output. The resulting `htex` file may then
940956 be processed by [gladTeX], which will produce image files for each
941957 formula and an `html` file with links to these images. So, the
Text/Pandoc/Shared.hs+1
@@ -870,6 +870,7 @@ isHeaderBlock _ = False
870870
871871data HTMLMathMethod = PlainMath
872872 | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js
873+ | JsMath (Maybe String) -- url of jsMath load script
873874 | GladTeX
874875 | MimeTeX String -- url of mimetex.cgi
875876 deriving (Show, Read, Eq)
Text/Pandoc/Writers/HTML.hs+8
@@ -129,6 +129,10 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) =
129129 script !
130130 [src url, thetype "text/javascript"] $
131131 noHtml
132+ JsMath (Just url) ->
133+ script !
134+ [src url, thetype "text/javascript"] $
135+ noHtml
132136 _ -> noHtml
133137 else noHtml
134138 head' = header $ metadata +++ math +++ css +++
@@ -467,6 +471,10 @@ inlineToHtml opts inline =
467471 if t == InlineMath
468472 then primHtml ("$" ++ str ++ "$")
469473 else primHtml ("$$" ++ str ++ "$$")
474+ JsMath _ ->
475+ return $ if t == InlineMath
476+ then thespan ! [theclass "math"] $ primHtml str
477+ else thediv ! [theclass "math"] $ primHtml str
470478 MimeTeX url ->
471479 return $ image ! [src (url ++ "?" ++ str),
472480 alt str, title str]
man/man1/pandoc.1.md+5
@@ -112,6 +112,11 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
112112 provide a *URL*. If no *URL* is provided, the contents of the
113113 script will be inserted directly into the HTML header.
114114
115+\--jsmath=*URL*
116+: Use jsMath to display embedded TeX math in HTML output.
117+ The *URL* should point to the jsMath load script; if provided,
118+ it will be linked to in the header of standalone HTML documents.
119+
115120\--gladtex
116121: Enclose TeX math in `<eq>` tags in HTML output. These can then
117122 be processed by gladTeX to produce links to images of the typeset