### latex2wp

I have a problem. I want to do all my writing in LaTeX, but I want to post some of it on my WordPress blog. I often use math; in fact, I often use a lot of math, and some of it is particularly difficult to typeset, like commutative diagrams.

WordPress has some ways of handling inline LaTeX—in particular, WP-LaTeX converts it to embedded images, and MathJax-LaTeX renders it client-side with a heady mix of JavaScript and CSS. But this doesn’t necessarily scale to complex packages for inference rules, commutative diagrams, and the like, without requiring custom hackery. And these solutions still require HTML markup on text, rather than LaTeX.

Here’s my solution. I’ve written a Haskell script, `latex2wp`

, which takes a `.tex`

file and outputs a `.html`

file with markup suitable for WordPress. Inline math is kept intact and can be rendered with one of the aforementioned LaTeX plugins. Display math is rendered as PNGs and hotlinked, to support any fancy packages you might use.

Luca Trevisan also has a LaTeX2WP script, so I should explain how these differ. Mine relies on Pandoc (the Haskell-based Esperanto of text markup) for the translation, so it automatically supports a wide range of LaTeX features, including hyperlinks and macro expansion inside math mode.

Luca’s script does the translation manually, so it supports a more eclectic (though impressively large) subset of LaTeX. More importantly to me, it doesn’t handle commutative diagrams. Apologies for stealing the apt name—in a case-insensitive world, at least.

Let me know if you find it useful, and please contribute! The script is somewhat fragile right now—it only works on Linux, and you need to trivially edit the source to include any additional LaTeX packages.