mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #431] Comments in Lists #359
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#359
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Foggalong on GitHub (Sep 22, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/431
MD032 is being flagged when HTML comments are included between list items. General example is
Markdown lint is complaining that lines 2 and 7 are MD032 violations because there aren't spaces around them, but if spaces are added (between 2 & 3 and 6 & 7) then that separates the sublist from the list and, when uncommented, leads to MD012 being flagged.
Alternatively, the comment can be adjusted so that it looks like
but (as well as looking weird) that flags a MD007 error when the sublist is uncommented.
From what I can tell there isn't a way to structure comments in lists without breaking one of those three rules. The ideal fix (I think) would be for MD032 to not fail in cases where the non-empty line next to the list is a comment, as a bonus going on to check if the line the other side of the comment is a list item or a blank line.
The context for this issue was this GitHub issue template which has a commented sublist and so seemingly can never be markdownlint compliant.
@Foggalong commented on GitHub (Sep 22, 2021):
Also flagged this at markdownlint/markdownlint#390 since (I think?) this project operates separately but let me know if I've misunderstood that 🙂
@DavidAnson commented on GitHub (Sep 22, 2021):
The violation is correct, the original sample creates two lists according to the CommonMark specification (the first has no blanks after and the second has no blanks before): https://markdown-it.github.io/#md3=%7B%22source%22%3A%22-%20item%20%3C!--%20comment%20--%3E%5Cn-%20item%20%3C!--%20comment%20--%3E%5Cn%3C!--%5Cn%20%20-%20commented%20subitem%3A%20description%5Cn%20%20-%20commented%20subitem%3A%20description%5Cn--%3E%5Cn-%20item%20%3C!--%20comment%20--%3E%5Cn-%20item%20%3C!--%20comment%20--%3E%22%2C%22defaults%22%3A%7B%22html%22%3Atrue%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
@Foggalong commented on GitHub (Sep 22, 2021):
This example is also creates two lists according to the CommonMark specification but doesn't get flagged as a markdown lint violation.
It's specifically multi-line comments inside lists that are being misflagged.
@Foggalong commented on GitHub (Sep 22, 2021):
Similarly fine is
but it's more of a workaround than a fix to the actual multiline comment issue.
@DavidAnson commented on GitHub (Sep 22, 2021):
The single-line comment not generating a warning looks like a bug. I'll have a look, here's the repro: https://dlaa.me/markdownlint/#%25m%23%20Issue%20431%0A%0A-%20item%20%3C!--%20comment%20--%3E%0A%3C!--%20%20-%20subitem%20--%3E%0A-%20item%20%3C!--%20comment%20--%3E%0A
@DavidAnson commented on GitHub (Sep 22, 2021):
I think your last example there looks like a good compromise - but it may start generating violations in a future release. :)
@Foggalong commented on GitHub (Sep 23, 2021):
Haha, seems I've found a bug but not the bug I thought I'd found!
@DavidAnson commented on GitHub (Dec 20, 2021):
When I looked at the code, I decided the tool's definition of "blank line" should have treated all your examples as scenarios that did NOT generate MD032. The next release of the library should behave as you expected. Here's the new test case: https://raw.githubusercontent.com/DavidAnson/markdownlint/6dea67825aac29bc6e43bd932d641e2bfe7b38ff/test/lists-with-commented-items.md