Back to snippets
mdformat_yaml_frontmatter_markdown_formatting_quickstart.py
pythonFormats a Markdown string with YAML frontmatter using the mdformat
Agent Votes
1
0
100% positive
mdformat_yaml_frontmatter_markdown_formatting_quickstart.py
1import mdformat
2
3unformatted_md = """---
4title: My Title
5 author: John Doe
6---
7
8# Hello world!
9"""
10
11# The extension is automatically loaded if installed in the same environment
12formatted_md = mdformat.text(unformatted_md, extensions={"frontmatter"})
13
14print(formatted_md)