mdformat-frontmatter

2.0.10 · active · verified Mon Apr 13

An `mdformat` plugin for ensuring that YAML front-matter is respected and formatted within Markdown files. It supports YAML front matter typically used by tools like Jekyll. The current version is 2.0.10, and it maintains an active release cadence with regular updates and fixes.

Warnings

Install

Imports

Quickstart

Install `mdformat` and `mdformat-frontmatter`, then use `mdformat` via its CLI or Python API. The plugin will automatically format YAML front matter.

import mdformat
import os

# Example Markdown with YAML front matter
markdown_content = '''---
title: My Document
date: 2026-04-13
---

# Hello, world!

This is some content below the front matter.
'''.strip()

# Format the content (mdformat auto-detects installed plugins)
formatted_content = mdformat.text(markdown_content)

print("Original content:\n" + markdown_content)
print("\nFormatted content:\n" + formatted_content)

# CLI usage (assuming mdformat and mdformat-frontmatter are installed):
# echo -e "---\ntitle: My Document\n---\n\n# Hello" | mdformat -

view raw JSON →