The previous post showed some new math rendering tools for supporting Latex for Blogger. That still relied on `htlatex`

(in the `tex4ht`

package) for converting Latex into HTML. I just found another tool called Pandoc that converts between lots of different markup languages. Here’s the first paragraph from the manpage.

Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library. It can read markdown and (subsets of) Textile, reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, Medi‐ aWiki markup, EPUB, Textile, groff man pages, Emacs Org-Mode, and Slidy or S5 HTML slide shows.

Sounds promising. So, this post is written in Latex, and then I converted it to HTML with this command:

```
[jstults@grafton pandoc]$ pandoc -f latex -t html -o pandoc.html pandoc.tex
```

Here’s some test equations: *f*(*x*) = *x*^{2}

$\frac{\partial U}{\partial t} = \nabla U
$

Φ = ϕ - ∫ _{t0}^{t}*f*(τ) dτ

hmm, doesn't seem to convert the second equation into something that MathJax will render.

ReplyDeleteConcur, FAIL on the second equation.

ReplyDeleteWith those options, pandoc won't use mathjax. It just tries as best it can to render the formula in Unicode. Try using the `--mathjax` option or one of the other math options that pandoc supports (for mathjax, you'll need to have a way to load the mathjax script into the page; not sure how to do that on blogger).

ReplyDeleteOops. Hadn't read your previous post. So

ReplyDeletepandoc -f latex -t html --mathjax -o pandoc.html pandoc.tex

should get you what you want.

Awesome, thanks!

ReplyDeleteThe URL for the --mathjax option is not optional (it is for --mathml and --jsmath), so the full command is (using the script from the previous post):

ReplyDeletepandoc -f latex -t html --mathjax=http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML -o foo.html foo.tex