# MD022 - Headings Should Be Surrounded by Blank Lines

## Description

This rule ensures that all headings have a blank line both before and after the heading.
Consistent spacing around headings improves readability and ensures proper rendering in all Markdown processors.

## Configuration

- `lines_above`: Number of blank lines that should be above headings (default: 1)
- `lines_below`: Number of blank lines that should be below headings (default: 1)

<!-- markdownlint-disable -->
## Examples

### Valid

```markdown
# Heading 1

Some content here.

## Heading 2

More content here.

### Heading 3

Even more content.
```

### Invalid

```markdown
# Heading 1
Some content here.
## Heading 2
More content here.
### Heading 3
Even more content.
```

### Fixed

```markdown
# Heading 1

Some content here.

## Heading 2

More content here.

### Heading 3

Even more content.
```
<!-- markdownlint-enable -->

## Special Cases

- This rule applies to both ATX-style headings (with hash signs) and setext-style headings (underlined with = or -)
- The first heading in a document should have a blank line after it, but doesn't require a blank line before it
- The last heading in a document should have a blank line before it, but doesn't require a blank line after it
- Front matter (YAML, TOML, etc.) at the beginning of a document is ignored when checking the first heading

## Related Rules

- [MD001 - Heading increment](md001.md): Ensures heading levels increment by one level at a time
- [MD003 - Heading style](md003.md): Ensures consistent heading style
- [MD023 - Headings must start at the beginning of the line](md023.md): Ensures headings are not indented
