Summary
yamlNodeToJson in src/markdown/frontmatter.zig attempts numeric coercion on every YAML scalar, including scalars that were explicitly quoted as strings in the source. This means version: "1.1" (a quoted YAML string) comes back as .float = 1.1 instead of .string = "1.1".
Root cause
zig-yaml's Yaml.Value.scalar variant carries no quoting metadata — both 1.1 and "1.1" arrive as .scalar = "1.1". Without that information, yamlNodeToJson cannot distinguish them.
The current integer-first → float → string fallback order is correct (fixed in the previous commit from float-first), but quoted strings that happen to look like numbers will still be coerced.
Correct behaviour per YAML spec
A YAML double-quoted or single-quoted scalar is always a string, regardless of its content.
Fix options
- Short-term (done): reverse coercion order to int → float → string so bare integers stay integers.
- Long-term: upstream a zig-yaml patch to add a
quoted_scalar: []const u8 variant (or a Style flag on .scalar) so zigmark can skip numeric coercion for quoted values.
- Alternative: switch to a YAML library that exposes scalar style, or write a thin wrapper that preserves quoting before handing off to
Yaml.
Affected versions
Reproduced with zigmark path-dep on Zig 0.15.2; zig-yaml 0.2.0.
Example
version: "1.1" # should be .string = "1.1"
weight: 10 # should be .integer = 10 (was .float before fix)
ratio: 1.5 # .float = 1.5 (correct — unquoted float)
Summary
yamlNodeToJsoninsrc/markdown/frontmatter.zigattempts numeric coercion on every YAML scalar, including scalars that were explicitly quoted as strings in the source. This meansversion: "1.1"(a quoted YAML string) comes back as.float = 1.1instead of.string = "1.1".Root cause
zig-yaml's
Yaml.Value.scalarvariant carries no quoting metadata — both1.1and"1.1"arrive as.scalar = "1.1". Without that information,yamlNodeToJsoncannot distinguish them.The current integer-first → float → string fallback order is correct (fixed in the previous commit from float-first), but quoted strings that happen to look like numbers will still be coerced.
Correct behaviour per YAML spec
Fix options
quoted_scalar: []const u8variant (or aStyleflag on.scalar) so zigmark can skip numeric coercion for quoted values.Yaml.Affected versions
Reproduced with zigmark path-dep on Zig 0.15.2; zig-yaml 0.2.0.
Example