I’ve been using Markdown, a simplified syntax for creating (X)HTML, on this blog since it started, and I’ve also adopted it for a number of things that aren’t fussy enough to want a word processor or LaTeX to do. But that’s exactly the problem sometimes: I want print output, and I want something simple like Markdown to get it, rather than fooling around writing LaTeX (just like I don’t want to fool around writing XHTML). Other people want this too, so I’ve lurked around the Markdown discussion list seeing what ideas there are. Most of the talk has involved hacking up Markdown (written in Perl) to make it spit out LaTeX instead of XHTML, but my Perl is about as good as my Spanish (which is to say, not good), and besides, this is a maintenance nightmare.
Then I stumbled on Fletcher Penney’s MultiMarkdown, which adds the following to Markdown:
- create a full XHTML document (with the headers, etc.) instead of just a snippet
- add basic metadata used in XHTML and LaTeX (title, author, etc.)
- footnotes! (which are a proposed addition to the “official” Markdown)
- a set of XSLT stylesheets for transforming the XHTML into LaTeX
This is better, because my XSLT is like my German, which is at least intelligible. And with the addition of footnotes (and a semi-standardized way to represent them in XHTML), the XHTML should be capable of bearing the semantic burden necessary to get LaTeX out of it with relatively little manual cleanup afterward. I have to work on the stylesheets to get exactly what I want out of them, but once they’re done, they’re pretty stable for my purposes.
This is still a branch from Markdown, but it’s necessary for me until Markdown includes footnotes. I think I will work on refactoring the other additions (full document & metadata) into a preprocessor for Markdown, so the chain is something like:
myPreprocessor.pl sample.txt | Markdown.pl | SmartyPants.pl |
xsltproc xhtml2article.xslt > sample.tex
Then I can just replace Markdown.pl with any upgrades or bug fixes without “fixing” it.
Gee, it’s really nice to have had a couple hours to finally work that out last night, because it’s been on my list of things to do since August but it seemed so daunting. As it turns out, not really that bad.