From 9dbb726af7b52a01578ab0fc0b9717396980edb3 Mon Sep 17 00:00:00 2001 From: TsunamiNoAi Date: Thu, 16 Jul 2026 14:26:20 -0400 Subject: [PATCH] fix: bump zig-yaml to 0.3.1 - trailing comments on plain scalars A trailing '# comment' after a plain scalar in a block sequence (e.g. a front-matter revision entry '- date: 2025-01-01 # when') failed the whole document with ParseFailure. Fixed in sc2in/zig-yaml 0.3.1 ('comment terminates a plain scalar', commit 7c60d9c); this bumps the pin and adds front-matter regression tests for the sequence case and the top-level trailing-comment case. 361/361 tests pass (CommonMark 652/652 + GFM 24/24 unchanged). --- CHANGELOG.md | 9 +++++++++ build.zig.zon | 4 ++-- build.zig.zon2json-lock | 6 +++--- src/markdown/frontmatter_test.zig | 28 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0da3cb6..d888df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ same stability guarantee. ## [0.9.0] — 2026-07-16 +### Fixed + +- **A trailing `# comment` after a plain scalar no longer breaks front-matter + parsing.** YAML like `- date: 2025-01-01 # when` inside a block sequence + (e.g. a policy revision entry) previously failed the whole document with + `ParseFailure`. Fixed upstream in the sc2in/zig-yaml fork (0.3.1, "comment + terminates a plain scalar"); this release bumps the pin and adds + front-matter regression tests. + ### Added - **Opt-in TeX math** (`Parser{ .math = true }`; off by default). `$…$` parses diff --git a/build.zig.zon b/build.zig.zon index f37b414..2a97f6b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -67,8 +67,8 @@ .lazy = true, }, .yaml = .{ - .url = "git+https://github.com/sc2in/zig-yaml#691a2c37f1546fe843f7080fd7bf4450f1facb2e", - .hash = "zig_yaml-0.3.0-C1161oSpAgCiEJXrktVkXNSWNQifQ8NWvNB-20PqoFc3", + .url = "git+https://github.com/sc2in/zig-yaml#7c60d9cd6ae596c8247ac74b5b8e32c329e7c1d0", + .hash = "zig_yaml-0.3.1-C1161s2zAgBOYGjCQB3uWdAadPevfdNiTaffefbhAhBq", }, }, // Specifies the set of files and directories that are included in this package. diff --git a/build.zig.zon2json-lock b/build.zig.zon2json-lock index 1987ea8..3009296 100644 --- a/build.zig.zon2json-lock +++ b/build.zig.zon2json-lock @@ -39,9 +39,9 @@ "url": "git+https://github.com/mnemnion/mvzr?ref=v0.3.10#dd0e1bd2d6b10f9650317b30baef7ab7bc9dd9ec", "hash": "sha256-hUGdJPjC1PAm6zWL9eAE7A+wAfzf6Q7uSutT2Xe7EMU=" }, - "zig_yaml-0.3.0-C1161oSpAgCiEJXrktVkXNSWNQifQ8NWvNB-20PqoFc3": { + "zig_yaml-0.3.1-C1161s2zAgBOYGjCQB3uWdAadPevfdNiTaffefbhAhBq": { "name": "yaml", - "url": "git+https://github.com/sc2in/zig-yaml#691a2c37f1546fe843f7080fd7bf4450f1facb2e", - "hash": "sha256-8BNs41Ch8CmvRME13b6xXTD6VN2/2LewIsW7kp30tCY=" + "url": "git+https://github.com/sc2in/zig-yaml#7c60d9cd6ae596c8247ac74b5b8e32c329e7c1d0", + "hash": "sha256-JAYq7B7gXd4+c60KXZ9b5IuaKLY7x7Bn9TNynyx4kog=" } } \ No newline at end of file diff --git a/src/markdown/frontmatter_test.zig b/src/markdown/frontmatter_test.zig index 087e1b9..8877c9d 100644 --- a/src/markdown/frontmatter_test.zig +++ b/src/markdown/frontmatter_test.zig @@ -978,3 +978,31 @@ test "frontmatter: parseFieldArg errors" { try tst.expectError(error.InvalidFieldArg, FrontMatter.parseFieldArg("no-equals-sign")); try tst.expectError(error.InvalidFieldArg, FrontMatter.parseFieldArg("=value-no-path")); } + +test "frontmatter: trailing comment on a block-sequence mapping line" { + // Regression: a trailing `# comment` after a plain scalar inside a block + // sequence (e.g. a policy revision entry) made the whole front matter + // fail with ParseFailure before zig-yaml 0.3.1. + const md = + "---\n" ++ + "extra:\n" ++ + " major_revisions:\n" ++ + " - date: 2025-01-01 # when it happened\n" ++ + " version: \"1.0\"\n" ++ + "---\n" ++ + "Body.\n"; + var fm = try FrontMatter.initFromMarkdown(tst.allocator, md); + defer fm.deinit(); + const revs = fm.get("extra.major_revisions") orelse return error.Missing; + try tst.expectEqual(@as(usize, 1), revs.array.items.len); + const date = revs.array.items[0].object.get("date") orelse return error.Missing; + try tst.expectEqualStrings("2025-01-01", date.string); +} + +test "frontmatter: trailing comment keeps top-level scalar intact" { + const md = "---\ntitle: My Policy # a note\n---\nBody.\n"; + var fm = try FrontMatter.initFromMarkdown(tst.allocator, md); + defer fm.deinit(); + const t = fm.get("title") orelse return error.Missing; + try tst.expectEqualStrings("My Policy", t.string); +}