Repository navigation
Keep list item open after a removed reference definition - #655
Merged
Merged
Conversation
When a list item's only paragraph holds nothing but a link reference definition, the paragraph is removed on finalize and the item is left without children. parse_node_item_prefix took that to mean the item started with a blank line, so a later blank line with some spaces, but fewer than the item's content indent, ended the item. `- [r]:x`, an empty line, ` `, ` l` put `l` in a paragraph after the list. Mark the item when such a paragraph is removed and keep it open as cmark does for an item with children. Fixes commonmark#618.
Member
|
Thanks. I tried to edit your regression test on the web interface, just to add "Issue #655" to the description. Can you revert my commit, add Issue #655 to the description (but without changing line endings), and force push? |
Revert the web-edit commit that normalized the file to CRLF and re-add the issue tag with LF endings only.
Contributor
Author
|
Got it. Reverted the web edit, added Issue #655 with LF endings only, and force-pushed. Thanks! |
ck0i
force-pushed
the
fix-item-after-refdef-blank-line
branch
from
November 6, 2026 18:17
77f3739 to
9e3b7bd
Compare
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.
When a list item's only paragraph is a link reference definition, finalize removes the paragraph and the item is left with no children. parse_node_item_prefix reads
first_child == NULLas "the item started with a blank line after the marker", so a later blank line with fewer spaces than the item's content indent closes the item. That is why- [r]:x, an empty line,,lrenders<li></li>followed by<p>l</p>. The empty-line and two-space variants from the issue keeplin the item, the first only because the LIST_LAST_LINE_BLANK early return in check_open_blocks skips the item check. commonmark.js keepslin the item in all three cases.The fix sets a new internal flag, CMARK_NODE__ITEM_HAD_CONTENT, on the parent item when finalize drops a reference-definition paragraph, and parse_node_item_prefix keeps the item open on a blank line when that flag is set. Items that really open with a blank line still end at the next blank line (
-, empty line,foois unchanged). I added the case from the issue to test/regression.txt. It fails before the change and passes after, and the ctest suite passes (api_test 563, spec 652, smart punctuation 16, regression 36) along with the pathological tests.Fixes #618