rumdl 0.3.3

A fast Markdown linter and formatter written in Rust
Documentation
# MD012 - Remove multiple blank lines

Aliases: `no-multiple-blanks`

## What this rule does

Reduces multiple consecutive blank lines to just one, keeping your documents clean and consistent.

## Why this matters

- **Readability**: Too many blank lines make documents feel disconnected and harder to follow
- **File size**: Extra blank lines waste space without adding value
- **Professional appearance**: Clean spacing looks polished and intentional
- **Consistency**: Standard spacing makes documents easier to maintain

## Examples

### ✅ Correct

```markdown
# Chapter 1

This is the introduction paragraph.

## Section 1.1

Content for this section.

## Section 1.2

More content here.
```

### ❌ Incorrect

<!-- rumdl-disable MD012 -->

```markdown
# Chapter 1


This is the introduction paragraph.



## Section 1.1

Content for this section.


## Section 1.2


More content here.
```

<!-- rumdl-enable MD012 -->

### 🔧 Fixed

```markdown
# Chapter 1

This is the introduction paragraph.

## Section 1.1

Content for this section.

## Section 1.2

More content here.
```

## Configuration

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

## Heading awareness

MD012 reads [MD022](md022.md)'s `lines-above`, `lines-below`, and `nested-heading-lines-above` configuration to determine how many blank lines are allowed adjacent to headings. This prevents MD012 from flagging blank lines that MD022 requires.

For example, with `lines-above = 2`, you need two blank lines before each heading — MD012 will allow up to 2 blank lines above headings while still flagging excess elsewhere:

```toml
[MD022]
lines-above = 2
lines-below = 1
```

```markdown
# Title


## Section
```

The two blank lines before `## Section` are allowed by MD012 because MD022 requires them. Multiple blank lines between non-heading content are still flagged normally.

If MD022 is disabled, MD012 enforces its own maximum everywhere without any special heading treatment. If MD022 uses `lines-above = -1` (unlimited), MD012 will not flag any blank lines above headings.

## How violations are reported

MD012 reports one warning per run of consecutive blank lines, not one per excess line. The message states how many blank lines the run holds and how many are allowed there, including any higher limit derived from MD022 next to a heading:

```text
doc.md:4:1: [MD012] Multiple consecutive blank lines between content (4 found, 1 allowed) [*]
doc.md:9:1: [MD012] Blank line at end of file (1 found, 0 allowed) [*]
```

The warning's range covers exactly the lines its fix removes. It starts at the first excess line and ends at the start of the line after the last one, so editors highlight every line that will be deleted. At the end of a file the range starts at the first trailing blank line and runs to the end of the file. A single fix removes the whole run.

Because the range ends at the start of the next content line, a `rumdl-disable-line MD012` comment on that line does not suppress the blank lines before it. To suppress a run, wrap it in `<!-- rumdl-disable MD012 -->` and `<!-- rumdl-enable MD012 -->`, or put `<!-- rumdl-disable-next-line MD012 -->` directly above its first excess line.

## Automatic fixes

This rule automatically removes excess blank lines. Near headings, blanks are capped at the limit derived from MD022's configuration. Between non-heading content, blanks are capped at MD012's own maximum (default: 1).

## Learn more

- [Paragraphs in Markdown]https://www.markdownguide.org/basic-syntax/#paragraphs-1 - How to use blank lines effectively
- [CommonMark specification]https://spec.commonmark.org/0.31.2/#blank-lines - Technical details about blank lines

## Related rules

- [MD009]md009.md - Remove trailing spaces
- [MD022]md022.md - Headings should be surrounded by blank lines
- [MD047]md047.md - End files with a single newline