mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #996] MD026: Invalid range when YAML front matter ending with punctuation is wrapped in HTML comment tags #585
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#585
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 @skyzyx on GitHub (Oct 6, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/996
I've been using this tool for a few years. Thank you!
I recently started seeing error messages causing markdownlint-cli to die. I know that this is occurring when using the CLI, but looking at the paths that are triggering the error, it seems to be coming from the underlying
markdownlint.jslibrary. Hence, opening the issue here.This works: (markdownlint@v0.30.0)
This crashes: (markdownlint@v0.31.1)
Error message is as follows, and repeats multiple times (I think once per Markdown document).
I haven't meaningfully updated my
.markdownlint.jsonfile in about ~2 years.It appears to be triggering from here: https://github.com/DavidAnson/markdownlint/blob/v0.31.1/lib/markdownlint.js#L606
Looking at the diff between the two releases, the only thing I see that looks like it might be related is this line:
https://github.com/DavidAnson/markdownlint/compare/v0.30.0..v0.31.1#diff-807e51fda288b4ebd0ccd4229d72a4c025f9b9316b0244ac45e76d8ff2317269L1025
@DavidAnson commented on GitHub (Oct 7, 2023):
According to the stack trace, the bug is probably in MD026. The source of the exception is just reporting an invalid range. The most helpful thing for me would be if you can identify a document that reproduces this problem so I can investigate. It can be a standalone document or you can point me to some existing repository and I can figure out which document it is. thank you!
@DavidAnson commented on GitHub (Oct 7, 2023):
Note to self: Likely from this repo: https://github.com/northwood-labs/terraform-provider-corefunc
@DavidAnson commented on GitHub (Oct 8, 2023):
The problem (with the repo above, at least) is that it puts YAML front matter inside HTML comment tags and the content of that HTML comment is being treated like Markdown. I've never seen this done before/elsewhere, but certainly it's wrong for markdownlint to throw in this scenario. Here is a simplified reproduction: https://dlaa.me/markdownlint/?renderer=markdownIt#%25m%3C!--%0A---%0Atitle%3A%20Front%20Matter%20YAML%20in%20HTML%20Comment%0Adescription%3A%20%7C-%0A%20%20This%20document%20has%20YAML%20front%20matter%20inside%20an%20HTML%20comment.%0A---%0A--%3E%0A%0A%23%20Front%20Matter%20YAML%20in%20HTML%20Comment%0A%0AText%20text%20text%0A
@DavidAnson commented on GitHub (Oct 8, 2023):
It turns out, that pattern is NOT technically an HTML comment which is why it is being parsed by markdownlint. Per the CommonMark specification (https://spec.commonmark.org/0.30/#raw-html):
@skyzyx commented on GitHub (Oct 8, 2023):
Out of interest, in which document did I add the thing which triggered the range error?
(I’ve been a Markdown user since the days when Movable Type was a popular blogging CMS. I also have a general interest in parsers, and in-turn, Commonmark/GFM.)
@DavidAnson commented on GitHub (Oct 9, 2023):
Maybe all of them? But here's one example:
docs/data-sources/str_camel.md. This is the pattern I saw in at least a couple of places: