fix(list): parse empty list items without trailing space#140
Merged
YousefHadder merged 1 commit intomainfrom Nov 27, 2025
Merged
fix(list): parse empty list items without trailing space#140YousefHadder merged 1 commit intomainfrom
YousefHadder merged 1 commit intomainfrom
Conversation
b175b66 to
ae93357
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #17 where list renumbering breaks when empty list items lose their trailing space due to formatters or editor settings like trim_trailing_whitespace.
Key changes:
- Added 7 new empty item patterns that match list markers at end-of-line without requiring trailing space
- Patterns use
$anchor to avoid false positives (e.g., "3.14159" is not matched) - Empty patterns are checked last to prefer matching with content when available
- Added 6 new test cases covering empty item parsing and false positive prevention
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lua/markdown-plus/list/parser.lua | Adds 7 new patterns for empty list items (unordered, ordered, letter variants, parenthesized) that match markers at EOL without trailing space, plus corresponding pattern config entries |
| spec/markdown-plus/list_spec.lua | Adds unit tests for parsing empty items without trailing space (ordered, unordered, letter, paren) and false positive prevention for decimals; adds integration test verifying empty items stay in same numbering group |
ae93357 to
46220a3
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.
Fixes #17
Summary
Fix list renumbering breaking when empty list items lose their trailing space (e.g., due to
trim_trailing_whitespaceor external formatters).Problem
When a user creates an empty list item (e.g., pressing
oon a list line), the plugin creates3.(with trailing space). If an external formatter or editor setting removes trailing whitespace, the line becomes3.which was not recognized as a valid list item, breaking list continuity and causing incorrect renumbering.Before fix:
Solution
Added empty item patterns that match list markers at end of line without requiring trailing space:
^(%s*)(%d+)%.$for ordered lists (e.g.,3.)^(%s*)([a-z])%.$for letter lists (e.g.,a.)These patterns are checked after normal patterns, so we prefer matching with content when available. This avoids false positives like
3.14159being parsed as a list item.After fix:
Testing