Skip to content

MD065 - Blank lines around horizontal rules

Aliases: blanks-around-horizontal-rules

What this rule does

Ensures horizontal rules (thematic breaks) have blank lines before and after them for better visual separation.

Why this matters

  • Improves readability: Blank lines around horizontal rules create clear visual breaks between sections
  • Consistent formatting: Ensures all horizontal rules are styled the same way throughout the document
  • Better rendering: Some markdown parsers may behave unexpectedly without blank lines around horizontal rules
  • Matches common conventions: Most markdown style guides recommend blank lines around thematic breaks

Examples

✅ Correct

This is the first section.

---

This is the second section.

❌ Incorrect

This is the first section.
---
This is the second section.

🔧 Fixed

This is the first section.

---

This is the second section.

Configuration

[MD065]
minimum-before = 1  # Minimum blank lines before horizontal rule (default: 1)
minimum-after = 1   # Minimum blank lines after horizontal rule (default: 1)

Configuration options explained

  • minimum-before: The minimum number of blank lines required before a horizontal rule (default: 1)
  • minimum-after: The minimum number of blank lines required after a horizontal rule (default: 1)

Exceptions

This rule does NOT flag horizontal rules in the following contexts:

1. Start of Document

No blank line is required before a horizontal rule at the very start of a document:

---

Content after horizontal rule.

2. End of Document

No blank line is required after a horizontal rule at the end of a document:

Content before horizontal rule.

---

3. Code Blocks

Horizontal rule patterns inside code blocks are not checked:

```
---
```

4. Setext Headings

Setext heading underlines (which look like horizontal rules) are not flagged:

Heading
---

This is correct - the --- is part of the heading, not a horizontal rule.

This includes headings inside blockquotes and list items, also when a line of the heading text is a lazy continuation without the >:

> Heading
text of the same heading
> ---

5. First Block of a List Item With an Empty Marker Line

No blank line is required before a horizontal rule that opens a list item whose marker has nothing after it. A blank line there would end the item and leave the rule outside the list, so the rule is checked only for the blank line after it:

-
  ***
  text

6. Text and Raw HTML That Only Look Like a Rule

A line is a horizontal rule only where the parser reads one. These lines are not checked, in a blockquote, a list item or a footnote as much as at the top level:

  • Indented text that continues a paragraph, including one that has a tag such as <audio> alone on a line in between (a tag of that kind cannot interrupt a paragraph):
> text
> <audio>
>     ***
  • Text inside a raw HTML block, also one opened after a quote or list marker:
> <div>
>     ***
  • A footnote paragraph continued by a line indented eight or more columns past the quote marker, and indented code in a footnote.

Horizontal Rule Formats

This rule recognizes all valid horizontal rule formats:

  • Hyphens: ---, ----, - - -
  • Asterisks: ***, ****, * * *
  • Underscores: ___, ____, _ _ _

All formats require at least 3 characters.

Fix

The automatic fix adds the required blank lines before and/or after horizontal rules.

Before:

Text before.
---
Text after.

After:

Text before.

---

Text after.
  • MD012 - Multiple consecutive blank lines
  • MD035 - Horizontal rule style (consistency of --- vs *** vs ___)
  • MD022 - Headings should be surrounded by blank lines