Repository navigation
Fix list source maps including trailing blank lines - #1212
Open
dyk1454683243-sudo wants to merge 1 commit into
Open
dyk1454683243-sudo wants to merge 1 commit into
dyk1454683243-sudo wants to merge 1 commit into
Conversation
The list rule recorded map end at the first line that cannot belong to the list, which includes blank lines after the last item. Trim trailing empty lines from list and list_item maps only. Leave state.line unchanged so tightness and HTML stay the same. Fixes markdown-it#374 Co-authored-by: David <[email protected]>
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.
Fixes #374
Cause
The list rule sets
bullet_list_open/ordered_list_openandlist_item_openmap[1]to the line where the rule terminates. That is the first line that cannot belong to the list (usually the next non-empty, less-indented block). Blank lines skipped after the last content are therefore included in the end row.- aaa bbbbullet_list_openandlist_item_opencurrently get[0, 3]instead of[0, 1]. Paragraphs and other block tokens already stop at the last content line.Fix
Trim trailing empty lines from list and list_item maps only.
state.lineis left unchanged so tightness, nesting, and HTML output stay the same.Tests
Added
test/markdown-it/list-sourcemap.test.mjsfor the issue case, ordered lists, tight multi-item lists, blanks after the last item, blanks between paragraphs in a loose item, nested lists, and unchanged HTML.