Repository navigation
Fix empty list items being parsed as nested lists - #734
Open
LuisFigueroaG wants to merge 2 commits into
Open
LuisFigueroaG wants to merge 2 commits into
LuisFigueroaG wants to merge 2 commits into
Conversation
A list item with nothing after the marker swallowed the next line as its content, so "1. \n2. " produced a nested, unclosed list instead of two empty items. Allow the item text to be empty. Fixes trentm#167
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 #167
A list item with nothing after the marker (just the marker and a trailing space) took the next line as its content. That line then got parsed as a sub-list, so the output was nested and broken:
- \n- \ndid the same thing with<ul>, and an empty item in the middle of a list (- foo\n- \n- bar) turnedbarinto a sub-list of the empty item.The item text in
_list_item_rewas(?:.+?), which needs at least one character, so for an empty item it went past the newline into the next item. I changed it to(?:.*?). For items that have text this matches the same as before. For empty items it now stops at the end of the line, so the output is:That's also what GitHub gives for this input.
Tests:
tm-cases/empty_list_items_issue167covers the example from the issue, bullet lists, an empty item between other items, an empty numbered item and empty items in a sub-list. It fails without the fix.xss_smuggling_spans_in_image_attrshas a-line followed by- , and its expected HTML had the old nested-list output. I updated it to the two-item list. The<img>line itself is unchanged.Test runs:
make testone: 289 tests, OK (288 on master)make testredos: 7 tests, OKpycodestyle lib/markdown2.pygives the same count before and after (415)