Registry / serialization / mdformat-frontmatter

mdformat-frontmatter

JSON →
library2.1.2pypypi✓ verified 22d ago

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.

pip install mdformat mdformat-frontmatter
INSTALL
IMPORT
SIG · MDFORMAT-FRONTMATT
M
mdformat-frontmatter
serializationpythonv2.1.2
Install
2.3s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.000s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mdformat_frontmatter
This is a plugin that mdformat auto-detects upon installation. No direct import statement for `mdformat_frontmatter` is typically needed by the end-user to apply its formatting functionality.
mdformat plugins are usually enabled by simply being installed in the environment where mdformat is run. For programmatic use, mdformat.text or mdformat.file will automatically use installed plugins.

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 -
Debug
Known issues
gotchamdformat-frontmatter explicitly supports only YAML front matter. If you require formatting for TOML or JSON front matter, consider alternative plugins like `mdformat-front-matters` (with an 's').
fix
Ensure your front matter is strictly YAML. For other formats, use a different plugin.
affects: All versions
gotchaIncorrectly formed YAML front matter blocks may lead to unexpected behavior or formatting issues. The plugin's primary objective is to allow properly formed YAML headers to pass through.
fix
Always ensure your front matter adheres to valid YAML syntax and structure.
affects: All versions
breakingThe formatting style produced by `mdformat` (and thus its plugins) can change between versions. This may lead to inconsistent output if `mdformat` itself is not pinned.
fix
Pin the version of `mdformat` in your project dependencies (e.g., `mdformat==1.0.0`) to ensure consistent formatting results across environments and builds.
affects: All versions, particularly across major/minor `mdformat` updates
gotchaPrior to v2.0.7, `ruamel.yaml`'s default line-breaking behavior could introduce unexpected wraps within front matter. This was fixed in v2.0.7 to ensure `ruamel.yaml` does not wrap lines.
fix
Upgrade to `mdformat-frontmatter` version 2.0.7 or newer to benefit from the fix that ensures `ruamel.yaml` does not wrap lines in front matter.
affects: <2.0.7
Upgrade
Version history
2.1.2latest on PyPI · released May 23, 2026
Audit
Dependencies
mdformatrequiredThis is a plugin for mdformat, which is its host formatter.
ruamel.yamlrequiredUsed internally for parsing and formatting YAML front matter.
Agent activity
18 hits · last 30 days
node
16
Amazon
1
Resources
mdformat-frontmatter — pip install mdformat-frontmatter · libregistry