From 4f28d47b90d8dde0de21d5db966520959ead8684 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Tue, 28 Oct 2008 21:54:50 +0000 Subject: 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 --- Main.hs | 6 ++++++ README | 38 +++++++++++++++++++++++++++----------- Text/Pandoc/Shared.hs | 1 + Text/Pandoc/Writers/HTML.hs | 8 ++++++++ man/man1/pandoc.1.md | 5 +++++ 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Main.hs b/Main.hs index 46c78e159..7853234e6 100644 --- a/Main.hs +++ b/Main.hs @@ -257,6 +257,12 @@ options = "URL") "" -- "Use mimetex for HTML math" + , Option "" ["jsmath"] + (OptArg + (\arg opt -> return opt { optHTMLMathMethod = JsMath arg}) + "URL") + "" -- "Use jsMath for HTML math" + , Option "" ["gladtex"] (NoArg (\opt -> return opt { optHTMLMathMethod = GladTeX })) diff --git a/README b/README index 05af25c31..230ad9c5b 100644 --- a/README +++ b/README @@ -328,19 +328,28 @@ For further documentation, see the `pandoc(1)` man page. no *url* is provided, the contents of the script will be inserted directly; this provides portability at the price of efficiency. If you plan to use math on several pages, it is much better to link to - a copy of `LaTeXMathML.js`, which can be cached. (See `--gladtex` - and `--mimetex` for alternative ways of dealing with math in HTML.) + a copy of `LaTeXMathML.js`, which can be cached. (See `--jsmath`, + `--gladtex`, and `--mimetex` for alternative ways of dealing with + math in HTML.) + +`--jsmath`*=[url]* +: causes `pandoc` to use the [jsMath] script to display + TeX math in HTML or S5. The *url* should point to the jsMath load + script (e.g. `jsMath/easy/load.js`). If it is provided, a link to it + will be included in the header of standalone HTML documents. + (See `--latexmathml`, `--mimetex`, and `--gladtex` for alternative + ways of dealing with math in HTML.) `--gladtex`*[=url]* : causes TeX formulas to be enclosed in `` tags in HTML or S5 output. This output can then be processed by [gladTeX] to produce links to - images with the typeset formulas. (See `--latexmathml` and + images with the typeset formulas. (See `--latexmathml`, `--jsmath`, and `--mimetex` for alternative ways of dealing with math in HTML.) `--mimetex`*[=url]* : causes TeX formulas to be replaced by `` tags linking to the [mimeTeX] CGI script, which will produce images with the typeset - formulas. (See `--latexmathml` and `--gladtex` for alternative + formulas. (See `--latexmathml`, `--jsmath`, and `--gladtex` for alternative ways of dealing with math in HTML.) `-i` or `--incremental` @@ -397,6 +406,7 @@ For further documentation, see the `pandoc(1)` man page. [Smartypants]: http://daringfireball.net/projects/smartypants/ [LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/ +[jsMath]: http://www.math.union.edu/~dpvc/jsmath/ [gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html [mimeTeX]: http://www.forkosh.com/mimetex.html @@ -924,18 +934,24 @@ command-line options selected: styled differently from the surrounding text if needed. 2. If the `--latexmathml` option is used, TeX math will be displayed - between $ characters, as in LaTeX, and the [LaTeXMathML] script will - be used to render it as formulas. (This trick does not work in all - browsers, but it works in Firefox. In browsers that do not support - LaTeXMathML, TeX math will appear verbatim between $ characters.) - -3. If the `--mimetex` option is used, the [mimeTeX] CGI script will + between $ or $$ characters and put in `` tags with class `LaTeX`. + The [LaTeXMathML] script will be used to render it as formulas. + (This trick does not work in all browsers, but it works in Firefox. + In browsers that do not support LaTeXMathML, TeX math will appear + verbatim between $ characters.) + +3. If the `--jsmath` option is used, TeX math will be put inside + `` tags (for inline math) or `
` tags (for display math) + with class `math`. The [jsMath] script will be used to render + it. + +4. If the `--mimetex` option is used, the [mimeTeX] CGI script will be called to generate images for each TeX formula. This should work in all browsers. The `--mimetex` option takes an optional URL as argument. If no URL is specified, it will be assumed that the mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`. -4. If the `--gladtex` option is used, TeX formulas will be enclosed +5. If the `--gladtex` option is used, TeX formulas will be enclosed in `` tags in the HTML output. The resulting `htex` file may then be processed by [gladTeX], which will produce image files for each formula and an `html` file with links to these images. So, the diff --git a/Text/Pandoc/Shared.hs b/Text/Pandoc/Shared.hs index 30fd3fc07..8b08a0e94 100644 --- a/Text/Pandoc/Shared.hs +++ b/Text/Pandoc/Shared.hs @@ -870,6 +870,7 @@ isHeaderBlock _ = False data HTMLMathMethod = PlainMath | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js + | JsMath (Maybe String) -- url of jsMath load script | GladTeX | MimeTeX String -- url of mimetex.cgi deriving (Show, Read, Eq) diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 628e784ed..8dafd2440 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -129,6 +129,10 @@ writeHtml opts (Pandoc (Meta tit authors date) blocks) = script ! [src url, thetype "text/javascript"] $ noHtml + JsMath (Just url) -> + script ! + [src url, thetype "text/javascript"] $ + noHtml _ -> noHtml else noHtml head' = header $ metadata +++ math +++ css +++ @@ -467,6 +471,10 @@ inlineToHtml opts inline = if t == InlineMath then primHtml ("$" ++ str ++ "$") else primHtml ("$$" ++ str ++ "$$") + JsMath _ -> + return $ if t == InlineMath + then thespan ! [theclass "math"] $ primHtml str + else thediv ! [theclass "math"] $ primHtml str MimeTeX url -> return $ image ! [src (url ++ "?" ++ str), alt str, title str] diff --git a/man/man1/pandoc.1.md b/man/man1/pandoc.1.md index f50fab050..bbd4e725e 100644 --- a/man/man1/pandoc.1.md +++ b/man/man1/pandoc.1.md @@ -112,6 +112,11 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`. provide a *URL*. If no *URL* is provided, the contents of the script will be inserted directly into the HTML header. +\--jsmath=*URL* +: Use jsMath to display embedded TeX math in HTML output. + The *URL* should point to the jsMath load script; if provided, + it will be linked to in the header of standalone HTML documents. + \--gladtex : Enclose TeX math in `` tags in HTML output. These can then be processed by gladTeX to produce links to images of the typeset -- cgit v1.2.3