rumdl 0.2.63

A fast Markdown linter and formatter written in Rust
Documentation
# MD009 - Remove trailing spaces

Aliases: `no-trailing-spaces`

## What this rule does

Removes unnecessary spaces at the end of lines to keep your Markdown clean and consistent.

## Why this matters

- **Clean diffs**: Trailing spaces create noisy changes in version control
- **Parser compatibility**: Some Markdown tools have issues with trailing whitespace
- **Professional quality**: Clean files without hidden characters look more polished
- **File size**: Removing unnecessary spaces reduces file size (slightly but it adds up!)

## Examples

### ✅ Correct

```markdown
This line ends cleanly
No extra spaces here
Perfect formatting
```

### ❌ Incorrect

<!-- rumdl-disable MD009 -->

```markdown
This line has trailing spaces  
Extra spaces at the end 
Why are these spaces here?   
```

<!-- rumdl-enable MD009 -->

### 🔧 Fixed

```markdown
This line ends cleanly
Extra spaces removed
Clean and tidy now
```

## Configuration

```toml
[MD009]
br-spaces = 2                  # Trailing spaces kept as a hard line break; 0 keeps none (default: 2)
strict = false                 # Also flag br-spaces runs that render no line break (default: false)
list-item-empty-lines = false  # Allow trailing spaces in empty list item lines (default: false)
```

Fewer than 2 trailing spaces never render a line break, so `br-spaces = 0` (or 1) turns the exception off: a run of 2 spaces is then flagged like any other trailing spaces. The other exemptions still apply (code blocks unless `strict`, the single space of an empty blockquote line, and `list-item-empty-lines`). This matches markdownlint.

## Automatic fixes

This rule automatically removes trailing spaces from the end of lines. A run of exactly `br-spaces` spaces (2 by default) is kept as an intentional hard line break.

With `strict = true`, that run is kept only where it renders a line break: on a line inside a paragraph that is followed by more of the same paragraph. On a heading, a fence line, the last line of a paragraph or list item, and anywhere else the `<br>` would be invisible, the spaces are flagged and removed. Strict mode also checks lines inside code blocks, which are otherwise skipped. To remove rendering line breaks as well, set `br-spaces = 0`.

## Learn more

- [Line breaks in Markdown]https://www.markdownguide.org/basic-syntax/#line-breaks - When trailing spaces are actually useful
- [CommonMark specification]https://spec.commonmark.org/0.31.2/#hard-line-breaks - Technical details about line breaks

## Related rules

- [MD010]md010.md - Use spaces instead of tabs
- [MD047]md047.md - End files with a single newline