[GH-ISSUE #1347] MD004 triggered on different lists #2515

Closed
opened 2026-03-07 20:08:30 +03:00 by kerem · 2 comments
Owner

Originally created by @ferrarimarco on GitHub (Sep 5, 2024).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1347

Hi! Thanks for working on this tool :)

I think Markdownlint might wrongly flagging the following snippet as a violation of MD004 set to its default configuration (consistent).

# H1

- list1: item 1

* list2: item 2

- list3: item 3

5 - MD004 / ul-style Unordered list style [Expected: dash; Actual: asterisk]

From my understanding of the CommonMark spec, this is allowed. Also, it's the only way to differentiate between different lists where there are only blank lines between them:

Changing the bullet or ordered list delimiter starts a new list:

Input:

- foo
- bar
+ baz

HTML output:

<ul>
<li>foo</li>
<li>bar</li>
</ul>
<ul>
<li>baz</li>
</ul>

Here's a playground link that reproduces the issue.

Is there a way to configure MD004 to allow for this, besides disabling the rule entirely?

Thanks!

Originally created by @ferrarimarco on GitHub (Sep 5, 2024). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1347 Hi! Thanks for working on this tool :) I think Markdownlint might wrongly flagging the following snippet as a violation of MD004 set to its default configuration (`consistent`). ```markdown # H1 - list1: item 1 * list2: item 2 - list3: item 3 ``` > 5 - MD004 / ul-style Unordered list style [Expected: dash; Actual: asterisk] From my understanding of the [CommonMark spec](https://spec.commonmark.org/0.31.2/#example-301), this is allowed. Also, it's the only way to differentiate between different lists where there are only blank lines between them: > Changing the bullet or ordered list delimiter starts a new list: Input: ```markdown - foo - bar + baz ``` HTML output: ```html <ul> <li>foo</li> <li>bar</li> </ul> <ul> <li>baz</li> </ul> ``` Here's a [playground link](https://dlaa.me/markdownlint/#%25m%23%20H1%0A%0A-%20list1%3A%20item%201%0A%0A*%20list2%3A%20item%202%0A%0A-%20list3%3A%20item%203%0A) that reproduces the issue. Is there a way to configure `MD004` to allow for this, besides disabling the rule entirely? Thanks!
kerem 2026-03-07 20:08:30 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Sep 5, 2024):

The configuration says all lists should have the same style but the example has lists with different styles, so the rule reports a violation. This is correct and working as intended.

I think it is uncommon to have separate lists consecutively as in your example, but you can put an HTML comment between them if you want to avoid the warning by using the same list type twice in a row without content between. Or disable the rule for that file or part of it.

https://dlaa.me/markdownlint/#%25m%23%20H1%0A%0A1.%20list1%3A%20item%201%0A%0A%3C!--%20comment%20--%3E%0A%0A1.%20list2%3A%20item%202%0A%0A%3C!--%20comment%20--%3E%0A%0A1.%20list3%3A%20item%203%0A

<!-- gh-comment-id:2332194684 --> @DavidAnson commented on GitHub (Sep 5, 2024): The configuration says all lists should have the same style but the example has lists with different styles, so the rule reports a violation. This is correct and working as intended. I think it is uncommon to have separate lists consecutively as in your example, but you can put an HTML comment between them if you want to avoid the warning by using the same list type twice in a row without content between. Or disable the rule for that file or part of it. https://dlaa.me/markdownlint/#%25m%23%20H1%0A%0A1.%20list1%3A%20item%201%0A%0A%3C!--%20comment%20--%3E%0A%0A1.%20list2%3A%20item%202%0A%0A%3C!--%20comment%20--%3E%0A%0A1.%20list3%3A%20item%203%0A
Author
Owner

@ferrarimarco commented on GitHub (Sep 5, 2024):

Yeah, makes sense. I guess I was asking for another option for MD004 along the lines of sublists that allowed this behavior.

Anyway, thanks!

<!-- gh-comment-id:2332307856 --> @ferrarimarco commented on GitHub (Sep 5, 2024): Yeah, makes sense. I guess I was asking for another option for MD004 along the lines of `sublists` that allowed this behavior. Anyway, thanks!
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#2515
No description provided.