fix(markdown): keep indented bare-fence lines as content in numeric lists - #248
Open
detail-app[bot] wants to merge 1 commit into
Open
detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
…ists Restore the body-indentation correction in the numeric-list fence nesting open-fence pass so the closing-fence cutoff stays relative to the opening fence's source column (CommonMark §4.5). A bare ```/~~~ line used as code content inside a reparented fence was misclassified as the closing fence when its indentation fell in the widened cutoff window, dropping the rest of the block out of the list item.
This branch has not been deployed
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.
Detail bug report: View on Detail
Bug
nestNumericListFencesre-indents fenced code blocks so CommonMark attaches them to a preceding numeric list item (parseMarkdownruns this on every message before lexing). In commit724c810ethe closing-fence cutoff in the open-fence pass lost itsbodyIndentation.lengthterm, widening it fromopeningSourceIndentation + 3toawaitedContinuationIndentation + 3.As a result, a bare
```/~~~line used as code content inside a reparented fence was misclassified as the closing fence whenever its source indentation landed in that gap. The block closed early, the inner fence line and everything after it were dropped/repurposed, and trailing content leaked out of the list item as a sibling<p>plus a stray empty<pre><code>. The window grows with the numeric marker width (e.g.14.,123.), so even moderately indented nested-fence demos lost content. This contradicts plainmarked@15.0.12on the un-preprocessed source, which keeps those lines as content (closing fences may be at most 3 columns past the opening fence's column).Closes #244
Fix
Restore the body-indentation correction so closing-fence detection stays relative to the (possibly re-indented) opening fence's source column, per CommonMark §4.5:
This is the pre-
724c810eformula and the idiomatic single-line fix:nestNumericListFencesis a structural reparenting transform, so it must preserve the content boundaries the source already establishes rather than reinterpret them. No lookahead/disambiguation is needed — a bare fence more than 3 columns past the opener is unambiguously content in the source frame.Updated the test added in
724c810e(which codified the widened, non-CommonMark cutoff) to expect bare fences at columns 4–7 to be preserved as content, matching plainmarked@15.0.12. Added regression tests for the reported reproducer, for deep numeric markers (14.,123.) — confirming the cutoff tracks the opening fence rather than the marker width — and a positive-direction test confirming valid closers at columns 0–3 still close (guards against over-tightening).Testing
numericListFenceNesting.test.ts,markdown.test.ts) and the full frontend Vitest suite (356 tests) pass.parseMarkdownoutput's code-block content matches plainmarked@15.0.12byte-for-byte for the1.,14., and123.openers (and tilde fences), with the block additionally nested under the list item and no leaked<p>/stray<pre>(ran as a temporary jsdom-backed Vitest cross-check, then removed per the no-probes rule).```\nmoreinside exactly one nestedol > li pre > code, with no stray top-level<pre>or<p>— for both the1.and14.markers. Both passed; the pre-existing accessibility e2e suite still passes (no regression). The temporary spec was removed (browser lane is CI-owned).svelte-check), format check (oxfmt), lint (oxlint + eslint type-aware + ast-grep), and production build all pass clean.Automatic Fixes PRs can be configured here.