Skip to content

YAML fixes#2302

Merged
stephenberry merged 1 commit intomainfrom
yaml
Feb 6, 2026
Merged

YAML fixes#2302
stephenberry merged 1 commit intomainfrom
yaml

Conversation

@stephenberry
Copy link
Owner

@stephenberry stephenberry commented Feb 4, 2026

YAML Quoted String Line Folding & Block Scalar Sibling Key Fixes

Quoted String Line Folding

Implements proper YAML line folding for double-quoted and single-quoted strings per the YAML spec:

  • Single newline between content lines is folded into a space
  • Blank lines (double newlines) are preserved as literal newlines
  • Trailing whitespace before a line break is trimmed
  • Leading whitespace on continuation lines is trimmed
  • Backslash continuation (double-quoted only): \ at end of line joins the next line with no space

The previous SWAR-optimized parsing in both parse_double_quoted_string and parse_single_quoted_string has been replaced with byte-by-byte processing that correctly handles embedded newlines, escape sequences, and line folding. The SWAR approach couldn't handle the multi-character newline/folding logic that the YAML spec requires within quoted strings.

Block Scalar Sibling Keys

Adds tests verifying that block scalars (|, >) followed by sibling keys at the same indentation level are parsed correctly (e.g., k1: |\n a\nk2: c).

Tests

Added comprehensive test coverage including:

  • Simple and complex line folding for both quote styles
  • Blank line preservation
  • Backslash line continuation (double-quoted)
  • Trailing whitespace trimming
  • StackOverflow-style multiline examples with mixed features
  • Block scalar followed by sibling keys in mappings and sequences

@stephenberry stephenberry merged commit 23030af into main Feb 6, 2026
43 checks passed
@stephenberry stephenberry deleted the yaml branch February 6, 2026 00:00
@stephenberry stephenberry mentioned this pull request Feb 6, 2026
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