fix(emitter): emit plain multi-line scalars as literal blocks#4
Merged
ralflang merged 1 commit intoJul 1, 2026
Merged
Conversation
🔍 CI ResultsOverall: ❌ 8/8 lanes failed TL;DR: ❌ Quality issues: PHPUnit: 8 tests failed. Summary by PHP Version
Quality Metrics
❌ Failed Lanesphp8.2-dev
php8.2-stable
php8.3-dev
php8.3-stable
php8.4-dev
php8.4-stable
php8.5-dev
php8.5-stable
CI powered by horde-components • View full results |
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.
Summary
A Plain-styled
ScalarNodewhose string value contains\nused to fall through the Plain → SingleQuoted → DoubleQuoted upgrade ladder inEmitter::emitStringand end up as"line1\nline2"— the newlines silently escaped as the two-character sequence\n. That is a round-trip data change for any caller that hands the AST a real multi-line string.The concrete symptom:
horde-components releasewritesdoc/changelog.ymlentries via horde/HordeYmlFile, which builds a plainScalarNodefrom the multi-linenotesstring. Recent releases (e.g.horde/imp7.0.1) shownotes: "...\\n..."in the file on GitHub instead of a readable multi-line block.Fix
Add two helpers on
Emitter:shouldUpgradePlainToLiteralBlock(ScalarNode)— returns true only for a Plain-styled node with a string value containing\n, no pinnedrawSource, no tag, and content that a literal block can carry safely.emitPlainAsLiteralBlock(ScalarNode, int, bool)— synthesises a|/|-/|+block. Chomp is picked from the value's trailing newline count.Wired into
emitScalar(root-scalar path) and theScalarNodebranch ofemitMapEntry. PinnedSingleQuoted/DoubleQuotedbehavior is unchanged.Gating is conservative — content with
\r, other sub-0x20 bytes, lines starting with whitespace, or whitespace-only interior lines still goes to double-quoted, because those would need an explicit indent indicator this change does not synthesize.Sequence-item scalars (
emitSequenceItem) are out of scope. That path has noisBlockStyleScalarbranch at all today and belongs to a separate PR.Verification
EmitterPlainMultilineLiteralBlockTest— 12 tests covering the changelog case, chomp-indicator selection, pinned-style / tagged / leading-whitespace / carriage-return / single-line fallbacks, plus aYaml::load()round-trip.AddChangelogEntryTaskpayload emits a propernotes: |block and reparses byte-for-byte.