reST to WordML
I’ve blogged about how much I like reStructuredText in the past. One of the problems with it though is getting PDF output; it’s unwieldy and not accurate. The reST->LaTeX->PDF pipeline is not very friendly and there are problems with the figure alignment in the resulting PDF.
Microsoft Word can produce very nice PDFs. Unfortunately, it’s not easy (read: nigh upon impossible) to intermingle code and text within a Word document (for example, literate programming), something that reST was designed to do.
Hm, if reST and MS Word were chocolate and peanut butter…
Well, as it happens to be, Microsoft had the foresight in Office 2003 to create an XML format for each of their Office applications, including MS Word. The reST tools are written to output a node based hierarchy, which lends itself to HTML and XML output. Sounds like chocolate and peanut butter to me.
To this end, I’ve started a simple reST writer for WordML. It’s very basic and only does maybe 1/10-1/5 of the features in reST, but it is a start. Couple this with a good PDF printer driver for Word, and it’s easy to make (accurate) PDFs. As a bonus, the Word Viewer can load these XML files and print them, meaning you don’t even need MS Word to be installed (though you’re stuck with the styles in the template file.)
Edit: I’ve added footnotes and images. Footnotes are implemented as endnotes, to simulate the HTML output more closely. Images are their own paragraph, usually centered. Also, their size is not determined, so you have to supply it.
Edit: Enumerated lists are fully implemented now. I use lists a lot, so this goes a long way to getting my own writing projects started.