fedoup-frontmatter
Tiny YAML-frontmatter parser/serializer/patcher for markdown documents. Sibling of the TypeScript package @fedoup/frontmatter — same API shape, same byte-stable round trip on canonical input, so a vault of .md files written by one side round-trips through the other.
pip install fedoup-frontmatter
from fedoup_frontmatter import parse, serialize, patch
raw = """---
title: Hello
status: draft
---
# Body content
"""
result = parse(raw)
result.frontmatter # {'title': 'Hello', 'status': 'draft'}
result.body # '# Body content\n'
# Round-trip is byte-stable for canonical input
serialize(frontmatter=result.frontmatter, body=result.body) == raw
# Patch a single field, leave the rest alone
patch(raw, {"status": "published"})
API
@dataclass
class ParseResult:
frontmatter: dict[str, Any]
body: str
def parse(raw: str) -> ParseResult: ...
def serialize(*, frontmatter: Mapping[str, Any], body: str) -> str: ...
def patch(raw: str, partial: Mapping[str, Any]) -> str: ...
parse— returnsParseResult(frontmatter={}, body=raw)if the document doesn't open with a---line. A UTF-8 BOM is tolerated; CRLF endings are accepted but the body is not normalized.serialize— empty frontmatter returns the body verbatim (no---\n---\nno-op block). Key order is preserved from the input dict.patch— mergespartialinto the existing frontmatter. Body and unaffected fields are preserved. To delete a key, parse → mutate the dict →serializedirectly.
Power source
Uses PyYAML under the hood — full YAML support (scalars, sequences, mappings, anchors). The minimal regex parsers you see in many vault tools have edge cases this avoids; the cost is the PyYAML dependency.
Sibling: TypeScript
A matching JS/TS package at @fedoup/frontmatter exists. Same function names, same semantics. Test fixtures are mirrored between the two repos so behavior stays aligned.
License
MIT
Metadata
Release files for fedoup-frontmatter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fedoup_frontmatter-0.1.0.tar.gz | 19.7 kB | Without provenance | Details for fedoup_frontmatter-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fedoup_frontmatter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fedoup_frontmatter-0.1.0-py3-none-any.whl |
Total release size: 24.9 kB
Release files / fedoup_frontmatter-0.1.0.tar.gz
| Download URL | fedoup_frontmatter-0.1.0.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c327487ee6805bbc60ca6efc4ae2c8579b6c65bb777b6d4e086fe50a93131849
|
|
BLAKE2b-256 checksum How to use checksums |
abe8689ce1208d44601a338120906748fee892391cbd1ddc29b8f2dc43555244
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fedoup_frontmatter-0.1.0-py3-none-any.whl
| Download URL | fedoup_frontmatter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a397fddf14781eceef34a8a3a5e8903d5fc1f74f843e0bbcf595c5c5ac979bfa
|
|
BLAKE2b-256 checksum How to use checksums |
b10a4715ca12b0de71f61aab549cca8f232b326df7340c323d84bf544bdf0104
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for fedoup-frontmatter 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.