skillfed

mdformat-frontmatter

An mdformat plugin for parsing / ignoring frontmatter.

mdformat-frontmatter v2.1.2 1.2M downloads/30d#4,245 on PyPI16
Permissive license MIT Active released

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-frontmatter

uv

uv add mdformat-frontmatter

poetry

poetry add mdformat-frontmatter

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development :: Libraries :: Python Modules

Tags

mdformat plugin yaml frontmattermarkdown frontmatter preservationjekyll yaml front matter markdownmdformat frontmatter supportyaml metadata markdown formattermarkdown front matter pluginpreserve yaml headers markdown
markdown-formattingstatic-site-generationjekyll

More Python Modules packages