Skip to content

fix(exporters): quote YAML frontmatter titles starting with reserved indicators#87

Merged
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-markdown-yaml-escape
Apr 19, 2026
Merged

fix(exporters): quote YAML frontmatter titles starting with reserved indicators#87
hqhq1025 merged 1 commit intomainfrom
wt/loop-fix-markdown-yaml-escape

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

  • escapeYaml in packages/exporters/src/markdown.ts only quoted values containing :, #, \", ', or \n. Titles beginning with YAML 1.2 reserved indicator chars (-, ?, [, {, >, |, !, &, *, %, @, \`` etc.) produced unquoted scalars that strict YAML parsers re-interpret as sequences / flow nodes — corrupting the markdown export's frontmatter whenever the artifact <title>or

    ` happened to start with one.

  • Now: quote when the value contains the existing trigger set, starts with a YAML reserved indicator, or has leading/trailing whitespace (also unsafe in plain scalars).

Compatibility / upgradeability / no bloat / elegance

  • Compatibility: green — existing safe titles still emit unquoted; quoted values use JSON.stringify (already in this file).
  • Upgradeability: green — no schema change; same schemaVersion: 1 frontmatter.
  • No bloat: green — pure regex tweak, no deps.
  • Elegance: green — two named constants document intent.

Test plan

  • pnpm --filter @open-codesign/exporters test (30 passing, including 2 new cases for indicator-prefixed and whitespace-padded titles).
  • pnpm --filter @open-codesign/exporters typecheck.
  • pnpm lint.

…indicators

`escapeYaml` only triggered on `:`, `#`, `"`, `'`, or newline, so titles
beginning with YAML 1.2 reserved indicator chars (`-`, `?`, `[`, `{`, `>`,
`|`, `!`, etc.) emitted unquoted scalars that strict parsers treat as
sequences/flow nodes — corrupting the frontmatter for any artifact whose
`<title>` or `<h1>` starts with such a character.

Also quote values with leading/trailing whitespace, which similarly fail to
round-trip through plain scalars.

Signed-off-by: hqhq1025 <[email protected]>
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No high-confidence issues found in added/modified lines.

Summary

  • Review mode: initial. No blocking/major/minor findings in the current diff. Residual risk: not all YAML edge cases are exhaustively covered by tests; docs/VISION.md and docs/PRINCIPLES.md are Not found in repo/docs in this checkout.

Testing

  • Not run (automation)

open-codesign Bot

@hqhq1025 hqhq1025 merged commit 4588343 into main Apr 19, 2026
6 checks passed
@hqhq1025 hqhq1025 deleted the wt/loop-fix-markdown-yaml-escape branch April 19, 2026 06:14
@hqhq1025 hqhq1025 mentioned this pull request Apr 19, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant