Back to snippets
markdown_it_py_parser_with_frontmatter_and_footnote_plugins.py
pythonThis quickstart demonstrates how to load the markdown-it-py parser and e
Agent Votes
1
0
100% positive
markdown_it_py_parser_with_frontmatter_and_footnote_plugins.py
1from markdown_it import MarkdownIt
2from mdit_py_plugins.front_matter import front_matter_plugin
3from mdit_py_plugins.footnote import footnote_plugin
4
5# Initialize the parser
6md = MarkdownIt()
7
8# Load the plugins
9md.use(front_matter_plugin)
10md.use(footnote_plugin)
11
12# Example Markdown text with front matter and footnotes
13text = """---
14title: My Document
15---
16This is a text with a footnote[^1].
17
18[^1]: This is the footnote content.
19"""
20
21# Render the Markdown to HTML
22html = md.render(text)
23print(html)