Skip to content

MD022 - blanks-around-headings

Description

This rule enforces blank lines around headings. It triggers when headings are not preceded or followed by at least the required number of blank lines (default: 1 each). Extra blank lines beyond the requirement are not flagged. The first heading in a document does not require blank lines above, and the last heading at the end of a document does not require blank lines below. Set lines_above or lines_below to -1 to disable the respective check.

Rationale

Aside from aesthetic reasons, some Markdown parsers will not parse headings that don't have a blank line before them, and will parse them as regular text. Consistent spacing around headings improves readability and ensures proper parsing.

Configuration

lines_above

Number of blank lines required before headings. Use -1 to disable.

  • Default: 1
lines_below

Number of blank lines required after headings. Use -1 to disable.

  • Default: 1

Examples

Invalid

# Heading 1
Some text here.

Some more text.
## Heading 2

Valid

# Heading 1

Some text here.

## Heading 2

Some more text here.