[GH-ISSUE #20] Unordered sublist in ordered list #15

Closed
opened 2026-03-03 01:23:01 +03:00 by kerem · 4 comments
Owner

Originally created by @anglepoised on GitHub (May 25, 2016).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/20

I'm having trouble getting an unordered sublist in an ordered list to pass linting with the default config. I've tested in playground and with markdownlint-cli.

With 2 space indent I get MD006 and also see 3 distinct lists - ordered, unordered, ordered - in the playground preview:

# sublist test

1. foo
  - bar
  - baz
1. foo

With 4 (or 3, or 5 just for kicks) space indent I get MD007:

# sublist test

1. foo
    - bar
    - baz
1. foo

An unordered sublist with 2 space indent in an unordered parent works fine:

# sublist test

- foo
  - bar
  - baz
- foo

As does inverting the structure of what I'm trying to achieve: an ordered sublist with 2 space indent in an unordered parent:

# sublist test

- foo
  1. bar
  1. baz
- foo

I may be missing a spacing requirement in the CommonMark spec, but feels like either one of the first two examples should pass if the fourth does?

Originally created by @anglepoised on GitHub (May 25, 2016). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/20 I'm having trouble getting an unordered sublist in an ordered list to pass linting with the default config. I've tested in playground and with `markdownlint-cli`. With 2 space indent I get [MD006](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md006---consider-starting-bulleted-lists-at-the-beginning-of-the-line) and also see 3 distinct lists - ordered, unordered, ordered - in the playground preview: ``` md # sublist test 1. foo - bar - baz 1. foo ``` With 4 (or 3, or 5 just for kicks) space indent I get [MD007](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md007---unordered-list-indentation): ``` md # sublist test 1. foo - bar - baz 1. foo ``` An unordered sublist with 2 space indent in an unordered parent works fine: ``` md # sublist test - foo - bar - baz - foo ``` As does inverting the structure of what I'm trying to achieve: an ordered sublist with 2 space indent in an unordered parent: ``` md # sublist test - foo 1. bar 1. baz - foo ``` I may be missing a spacing requirement in the CommonMark spec, but feels like either one of the first two examples should pass if the fourth does?
kerem 2026-03-03 01:23:01 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@DavidAnson commented on GitHub (May 25, 2016):

Thanks for reporting, this is really interesting!

Regarding the first example, please note that markdown-it (the parser used by markdownlint) does not recognize this structure as a nested list: https://markdown-it.github.io/

The reason is explained in the first few paragraphs of the spec: http://spec.commonmark.org/0.25/#list-items

Briefly, the indent of bar/baz must be 3 spaces in order to line up under the start of the content of the first item, foo, because "1. " is 3 characters long . Once that is done, markdown-it recognizes the structure correctly.

Going back to markdownlint, the problem is that MD007 is reported for both of your first examples. That's most likely because of this misunderstanding about indent length of unordered vs. ordered lists.

I'll look into this more soon, thanks!

<!-- gh-comment-id:221664239 --> @DavidAnson commented on GitHub (May 25, 2016): Thanks for reporting, this is really interesting! Regarding the first example, please note that `markdown-it` (the parser used by `markdownlint`) does not recognize this structure as a nested list: https://markdown-it.github.io/ The reason is explained in the first few paragraphs of the spec: http://spec.commonmark.org/0.25/#list-items Briefly, the indent of bar/baz must be _3_ spaces in order to line up under the start of the content of the first item, foo, because "1. " is 3 characters long . Once that is done, `markdown-it` recognizes the structure correctly. Going back to `markdownlint`, the problem is that MD007 is reported for both of your first examples. That's most likely because of this misunderstanding about indent length of unordered vs. ordered lists. I'll look into this more soon, thanks!
Author
Owner

@DavidAnson commented on GitHub (Jun 26, 2016):

I've fixed the incorrect MD007 instances and documented the remaining MD006 behavior. Please see the updated documentation and new tests for details. Thanks!

<!-- gh-comment-id:228616506 --> @DavidAnson commented on GitHub (Jun 26, 2016): I've fixed the incorrect MD007 instances and documented the remaining MD006 behavior. Please see the updated documentation and new tests for details. Thanks!
Author
Owner

@koppor commented on GitHub (Apr 29, 2020):

Does not seem to work currently:

1. After repository initialization:

  - `git commit` to save your work
  - `git checkout -b template` - to create a branch with initial template (required for updating)
  - `git checkout master` switch back to your thesis

grafik

When identing with four spaces, it works:

1. After repository initialization:

    - `git commit` to save your work
    - `git checkout -b template` - to create a branch with initial template (required for updating)
    - `git checkout master` switch back to your thesis

grafik

Environment

VS Code, markdownlint 0.35.1

<!-- gh-comment-id:621139647 --> @koppor commented on GitHub (Apr 29, 2020): #### Does not seem to work currently: ```markdown 1. After repository initialization: - `git commit` to save your work - `git checkout -b template` - to create a branch with initial template (required for updating) - `git checkout master` switch back to your thesis ``` ![grafik](https://user-images.githubusercontent.com/1366654/80590296-f78a2f80-8a1b-11ea-8bfc-1a2ed70b03d1.png) #### When identing with four spaces, it works: ```markdown 1. After repository initialization: - `git commit` to save your work - `git checkout -b template` - to create a branch with initial template (required for updating) - `git checkout master` switch back to your thesis ``` ![grafik](https://user-images.githubusercontent.com/1366654/80590355-08d33c00-8a1c-11ea-98eb-ae6755c92e53.png) #### Environment VS Code, markdownlint 0.35.1
Author
Owner

@DavidAnson commented on GitHub (Apr 29, 2020):

CommonMark treats the first example like two lists at the same level (because the nesting of two spaces is insufficient to push it into the ordered list item), so the warning you see is correct: Example

The second example nests one more space than necessary, but is treated as a nested list: Example

The linter could probably warn for the second case, but that is beyond what this issue was opened for. From what I can tell, the initially reported behavior of correct syntax being incorrectly flagged seems to have been addressed. After reviewing the original discussion, if you’d like to open a new issue asking for a violation to be reported in the four-space case, that seems reasonable and I would look into it.

<!-- gh-comment-id:621427480 --> @DavidAnson commented on GitHub (Apr 29, 2020): CommonMark treats the first example like two lists at the same level (because the nesting of two spaces is insufficient to push it into the ordered list item), so the warning you see is correct: [Example](https://markdown-it.github.io/#md3=%7B%22source%22%3A%221.%20Ordered%20list%20item%5Cn%5Cn%20%20-%20Unordered%20list%20item%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22src%22%7D%7D) The second example nests one more space than necessary, but is treated as a nested list: [Example](https://markdown-it.github.io/#md3=%7B%22source%22%3A%221.%20Ordered%20list%20item%5Cn%5Cn%20%20%20%20-%20Unordered%20list%20item%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22src%22%7D%7D) The linter could probably warn for the second case, but that is beyond what this issue was opened for. From what I can tell, the initially reported behavior of correct syntax being incorrectly flagged seems to have been addressed. After reviewing the original discussion, if you’d like to open a new issue asking for a violation to be reported in the four-space case, that seems reasonable and I would look into it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#15
No description provided.