Typesetting Algorithms in reStructuredText

This blog is written in rst, coming from LaTex I often want to add math equations and this is straightforward to achieve using MathJax. Latex offers excellent packages for typesetting algorithms. Unfortunately, no rst equivalent seems to exist. The solution I'm trying at the moment is create small fragments in LaTex convert them to SVG and add them as these as images to the blog. Here are the steps I'm currently experimenting with. The first state is create a standalone latex document which just contains the markup to typeset the algorithm.

\usepackage{algorithm} %ctan.org\pkg\algorithms
 \State $r\gets a\bmod b$
 \State $a\gets b$
 \State $b\gets r$
 \State $r\gets a\bmod b$
 \State \textbf{return} $b$

This next stage is compile the fragments and convert it to svg using the following:

pdflatex tmp.tex; pdf2svg tmp.pdf tmp.svg

The resuling svg figure can be included as an image in the rst document.

.. image:: tmp.svg

To yield the following:


Surrounding the algorithmic in an algorithm environment causes compilation errors. In addition the document doesn't scale around comments, which are instead cropped off. It would be nice to add some sort of custom role that accepts the algorithm markup and automates the entire process. The final feature I'm missing form this blog is and rst equivalent of bibtex.