Repository navigation
Quote strings that start or end with whitespace when writing YAML - #195
Merged
Merged
Conversation
…tch] WithQuotingNecessaryStrings leaves a string that ends in a tab as a plain scalar, and YAML strips trailing whitespace from plain scalars, so "tab\t" came back as "tab" after AddFrontmatter, ReplaceFrontmatter or a CombineFrontmatter rewrite. A chained event emitter now double-quotes any string whose first or last character is whitespace. Fixes #183 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn
The build's ktsu.Sdk sync rewrote it, and it was committed by mistake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn
|
This was referenced Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #183
Before: a value ending in a tab was written as a plain scalar (
k: tab<TAB>), and YAML strips trailing whitespace from plain scalars. So"tab\t"came back as"tab"and"x \t"as"x", through every writer, including aCombineFrontmatterrewrite of an already-quotedk: "tab\t".After: these values round-trip unchanged. Ordinary values are still written plain.
How: the shared serializer in
YamlSerializer.csregisters aChainedEventEmitterthat setsScalarStyle.DoubleQuotedon any string whose first or last character is whitespace.WithQuotingNecessaryStringsstays in place for everything else.Tests: new
EdgeWhitespaceRoundTripTestscovers leading and trailing tabs and spaces throughAddFrontmatter/ExtractFrontmatter, aCombineFrontmatterrewrite of a quoted tab value, a directSerializeYamlObjectround trip, and a check that a plain value stays plain. Four of these fail without the change (trailing tab, trailing space then tab, the Combine rewrite, the serializer round trip) and all pass with it. Full suite: 273 passed. The library builds for netstandard2.0/2.1 and net8/9/10.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ho7QngpAmRRAxjmT2qp1sn
Generated by Claude Code