reStructuredText to HTML

Author: Ben Reynwar
Copyright: Public Domain
Created:2011 March 25
Last Edited:2011 May 28

I've recently decided to use reStructuredText for making notes and needed a method to convert them into html. The reStructuredText contains code snippets as well as mathematical notation so the conversion process needed to be able to handle that.

docutils is the obvious candidate to do the conversion, however it doesn't do syntax highlighting or MathML out of the box, so I needed to find extensions that could.

I decided to use Pygments for the syntax highlighting of the code snippets. The Pygments package comes with a file that creates a directive called 'sourcecode' that can then be used to define code snippets.

For the maths I found rst2mathml which adds a directive converting tex math notation in a reStructuredText file to MathML in the html.

So the list of steps to get this working was:

#!/usr/bin/env bash

echo input file name is $1
python /home/ben/Documents/Notes/ --stylesheet-path=/home/ben/Documents/Notes/style.css $1 > $stem.xhtml