Skip to content

chore(translate): use a proper YAML parser for frontmatter key extraction #177

@luandro

Description

@luandro

Background

parseFrontmatterKeys in scripts/notion-translate/translateFrontMatter.ts uses a regex to extract YAML keys from frontmatter blocks. The function comment acknowledges the limitation:

"Only recognises simple `key:` entries (no nested parsing) — enough to detect dropped or added keys without pulling in a YAML parser dependency."

This means it will silently misparse quoted keys, flow sequences, or multi-line scalars.

What to do

Evaluate adding a lightweight YAML parser (e.g. yaml, already a transitive dependency in many Node projects) to replace the regex approach in parseFrontmatterKeys and replaceFrontmatterValue.

Alternatively, if the current regex coverage is deemed sufficient for the narrow set of frontmatter shapes Notion generates, add explicit documentation and a test asserting the known limitations so future contributors don't assume full YAML support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions