mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-26 01:36:03 +03:00
[GH-ISSUE #324] MD037/no-space-in-emphasis reported when underscore contained within emphasis #2126
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#2126
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 @tekumara on GitHub (Aug 28, 2020).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/324
The following markdown snippet, reports MD037/no-space-in-emphasis
Renders as:
~/.ssh/id_rsa and foo
@DavidAnson commented on GitHub (Aug 28, 2020):
This renders correctly because the parser makes assumptions about whitespace that allow it to ignore the embedded underscore. However, the linting rule cannot do that because it is specifically looking for mistakes in that area. Therefore, this is expected behavior for the rule. It believes the underscores match in pairs and therefore sees a problem. In order to fix this, you can escape the embedded underscore with a backslash. Here's an example of your text not reporting any violations:  https://dlaa.me/markdownlint/#%25m%23%20Issue%20324%0A%0A_~%2F.ssh%2Fid%5C_rsa_%20and%20_foo_%0A
@tekumara commented on GitHub (Aug 29, 2020):
Thanks for the quick response!
It looks like the commonmark spec allows for underscores inside emphasis, so the parser is happy.
_~/.ssh/id\_rsa_makes markdownlint happy but prettier removes the backslash, so I can't win 😢@DavidAnson commented on GitHub (Aug 29, 2020):
How do you feel about using asterisk for emphasis for that part? Doing so allows the underscore to be an escaped like so: https://dlaa.me/markdownlint/#%25m%23%20Issue%20324%0A%0A*~%2F.ssh%2Fid_rsa*%20and%20_foo_%0A
@tekumara commented on GitHub (Aug 29, 2020):
I prefer asterisk actually, but when I run prettier it converts asterisks to underscores (and causes the MD037 report) 🤕
@DavidAnson commented on GitHub (Aug 29, 2020):
I've lost track, is Prettier helping us or hurting us? 😐
@tekumara commented on GitHub (Aug 29, 2020):
99% of the time it's great. It will resolve a lot of issues identified by markdownlint (things like bare URLs, or trailing punctuation in headings, it can't fix automatically). For this edge case tho, markdownlint and prettier work against each other.
@DavidAnson commented on GitHub (Jun 19, 2021):
I don't see a simple way for this rule to be flexible enough to detect issues and also strict enough to allow this case. Because there are two easy workarounds (escape the underscore or use asterisks), I'm going to close the issue.