Update MD038/no-space-in-code to allow code spans with only spaces (fixes #1481).

This commit is contained in:
David Anson 2025-02-02 21:36:35 -08:00
parent 2d2fafc58d
commit 90cf515ff0
7 changed files with 56 additions and 68 deletions

View file

@ -1528,8 +1528,8 @@ Aliases: `no-space-in-code`
Fixable: Some violations can be fixed by tooling
This rule is triggered for code span elements that have spaces adjacent to the
backticks:
This rule is triggered for code spans that have content with spaces next to the
beginning or ending backticks:
```markdown
`some text `
@ -1537,14 +1537,21 @@ backticks:
` some text`
```
To fix this, remove any spaces adjacent to the backticks:
To fix this, remove any spaces at the beginning or ending:
```markdown
`some text`
```
Note: Code spans containing only spaces are allowed by the specification:
```markdown
` ` or ` `
```
Note: A single leading and trailing space is allowed by the specification and
automatically trimmed (in order to allow for code spans that embed backticks):
automatically trimmed by the parser (in order to allow for code spans that embed
backticks):
```markdown
`` `backticks` ``
@ -1558,8 +1565,7 @@ span markers from an embedded backtick (though the space is not trimmed):
```
Rationale: Violations of this rule are usually unintentional and may lead to
improperly-rendered content. If spaces beside backticks are intentional, this
rule can be disabled for that line or file.
improperly-rendered content.
<a name="md039"></a>

View file

@ -6,8 +6,8 @@ Aliases: `no-space-in-code`
Fixable: Some violations can be fixed by tooling
This rule is triggered for code span elements that have spaces adjacent to the
backticks:
This rule is triggered for code spans that have content with spaces next to the
beginning or ending backticks:
```markdown
`some text `
@ -15,14 +15,21 @@ backticks:
` some text`
```
To fix this, remove any spaces adjacent to the backticks:
To fix this, remove any spaces at the beginning or ending:
```markdown
`some text`
```
Note: Code spans containing only spaces are allowed by the specification:
```markdown
` ` or ` `
```
Note: A single leading and trailing space is allowed by the specification and
automatically trimmed (in order to allow for code spans that embed backticks):
automatically trimmed by the parser (in order to allow for code spans that embed
backticks):
```markdown
`` `backticks` ``
@ -36,5 +43,4 @@ span markers from an embedded backtick (though the space is not trimmed):
```
Rationale: Violations of this rule are usually unintentional and may lead to
improperly-rendered content. If spaces beside backticks are intentional, this
rule can be disabled for that line or file.
improperly-rendered content.