Fix two list item related bugs#514
Merged
nicholasserra merged 4 commits intotrentm:masterfrom Jun 22, 2023
Merged
Conversation
… only lines. Also converted it and `_uniform_outdent` to `staticmethod`s and added docstrings
Collaborator
|
Nice thank you! |
Crozzers
added a commit
to Crozzers/python-markdown2
that referenced
this pull request
Jul 2, 2023
Merge master to pull in trentm#514 for conversion to new Extra format
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.
Bug 1: List items being incorrectly nested if preceded by
\n\nWhile processing
Item 2,Item 4would erroneously be flattened to the same level asItem 3.In
_list_item_subif the last processed list item (in this caseItem 1) ended with\n\n, the current list item would be passed toself._outdent, flattening the child list items.This bug was fixed by instead passing the current list item to
self._uniform_outdentand outdenting it by 1-4 spaces.Bug 2: HTML blocks with
markdown="1"not being processed correctly when inside list itemsThe
_list_item_subfunction assumes that most list items, if they don't contain\n\n, should be run through the span gamut.This assumption causes the following markdown to be incorrectly converted:
List items are allowed to contain
divblocks, which can contain other block elements such as headers. However, since this example does not contain\n\n, it would be run through the span gamut and the header would not be processed.The fix for this was to add a dedicated
_do_markdown_in_htmlfunction that piggy-backs off of_strict_tag_block_sub.It will find and hash indented HTML blocks, resulting in the following markdown:
Due to the presence of
\n\n, the_list_item_subwill now process these correctly using the block gamut.Alternatives considered:
<li><p>some text</p></li>_strict_tag_block_subto always hash indented HTML blocksOther notable changes
_uniform_indentto give better control on what happens to whitespace-only lines_uniform_(in|out)dentstaticmethods and added docstrings