Comments in Lists
See original GitHub issueMD032 is being flagged when HTML comments are included between list items. General example is
- item <!-- comment -->
- item <!-- comment -->
<!--
- commented subitem: description
- commented subitem: description
-->
- item <!-- comment -->
- item <!-- comment -->
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
- item <!-- comment -->
- item <!-- comment -->
<!--- commented subitem: description
- commented subitem: description-->
- item <!-- comment -->
- item <!-- comment -->
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
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
Haha, seems I’ve found a bug but not the bug I thought I’d found!