fix(archive): preserve blank lines inside code fences - #1798
fix(archive): preserve blank lines inside code fences#1798dwin-gharibi wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe spec assembly now collapses blank-line runs only outside fenced code blocks. The change adds fence-aware normalization and tests for backtick fences, tilde fences, indentation-sensitive content, whitespace-only lines, and existing spec content. ChangesSpec normalization
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change preserves blank lines in fenced code blocks while retaining existing normalization outside fences, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #1797.
Why
The final assembly in
buildUpdatedSpecnormalises blank lines across the wholerebuilt document:
That normalisation exists to tidy the seams between the four slices being
rejoined, but it also rewrites the inside of fenced code blocks. A requirement
documenting a sample with two or more consecutive blank lines has that sample
silently edited on archive, and re-edited on every subsequent archive.
It matters for whitespace-significant content — YAML block scalars, Python,
expected-output fixtures, Markdown-in-Markdown examples. Every other structural
pass in this module is already fence-aware via
buildCodeFenceMask; this onewas not.
What Changes
collapseBlankRunsOutsideFences, whichwalks the assembled document with
buildCodeFenceMaskand collapses blankruns only outside fenced blocks.
line counts as blank, exactly as
/\n{3,}/did, so a line of spaces is stillnever a collapse boundary.
Testing
test/core/specs-apply.fence-preservation.test.ts— 8 tests, written first andwatched fail (5 failed / 3 passed before, 8 passed after).
Edge cases covered:
~~~) fence\n{3,}survives)against the full expected string, not a substring)
delta) are preserved
Full suite green on this branch.
Changeset
Not added. Per
.changeset/README.mdthe default path is the normal releasecadence; happy to run
pnpm changesetif a maintainer wants dedicated releasenotes.
Summary by CodeRabbit
Bug Fixes
Tests