test: list-item position fails to envelop fenced-code child#205
Open
ChristianMurphy wants to merge 1 commit intowooorm:mainfrom
Open
test: list-item position fails to envelop fenced-code child#205ChristianMurphy wants to merge 1 commit intowooorm:mainfrom
ChristianMurphy wants to merge 1 commit intowooorm:mainfrom
Conversation
`to_mdast("- ```\n\nx\n", &ParseOptions::default())` returns Ok in 1.0.0
release but produces an mdast tree where the bullet list-item ends at
offset 6 while its fenced-code child ends at offset 7 — breaking the
unist invariant that a parent's position envelops its child's. An
analogous case fires for the ordered-list shape `1. ```\n\nx\n`.
This is data-integrity, not a panic: `to_mdast` returns `Ok`, but
downstream consumers indexing into source via `child.position.end.offset`
will read past `parent.position.end.offset`. Affects language servers,
source-mapped renderers, and any tool relying on positional invariants.
Adds a small `assert_position_envelop` helper that walks the mdast tree
and reports parent/child position-mismatch violations. Reusable for
future position-invariant regression tests.
Cause likely lives in `src/construct/list_item.rs`: the list-item event
pair closes on the blank-line offset before the fenced-code construct
finishes capturing content, so `on_exit_list_item` finalizes the
position before the code child gets its broader span. Cheapest fix:
post-process parent positions in `on_exit_list_item` to envelop child
spans.
Verified to fail against `markdown = "=1.0.0"` in release. Found via
in-tree fuzzing campaign.
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.
to_mdast("- ```\n\nx\n", &ParseOptions::default())returns Ok in 1.0.0 release but produces an mdast tree where the bullet list-item ends at offset 6 while its fenced-code child ends at offset 7, breaking the unist invariant that a parent's position envelops its child's. An analogous case fires for the ordered-list shape1. ```\n\nx\n.This is data-integrity, not a panic:
to_mdastreturnsOk, but downstream consumers indexing into source viachild.position.end.offsetwill read pastparent.position.end.offset. Affects language servers, source-mapped renderers, and any tool relying on positional invariants.Adds a small
assert_position_envelophelper that walks the mdast tree and reports parent/child position-mismatch violations. Reusable for future position-invariant regression tests.Cause likely lives in
src/construct/list_item.rs: the list-item event pair closes on the blank-line offset before the fenced-code construct finishes capturing content, soon_exit_list_itemfinalizes the position before the code child gets its broader span. Cheapest fix: post-process parent positions inon_exit_list_itemto envelop child spans.Verified to fail against
markdown = "=1.0.0"in release. Found via in-tree fuzzing campaign.