Skip to content

Fix multilevel lists#463

Merged
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:fix-multilevel-lists
Aug 16, 2022
Merged

Fix multilevel lists#463
nicholasserra merged 3 commits intotrentm:masterfrom
Crozzers:fix-multilevel-lists

Conversation

@Crozzers
Copy link
Copy Markdown
Contributor

@Crozzers Crozzers commented Aug 9, 2022

This PR fixes #275. The issue was that lists with multiple levels of nesting were being flattened. For example:

* Item 2
  - Subitem B following:
    + What
    + The
    + Code

Would become:
image
Which is obviously wrong. The bug came from the following line in the _list_item_sub function:

item = self._do_lists(self._outdent(item))

Once the above example reaches this line it is then outdented to:

Item 2
- Subitem B following:
+ What
+ The
+ Code

Which now just resembles a normal list and will be processed as such.
This PR changes the _list_item_sub function to use the _uniform_outdent function, which produces the following output at the same point in the program, allowing nesting to be preserved.

Item 2
- Subitem B following:
  + What
  + The
  + Code

Whilst working on this bug I also discovered that the break_on_newline_excessive_br_tags test case, added in PR #422, contained incorrect list nesting.
image
This PR also fixes that test case.

<ul>
<li>Em Nuvem (cloud based)</li>
<li>Em Nuvem (cloud based)
<ul>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing a quick look at this and it seems wrong because the LIs arent closing. But i'm guessing this is intentional? UL should be nested under the LI before it's closed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Mozilla docs on nesting lists give an example where the nested <ul> is placed as a child of the <li> before closing and I also found this stackoverflow answer that confirms this

@nicholasserra nicholasserra merged commit cf4f8b6 into trentm:master Aug 16, 2022
@nicholasserra
Copy link
Copy Markdown
Collaborator

Thank you!

@Crozzers Crozzers deleted the fix-multilevel-lists branch August 22, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect result for multi-level lists

2 participants