Rule - MD020#
| Property | Value |
|---|---|
| Aliases | md020, no-missing-space-closed-atx |
| Autofix Available | No |
| Enabled By Default | Yes |
Summary#
No space present inside of the hashes on a possible Atx Closed Heading.
Reasoning#
Correctness#
In most cases, one or more hash characters (#) followed by text and closing
hash characters were meant to indicate an Atx Closed Heading, with the
space between the hash characters and the text being omitted.
Examples#
Failure Scenarios#
This rule triggers when a sequence of characters occurs at the start of a line in
a paragraph after between 0 and 3 leading spaces are removed. After those leading
spaces are removed, this rule then looks for between 1 and 6 hash characters (#),
0 or more space characters, 1 or more non-space characters, 0 or more space
characters, and 1 or more hash characters. This rule specifically triggers
if the number of space characters at the start of the Atx Closed Heading is zero:
```Markdown
Heading 1#
```
if the number of space character at the end of the Atx Closed Heading is zero:
```Markdown
Heading 1#
```
or if both counts of space characters are zero:
```Markdown
Heading 1#
```
Correct Scenarios#
This rule does not trigger when there are 1 or more spaces on either side of the Atx Closed Heading:
```Markdown
Heading 2#
```
or if a closing hash character is not present:
```Markdown
Heading 2#
```
This failure scenario is managed by Rule md018.
Fix Description#
The reason for not being able to auto-fix this rule is context. As stated above, the rule looks for:
No space present inside of the hashes on a possible Atx Closed Heading.
As there is only a possibility that the Markdown:
```Markdown
Heading 1#
```
represents a heading, there is a lack of context surrounding the implied meaning of that block of text. It is better for this rule to trigger and have the author of the document clarify the context than to assume that the above text will always indicate a heading.
Configuration#
| Prefixes |
|---|
plugins.md020. |
plugins.no-missing-space-closed-atx. |
| Value Name | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
True |
Whether the Rule Plugin is enabled. |
Origination of Rule#
This rule is largely inspired by the MarkdownLint rule MD020.
Differences From MarkdownLint Rule#
Like the PyMarkdown version of Rule md018, the original rule did not trigger in Block Quote elements or List elements but did fire within SetExt Heading elements. These changes were also made to this rule to keep it consistent with Rule Md018.