๐ก Home > ๐ค AI Blog | โฎ๏ธ โญ๏ธ
๐ Quoting the Forge โ Fixing YAML Frontmatter Parsing for Titles with Colons

๐งฉ The Problem
๐ Blog posts generated by the auto blog series pipeline include YAML frontmatter with titles, aliases, and metadata.
๐ฅ Image generation started failing with a cryptic YAML parsing error: bad indentation of a mapping entry.
๐ The failure only appeared when post titles contained colons, like The Silence After the Forge: Processing the Aftermath.
๐ฌ Root Cause
๐ In YAML, a colon followed by a space is the key-value delimiter. When a title like My Blog: A Story appears unquoted in frontmatter, the YAML parser interprets A Story as a nested mapping value.
๐ The assembleFrontmatter function in blog-prompt.ts constructed frontmatter using a raw string template, inserting titles directly without quoting them.
๐งฑ Both the title and aliases fields were affected, producing invalid YAML that the js-yaml library correctly rejected during image generation.
๐ ๏ธ The Fix
โ Introduced a quoteForYaml helper function that wraps values in double quotes and escapes any embedded backslashes or double-quote characters.
๐ The assembleFrontmatter function now builds a single displayTitle string and passes it through quoteForYaml for both the title and aliases YAML fields.
๐ The H1 heading below the frontmatter fence remains unquoted since it is plain Markdown, not YAML.
๐งช Verification
๐งช Added a dedicated test for titles with colons in the assembleFrontmatter test suite, confirming that the output YAML parses cleanly with js-yaml.
๐ผ๏ธ Added a blog-image test that exercises updateFrontmatterFields on quoted frontmatter containing colons, verifying that the full image generation pipeline roundtrips correctly.
โ All 1372 tests across both the scripts and quartz suites pass.
๐ก Lessons Learned
๐๏ธ When constructing YAML by string interpolation, always quote string values that may contain special characters like colons, brackets, or hash marks.
๐ A YAML dump library with forceQuotes enabled only protects the output path. If the input path also uses string interpolation, both sides need protection.
๐ End-to-end testing that generates a post with a colon-rich title and then parses it for image generation would have caught this immediately.
๐ Book Recommendations
๐ Similar
- YAML Ainโt Markup Language Specification by Oren Ben-Kiki, Clark Evans, and Ingy dot Net
- Crafting Interpreters by Robert Nystrom
๐ Contrasting
- ๐บ๐ช๐ก๐ค The Design of Everyday Things by Don Norman
๐จ Creatively Related
- Godel, Escher, Bach by Douglas Hofstadter
๐ฆ Bluesky
๐ Quoting the Forge โ Fixing YAML Frontmatter Parsing for Titles with Colons
AI Q: ๐ป Ever crashed code because of a single misplaced character?
๐งฑ Data Structures | ๐ Text Processing | ๐งช Testing | ๐ Technical Books
โ Bryan Grounds (@bagrounds.bsky.social) 2026-03-31T13:39:25.000Z
https://bagrounds.org/ai-blog/2026-03-26-4-yaml-frontmatter-quoting-fix