Have the same README both in Markdown and reStructuredText Have the same README both in Markdown and reStructuredText python python

Have the same README both in Markdown and reStructuredText


I would recommend Pandoc, the "swiss-army knife for converting files from one markup format into another" (check out the diagram of supported conversions at the bottom of the page, it is quite impressive). Pandoc allows markdown to reStructuredText translation directly. There is also an online editor here which lets you try it out, so you could simply use the online editor to convert your README files.


As @Chris suggested, you can use Pandoc to convert Markdown to RST. This can be simply automated using pypandoc module and some magic in setup.py:

from setuptools import setuptry:    from pypandoc import convert    read_md = lambda f: convert(f, 'rst')except ImportError:    print("warning: pypandoc module not found, could not convert Markdown to RST")    read_md = lambda f: open(f, 'r').read()setup(    # name, version, ...    long_description=read_md('README.md'),    install_requires=[])

This will automatically convert README.md to RST for the long description using on PyPi. When pypandoc is not available, then it just reads README.md without the conversion – to not force others to install pypandoc when they wanna just build the module, not upload to PyPi.

So you can write in Markdown as usual and don’t care about RST mess anymore. ;)


2019 Update

The PyPI Warehouse now supports rendering Markdown as well! You just need to update your package configuration and add the long_description_content_type='text/markdown' to it. e.g.:

setup(    name='an_example_package',    # other arguments omitted    long_description=long_description,    long_description_content_type='text/markdown')

Therefore, there is no need to keep the README in two formats any longer.

You can find more information about it in the documentation.

Old answer:

The Markup library used by GitHub supports reStructuredText. This means you can write a README.rst file.

They even support syntax specific color highlighting using the code and code-block directives (Example)