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

MD012 - Multiple Consecutive Blank Lines

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

Rule Description

This rule checks for multiple consecutive blank lines in the document. Excessive blank lines add unnecessary whitespace without improving readability.

Why This Rule Exists

Multiple consecutive blank lines create issues:

  • Inconsistent spacing throughout documents
  • Unnecessary vertical space in rendered output
  • Potential confusion about section boundaries
  • Increased file size without benefit

Examples

❌ Incorrect (violates rule)

# Heading

First paragraph.


Second paragraph with too many blank lines above.



Third paragraph with even more blank lines.

✅ Correct

# Heading

First paragraph.

Second paragraph with single blank line.

Third paragraph properly spaced.

Configuration

[MD012]
maximum = 1  # Maximum consecutive blank lines allowed (default: 1)

Automatic Fix

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

  • Reduce multiple consecutive blank lines to the configured maximum
  • Preserve intentional spacing at the maximum level
  • Handle blank lines anywhere in the document

Apply Fix

# Fix excessive blank lines
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 blank lines for visual separation
  • You're working with generated content that uses specific spacing
  • You need extra spacing for ASCII art or diagrams

Disable in Config

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

Disable Inline

<!-- mdbook-lint-disable MD012 -->
Content with multiple


blank lines allowed here
<!-- mdbook-lint-enable MD012 -->
  • MD009 - No trailing spaces
  • MD010 - Hard tabs
  • MD047 - Files should end with newline

References