You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Render markdown to HTML with markdown-it-py and a custom configuration
with and without plugins and features:
frommarkdown_itimportMarkdownItfrommdit_py_plugins.front_matterimportfront_matter_pluginfrommdit_py_plugins.footnoteimportfootnote_pluginmd= (
MarkdownIt('commonmark', {'breaks':True,'html':True})
.use(front_matter_plugin)
.use(footnote_plugin)
.enable('table')
)
text= ("""---a: 1---a | b- | -1 | 2A footnote [^1][^1]: some details""")
tokens=md.parse(text)
html_text=md.render(text)
## To export the html to a file, uncomment the lines below:# from pathlib import Path# Path("output.html").write_text(html_text)
Command-line Usage
Render markdown to HTML with markdown-it-py from the
command-line:
usage: markdown-it [-h] [-v] [filenames [filenames ...]]Parse one or more markdown files, convert each to HTML, and print to stdoutpositional arguments: filenames specify an optional list of files to convertoptional arguments: -h, --help show this help message and exit -v, --version show program's version number and exitInteractive: $ markdown-it markdown-it-py [version 0.0.0] (interactive) Type Ctrl-D to complete input, or Ctrl-C to exit. >>> # Example ... > markdown *input* ... <h1>Example</h1> <blockquote> <p>markdown <em>input</em></p> </blockquote>Batch: $ markdown-it README.md README.footer.md > index.html