markdown_to_rst, path_to_rst, engine=None, pandoc_exe=None, verbose=False, **kwargs)

Convert a Markdown file (.md) to a reStructuredText (.rst) file.

This function relies on Pandoc or pypandoc.

  • path_to_md (str) – path where a markdown file is saved

  • path_to_rst (str) – path where a reStructuredText file is saved

  • engine (None or str) – engine/module used for performing the conversion, defaults to None; an alternative option is 'pypandoc'

  • pandoc_exe (str or None) – absolute path to the executable “pandoc.exe”, defaults to None; when pandoc_exe=None, use the default installation path, e.g. (on Windows) “C:\Program Files\Pandoc\pandoc.exe

  • verbose (bool or int) – whether to print relevant information in console, defaults to False

  • kwargs – [optional] parameters of (when engine=None) or pypandoc.convert_file (when engine='pypandoc')


>>> from import markdown_to_rst
>>> from pyhelpers.dirs import cd

>>> dat_dir = cd("tests\documents")

>>> path_to_md_file = cd(dat_dir, "")
>>> path_to_rst_file = cd(dat_dir, "readme.rst")

>>> markdown_to_rst(path_to_md_file, path_to_rst_file, verbose=True)
Converting "tests\data\" to "tests\data\markdown.rst" ... Done.