Functions
_find_delimiter_line
1
tuple[str, str] | None
▼
Find closing --- delimiter on its own line. Returns (frontmatter_str, body) or …
_find_delimiter_line
1
tuple[str, str] | None
▼
def _find_delimiter_line(content: str) -> tuple[str, str] | None
Find closing --- delimiter on its own line. Returns (frontmatter_str, body) or None.
Parameters
| Name | Type | Description |
|---|---|---|
content |
str |
Returns
tuple[str, str] | None
_normalize_metadata
1
dict[str, Any]
▼
Coerce known numeric frontmatter fields to float.
Called immediately after yam…
_normalize_metadata
1
dict[str, Any]
▼
def _normalize_metadata(raw: dict[str, Any]) -> dict[str, Any]
Coerce known numeric frontmatter fields to float.
Called immediately after yaml.safe_load() so every downstream consumer (cascade, snapshots, sorts, templates) sees consistent types.
Parameters
| Name | Type | Description |
|---|---|---|
raw |
dict[str, Any] |
Returns
dict[str, Any]
parse_frontmatter
1
tuple[dict[str, Any], st…
▼
Parse YAML frontmatter from content. Returns (metadata, body).
Returns (metada…
parse_frontmatter
1
tuple[dict[str, Any], st…
▼
def parse_frontmatter(content: str) -> tuple[dict[str, Any], str]
Parse YAML frontmatter from content. Returns (metadata, body).
Returns (metadata, body) — complementary to parse_notebook which returns (markdown_content, metadata). Delimiters must be --- on their own line.
Behavior:
- Delimiters: --- at start, --- at end of block (line-boundary only)
- No leading ---: return ({}, content)
- Unclosed ---: return ({}, content) (treat as no frontmatter)
- Valid YAML: parse with yaml.safe_load, normalize numeric fields, return (metadata, body)
- YAML error: return ({}, body) where body = content with frontmatter block stripped
Parameters
| Name | Type | Description |
|---|---|---|
content |
str |
Raw file content with optional frontmatter |
Returns
tuple[dict[str, Any], str]
extract_body
1
str
▼
Strip --- delimited block from start. No YAML parsing.
Uses line-boundary deli…
extract_body
1
str
▼
def extract_body(content: str) -> str
Strip --- delimited block from start. No YAML parsing.
Uses line-boundary delimiter detection (--- on its own line), so values like title: "a---b" inside frontmatter do not truncate the body.
Use when parse_frontmatter fails (e.g. broken YAML) but you still want the body content.
Parameters
| Name | Type | Description |
|---|---|---|
content |
str |
Full file content |
Returns
str