My favorite editor is vim, but it has downsides as well. Vim doesn’t have the GUI needed to extend it to preview things like Markdown properly. Yeah, sure, vim can highlight Markdown syntax, but that is not a replacement for real previewing. With that itch in mind, I searched for a solution but found none that satisfied me. For reStructuredText, I’ve found a solution that worked well. It worked by starting a local web server and doing the previewing in the browser. Inspired by it, I started writing mdview.
mdview allows you to instantly preview any Markdown file you’re editing in your favorite browser. It will automatically refresh when the file is changed, hence it’s great for working with the editor and browser side by side for live preview.
mdview‘s Markdown support is based on python-markdown, which means it supports all kinds of Markdown flavors, including Markdown Extra (which means, among other things, GitHub-style fenced code blocks and footnotes) and syntax highlighting for many languages based on Pygments. The web server itself is based on Flask.
While I had Vim in mind when I wrote it, mdview is actually editor agnostic and should work great with any editor.
Installation
mdview is available from PyPI, so you can install it using pip:
# pip install mdview
Usage
Just invoke mdview and pass it the Markdown file you want to preview. mdview will automatically open a browser window displaying the rendered file. For example:
$ mdview Readme.md
You can enable python-markdown extensions by using the -x flag.
What’s next
This is only an early release. My future plans for mdview include the ability to serve an entire directory (which would allow a sort of “wiki”-like experience) and adding MathJax support to display formulas easily.
Cool stuff,
especially seeing that Firefox Quantum Markdown Viewer has problems
with Linux, this is a real alternativ for me!