+++ title = 'Render reStructuredText Directly to Firefox' date = 2013-01-23T18:13:00Z +++ [reStructuredText](http://docutils.sourceforge.net/rst.html) is awesome. Anytime I need to write something in plain text, I mark it up using rST. It looks nice in plain text form, and can be rendered to HTML for improved presentation. Sometimes, as I am working on a document, I'd like to see what it looks like once rendered to HTML, to make sure I am thinking the same way the computer is. [Docutils](http://docutils.sourceforge.net/) ships with a nice little script called `rst2html` that will render a rST document as HTML, either to standard output or another file. What would be really nice is to be able to immediately preview the resulting HTML document in Firefox without the intermediate file. Unfortunately, Firefox doesn't read HTML from standard input, so `rst2html.py document.rst | firefox` doesn't work. I've come up with this workaround, however, that works just fine. Using `base64` and `xargs`, I construct a [Data URI](http://en.wikipedia.org/wiki/Data_URI_scheme) and instruct Firefox to open that: ```sh rst2html.py document.rst | base64 -w 0 | xargs -i firefox "data:text/html;charset=utf8;base64,{}" ```