MD020 - Missing Space Inside Hashes on Closed ATX Style Headings
Severity: Warning
Category: Headings
Auto-fix: ✓ Available
Rule Description
This rule checks heading-like closed ATX syntax for missing separators between the heading text and its opening or closing hash sequence. A closed ATX heading uses spaces or tabs inside both sets of hashes.
Per CommonMark, a trailing hash sequence is a closing delimiter only when it is
preceded by a space or tab. Content-adjacent hashes in headings such as C# and
F# are ordinary heading text and do not trigger this rule.
Examples
❌ Incorrect
#Heading 1#
##Heading 2 ##
✅ Correct
# Heading 1 #
## Heading 2 ##
# Open headings are also valid
### C#
### F#
### Heading# is an open ATX heading whose text ends in #. MD020 does not
guess that the final hash was intended as a closing delimiter.
Configuration
This rule has no configuration options.
Automatic Fix
The fix adds missing separators where closed-heading intent is unambiguous:
##Heading## -> ## Heading ##
##Heading ## -> ## Heading ##
Content-adjacent hashes are never removed or converted into delimiters.
# Apply fixes
mdbook-lint lint --fix docs/
# Preview fixes
mdbook-lint lint --fix --dry-run docs/
Related Rules
- MD003 - Heading style
- MD018 - Missing space after hashes on ATX headings
- MD019 - Multiple spaces after hashes on ATX headings
- MD021 - Multiple spaces inside closed ATX headings