Pandoc: Best Way To Convert Markdown to reStructuredText!

3 min read
I wrote a simple readme to one of my Python package Fadapa. I built the package using setuptools. In setup.py file, for long_description field I just read README.md file and  assigned it. After uploading the package to PyPi, I saw the page and found that PyPi doesn't support Markdown format. So I had to change it to reStructuredText.

Pandoc is the best tool available to convert markup formats. It supports a lot of formats and you can convert it to any format you want.

If you have a few documents to convert, you can convert them online. You can also install in in your system if you want to convert a lot files. Instructions on how to install on various operating systems is give here.

For ubuntu you can install by
sudo apt-get install pandoc   
Then you can convert files using
pandoc readme.md --from markdown --to rst -s -o readme.rst
This converts readme.md to readme.rst.

Pypandoc is a simple python wrapper for pandoc. Using that also, you can convert files.

Install it using pip
pip install pypandoc
and then to convert files just do
import pypandoc
output = pypandoc.convert('somefile.md', 'rst')


Update: There is an feature request with pull request to add support for Markdown for PyPi.



I am Chillar Anand. I daydream a lot and write about the things that interest me here. You can read more about this blog here.

See all articles

RSS Feed for the blog

Edit this page

Comments

Comments powered by Disqus