Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MD019 - Multiple Spaces After Hash on ATX Style Heading

Severity: Warning
Category: Headings
Auto-fix: ✓ Available

Rule Description

This rule ensures there's only a single space after the hash character(s) in ATX-style headings. Multiple spaces are unnecessary and can cause inconsistent formatting.

Why This Rule Exists

Single space after hash is important because:

  • Maintains consistent formatting across documents
  • Follows standard markdown conventions
  • Reduces unnecessary whitespace
  • Improves readability and predictability

Examples

❌ Incorrect (violates rule)

#  Heading with multiple spaces
##   Another heading with extra spaces
###    Too many spaces here

✅ Correct

# Heading with single space
## Another heading correctly formatted
### Proper spacing

Configuration

This rule has no configuration options.

Automatic Fix

This rule supports automatic fixing with --fix. The fix will:

  • Reduce multiple spaces to a single space after hash character(s)
  • Preserve the heading level and content
  • Handle all heading levels (1-6)

Apply Fix

# Fix multiple space issues in headings
mdbook-lint lint --fix docs/

# Preview what would be fixed
mdbook-lint lint --fix --dry-run docs/

When to Disable

Consider disabling this rule if:

  • Your style guide requires multiple spaces for alignment
  • You're maintaining legacy content with specific spacing requirements

Disable in Config

# .mdbook-lint.toml
disabled_rules = ["MD019"]

Disable Inline

<!-- mdbook-lint-disable MD019 -->
##   Heading with multiple spaces allowed
<!-- mdbook-lint-enable MD019 -->
  • MD018 - No space after hash on ATX heading
  • MD020 - No space inside hashes on closed ATX heading
  • MD021 - Multiple spaces inside hashes on closed ATX heading
  • MD022 - Headings should be surrounded by blank lines
  • MD023 - Headings must start at the beginning of the line

References