If you are well-versed in markdown, you don’t need a fully-blown editor with preview to write in markdown. For example, I am writing this article using vim. However, to post the article I need to convert it to html. Many web based markdown editors support that. Today I came across an easy to use python module which does the same.
I’ll be using Python3 to demonstrate this. While the module markdown
intends to be a library, it can be run as a script.
Installation
To install the module on Ubuntu, run:
$ sudo apt-get install python3-markdown
Usage
By default the output is printed on the terminal.
To convert a markdown file to html, run:
$ python3 -m markdown input.md
You can redirect the output to a html file as well:
$ python3 -m markdown input.md > output.html
Get more help:
$ python3 -m markdown help
I regularly use pandoc to convert this kind of files. It’s very handy since sometimes I want html and there are cases I’d rather have pdf.
I’ve made my own scripts for these tasks.
pandoc is awesome too!