Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed ordered and unordered list hierarchies should indent consistently #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srichy
Copy link

@srichy srichy commented Mar 12, 2025

Summary

Mixed nested ordered and unordered lists causes indentation prefixes to get dropped in some cases.

Details

Input like this (but starting in the first column; using CODE blocks here):

- This is a top-level bulleted list
  - This is second-level bulleted list
  - Second of the second
    1. This is ordered and second-order nested
    1. Second entry of same

should render like:

* This is a top-level bulleted list
  * This is second-level bulleted list
  * Second of the second
    1. This is ordered and second-order nested
    2. Second entry of same

given formatting options unorderedListMarker: .star, orderedListNumerals:.incrementing(start: 1), and emphasisMarker: .underline.

However, before this change, they render like:

* This is a top-level bulleted list
  * This is second-level bulleted list
  * Second of the second
  1. This is ordered and second-order nested
  2. Second entry of same

in which the prefix is not generated for the ordered list. The dump of the tree is correct, however:

    Document
    └─ UnorderedList
       └─ ListItem
          ├─ Paragraph
          │  └─ Text "This is a top-level bulleted list"
          └─ UnorderedList
             ├─ ListItem
             │  └─ Paragraph
             │     └─ Text "This is second-level bulleted list"
             └─ ListItem
                ├─ Paragraph
                │  └─ Text "Second of the second"
                └─ OrderedList
                   ├─ ListItem
                   │  └─ Paragraph
                   │     └─ Text "This is ordered and second-order nested"
                   └─ ListItem
                      └─ Paragraph
                         └─ Text "Second entry of same"

The above AST shows that the OrderedList is a child of the ListItem and not of the UnorderedList, so it should be indented accordingly when rendered.

Dependencies

None

Testing

I sanity tested with the above examples and ran on some other markdown to verify that the output seems sane.

Input like this (but starting in the first column; using CODE blocks here):

    - This is a top-level bulleted list
      - This is second-level bulleted list
      - Second of the second
        1. This is ordered and second-order nested
        1. Second entry of same

should render like:

    * This is a top-level bulleted list
      * This is second-level bulleted list
      * Second of the second
        1. This is ordered and second-order nested
        2. Second entry of same

(given formatting options "unorderedListMarker: .star",
 "orderedListNumerals:.incrementing(start: 1)", and
 "emphasisMarker: .underline").

However, before this change, they rendered like:

    * This is a top-level bulleted list
      * This is second-level bulleted list
      * Second of the second
      1. This is ordered and second-order nested
      2. Second entry of same

in which the prefix is not generated for the ordered list.  The dump
of the tree is correct, however:

    Document
    └─ UnorderedList
       └─ ListItem
          ├─ Paragraph
          │  └─ Text "This is a top-level bulleted list"
          └─ UnorderedList
             ├─ ListItem
             │  └─ Paragraph
             │     └─ Text "This is second-level bulleted list"
             └─ ListItem
                ├─ Paragraph
                │  └─ Text "Second of the second"
                └─ OrderedList
                   ├─ ListItem
                   │  └─ Paragraph
                   │     └─ Text "This is ordered and second-order nested"
                   └─ ListItem
                      └─ Paragraph
                         └─ Text "Second entry of same"

The AST shows that the OrderedList is a child of the ListItem and not
of the UnorderedList.
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.

1 participant