mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1481] MD038: Code span containing only spaces #2543
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#2543
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 @straight-shoota on GitHub (Feb 1, 2025).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1481
When a code span contains only spaces, I think MD038 should not apply.
CommonMark describes that case to be taken as is without chopping off leading or trailing spaces (https://spec.commonmark.org/0.31.2/#code-spans).
When there are only spaces, it's very likely that they're intentional. That premise for MD038 is to avoid unintentional whitespace.
And it's even more likely that the automatic fix is much less intentional:
markdownlint --fixremoves all spaces.This results in an empty code span, which is not even a valid code span. Thus the fix definitely changes semantics.
In my opinion the fix behaviour is wrong. The rule violation maybe not as clearly wrong, but I'd suggest to exempt code spans with only spaces from MD038.
Original:
Original, rendered in GitHub:
Result of
markdownlint --fix:Result of
markdownlint --fix, rendered in GitHub:@DavidAnson commented on GitHub (May 1, 2025):
[Deleted obvious SPAM comment]