开源软件名称(OpenSource Name):miyakogi/m2r开源软件地址(OpenSource Url):https://github.com/miyakogi/m2r开源编程语言(OpenSource Language):Python 95.7%开源软件介绍(OpenSource Introduction):M2RM2R converts a markdown file including reStructuredText (rst) markups to a valid rst format. Why another converter?I wanted to write sphinx document in markdown, since it's widely used now and
easy to write code blocks and lists. However, converters using pandoc or
recommonmark do not support many rst markups and sphinx extensions. For
example, rst's reference link like Features
InstallationPython 2.7 or Python 3.4+ is required.
Or,
UsageCommand Line
Then you will find Programmatic UseImport from m2r import convert
rst = convert('# Title\n\nSentence.')
print(rst)
# Title
# =====
#
# Sentence. Or, use from m2r import parse_from_file
output = parse_from_file('markdown_file.md') This is an example of setup.py to write README in markdown, and publish it to PyPI as rst format. readme_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md')
try:
from m2r import parse_from_file
readme = parse_from_file(readme_file)
except ImportError:
# m2r may not be installed in user environment
with open(readme_file) as f:
readme = f.read()
setup(
...,
long_description=readme,
...,
) Sphinx IntegrationIn your conf.py, add the following lines. extensions = [
...,
'm2r',
]
# source_suffix = '.rst'
source_suffix = ['.rst', '.md'] Write index.md and run When mdinclude directiveLike Note: do not use Restrictions
If you find any bug or unexpected behaviour, please report it to Issues. ExampleSee example document and its source code. I'm using m2r for writing user guide of WDOM. So you can see it as another example. Its HTML is here, and its source code is here. Demo editorDemo editor of m2r is available. If you are interested in m2r, please try it. https://github.com/miyakogi/m2rdemo Acknowledgementm2r is written as an extension of mistune, which is highly extensible pure-python markdown parser. Without the mistune, I couldn't write this. Thank you! Licence |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论