mdformat-frontmatter
An mdformat plugin for parsing / ignoring frontmatter.
What it is and what it does
mdformat-frontmatter extends the mdformat markdown formatter to recognize and preserve YAML front matter blocks—the metadata headers used by static site generators like Jekyll. When mdformat processes a markdown file, this plugin ensures that properly formed YAML blocks at the beginning of the file are left intact rather than being reformatted or stripped. The plugin works by integrating with mdformat's plugin system and depends on ruamel-yaml for YAML parsing and mdit-py-plugins for markdown-it integration.
The plugin is straightforward in scope: it validates that YAML front matter appears only at the file's start (first one or two lines) and allows well-formed blocks to pass through unchanged. The maintainers note that the plugin is not sophisticated about handling malformed YAML—incorrectly structured blocks may produce unexpected behavior—so it works best when front matter is already valid.
Use it for:
- Format markdown files for Jekyll or other static site generators that rely on YAML front matter for configuration and metadata.
- Integrate mdformat into a documentation build pipeline without losing front matter headers during formatting passes.
- Ensure consistent markdown style across a project while preserving metadata used by automation tools.
- Enforce markdown formatting standards in a monorepo where some files use YAML front matter for site generation.
- Combine with pre-commit hooks to automatically format markdown while respecting front matter structure.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
mdformat-frontmatter is an mdformat plugin that preserves YAML front matter blocks at the start of markdown files, preventing them from being reformatted or removed during markdown formatting operations.
Yes, if you use mdformat with markdown files that contain YAML front matter. The plugin is actively maintained, has no security vulnerabilities, and solves a specific but real problem for Jekyll users and documentation projects. Install it only if you need front matter preservation; it adds no value for plain markdown files.
Install
mdformat-frontmatter on PyPI
pip
pip install mdformat-frontmatteruv
uv add mdformat-frontmatterpoetry
poetry add mdformat-frontmatterInstalling mdformat-frontmatter
Before you install
Low friction install with three straightforward runtime dependencies (mdformat, mdit-py-plugins, ruamel-yaml). The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install mdformat-frontmatter
import mdformat
markdown_text = """---
test: yaml
---
# Heading
Content here."""
formatted = mdformat.text(markdown_text)
Requires Python 3.10 or higher.
Verify before relying
- Whether the plugin handles edge cases like malformed YAML front matter gracefully or if it produces unpredictable output as the description suggests.
- Performance characteristics when processing large markdown files with complex front matter.
- Compatibility with other mdformat plugins when used together in a formatting pipeline.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — mdformat, mdit-py-plugins, ruamel-yaml |
| Maintenance | actively maintained — 83 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,188,261/month — #4,245 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mdformat_frontmatter-2.1.2-py3-none-any.whl
Keywords: markdown, markdown-it, mdformat
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
mdformat-front-mattersA plugin for mdformat that normalizes YAML,…
permissive · top 15,000 on PyPI
python-frontmatterParses and manages text files with YAML (or…
permissive · top 5,000 on PyPI
mdformat-footnoteAdds footnote parsing and formatting support to…
permissive · top 15,000 on PyPI
mdformat_mystmdformat-myst is an mdformat plugin that…
permissive · top 15,000 on PyPI
mdformat_tablesmdformat-tables is a plugin for mdformat that…
permissive · top 15,000 on PyPI
mdformat_deflistExtends mdformat with support for parsing and…
permissive · top 15,000 on PyPI
mdformatMdformat is a CommonMark-compliant command-line…
permissive · top 5,000 on PyPI
mdformat-mkdocsAn mdformat plugin that formats Markdown for…
permissive · top 15,000 on PyPI
mdformat-ruffIntegrates ruff code formatting into mdformat…
permissive · top 15,000 on PyPI
mdformat-blackA plugin for mdformat that automatically…
permissive · top 15,000 on PyPI