Live preview Markdown and reStructuredText files as HTML in a web browser
The preview-markup program takes a text file with lightweight markup (Markdown and reStructuredText are supported) and shows a live preview of the markup rendered to HTML in your web browser. When you save your text file the preview is automatically updated within a couple of seconds. That’s all there is to it!
The preview-markup program is written in Python and is available on PyPI which means installation should be as simple as:
$ pip install preview-markup
There’s actually a multitude of ways to install Python packages (e.g. the per user site-packages directory, virtual environments or just installing system wide) and I have no intention of getting into that discussion here, so if this intimidates you then read up on your options before returning to these instructions ;-).
To get started you simply run the command preview-markup. If you give it a filename as an argument then that file will be previewed, otherwise the README.md or README.rst file in the current working directory is previewed.
If you want to run preview-markup in the background then you probably won’t appreciate the logging to the terminal that is enabled by default. In this case I suggest you use the following command line:
$ preview-markup -q &
The -q is short for --quiet and the & instructs your shell to run the program in the background. If you want to kill the program later on just run the fg command (this will bring the program back to the foreground) and then press Control-C (this will kill the program).
Some random ideas for future improvements (I may implement these as time permits or when I feel like programming but don’t feel like picking up one of my many other projects):
Different variations of preview-markup have lived in my private dotfiles repository for years now (I track ~/bin in my dotfiles repository). Over those years the program has had several names and very similar yet slightly different purposes. By the time I decided to clean up these “variations on a similar theme” I was using several different shell and Python scripts working together to do the same things that preview-markup now does. I decided to merge, cleanup, document and publish that mess of Python and shell scripts for multiple reasons:
I created preview-markup because I couldn’t find a tool that provided live previews of Markdown and reStructuredText markup and just because it was fun to work on, however this is clearly an itch that dozens of developers have scratched over the years :-). Here are some similar projects that I’ve run into and/or used in the past:
The latest version of preview-markup is available on PyPI and GitHub. For bug reports please create an issue on GitHub. If you have questions, suggestions, etc. feel free to send me an e-mail at firstname.lastname@example.org.