[GH-ISSUE #540] MD037 Flags asterisks in HTML attributes #2288

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

Originally created by @mtlynch on GitHub (Jul 29, 2022).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/540

First, thanks for all your excellent work on markdownlint! I ran into a minor bug today that I wanted to share.

If there are two asterisks in an HTML attribute, markdownlint will flag it as MD037/no-space-in-emphasis. This seems to be an error as there isn't markdown within HTML attributes:

Example input

<img src="cron.png" alt="cron job with a '0 0 3 * *' schedule">

markdown-lint output

$ davidanson/markdownlint-cli2 example.md
markdownlint-cli2 v0.5.0 (markdownlint v0.26.1)
Finding: example.md
Linting: 1 file(s)
Summary: 2 error(s)
example.md:1:49 MD037/no-space-in-emphasis Spaces inside emphasis markers [Context: "* *"]
example.md:1 MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "<img src="cron.png" alt="cron ..."]
Originally created by @mtlynch on GitHub (Jul 29, 2022). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/540 First, thanks for all your excellent work on markdownlint! I ran into a minor bug today that I wanted to share. If there are two asterisks in an HTML attribute, markdownlint will flag it as MD037/no-space-in-emphasis. This seems to be an error as there isn't markdown within HTML attributes: ### Example input ```text <img src="cron.png" alt="cron job with a '0 0 3 * *' schedule"> ``` ### markdown-lint output ```bash $ davidanson/markdownlint-cli2 example.md markdownlint-cli2 v0.5.0 (markdownlint v0.26.1) Finding: example.md Linting: 1 file(s) Summary: 2 error(s) example.md:1:49 MD037/no-space-in-emphasis Spaces inside emphasis markers [Context: "* *"] example.md:1 MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "<img src="cron.png" alt="cron ..."] ```
kerem 2026-03-07 20:06:21 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jul 29, 2022):

Thanks for the clear reproduction! There are a number of rules that use heuristics instead of the parser and so don't really understand the context of what they are reporting. I already have a helper that excludes violations like this from code spans; I should be able to do something similar for HTML.

<!-- gh-comment-id:1199636645 --> @DavidAnson commented on GitHub (Jul 29, 2022): Thanks for the clear reproduction! There are a number of rules that use heuristics instead of the parser and so don't really understand the context of what they are reporting. I already have a helper that excludes violations like this from code spans; I should be able to do something similar for HTML.
Author
Owner

@DavidAnson commented on GitHub (Jul 29, 2022):

Oh, and thanks for the sponsorship!!

<!-- gh-comment-id:1199638423 --> @DavidAnson commented on GitHub (Jul 29, 2022): Oh, and thanks for the sponsorship!!
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#2288
No description provided.