markdown_to_rst
- pyhelpers.store.markdown_to_rst(path_to_md, 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.
- Parameters:
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
; whenpandoc_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 subprocess.run (when
engine=None
) or pypandoc.convert_file (whenengine='pypandoc'
)
Examples:
>>> from pyhelpers.store import markdown_to_rst >>> from pyhelpers.dirs import cd >>> dat_dir = cd("tests\documents") >>> path_to_md_file = cd(dat_dir, "readme.md") >>> 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\markdown.md" to "tests\data\markdown.rst" ... Done.