m2r

raw JSON →
0.3.1 verified Fri May 01 auth: no python deprecated

m2r is a Python utility for converting Markdown files to reStructuredText, enabling inclusion of Markdown content in Sphinx documentation. Version 0.3.1 is the latest release; the library is no longer actively maintained.

pip install m2r
error ModuleNotFoundError: No module named 'm2r'
cause m2r is not installed.
fix
Run: pip install m2r
error ImportError: cannot import name 'convert' from 'm2r'
cause Outdated version (<0.2.0) where convert function existed under different name or not at all.
fix
Upgrade m2r: pip install --upgrade m2r
error AttributeError: 'NoneType' object has no attribute 'groups'
cause Incompatibility with newer versions of mistune (mistune>=2.0.0 changed API).
fix
Pin mistune to version <2.0.0: pip install 'mistune<2.0.0'
deprecated m2r is no longer actively maintained. Consider using m2r2, recommonmark, or MyST for continued support.
fix Replace 'm2r' with 'm2r2' or use 'recommonmark' or 'myst-parser' for Sphinx.
gotcha m2r's conversion is not lossless; some Markdown constructs may not translate correctly to RST.
fix Review converted output manually and adjust source Markdown or use an alternative converter.

Convert a Markdown string to reStructuredText.

from m2r import convert

markdown_text = "# Hello\n\nThis is **Markdown**."
rst_text = convert(markdown_text)
print(rst_text)