# MD030 - Add consistent spacing after list markers

Aliases: `list-marker-space`

## What this rule does

Ensures consistent spacing between list markers (bullets or numbers) and the text that follows them.

## Why this matters

- **Visual consistency**: Uniform spacing makes lists easier to scan
- **Proper rendering**: Some parsers require specific spacing to recognize lists
- **Professional appearance**: Consistent formatting looks more polished
- **Readability**: Proper spacing prevents list items from looking cramped

## Examples

### ✅ Correct

```markdown
* Unordered list item with one space
* Another item

1. Ordered list item with one space
2. Another item
```

### ❌ Incorrect

<!-- rumdl-disable MD030 -->

```markdown
*  Unordered list item with two spaces
*   Another item with three spaces

1.  Ordered list item with two spaces
2.   Another item with three spaces
```

<!-- rumdl-enable MD030 -->

### 🔧 Fixed

```markdown
* Unordered list item with one space
* Another item with one space

1. Ordered list item with one space
2. Another item with one space
```

## Configuration

```toml
[MD030]
ul-single = 1  # Spaces after bullet for single-line items (default: 1)
ol-single = 1  # Spaces after number for single-line items (default: 1)
ul-multi = 1  # Spaces after bullet for multi-line items (default: 1)
ol-multi = 1  # Spaces after number for multi-line items (default: 1)

# Align ordered list text to this column (default: 0 = off; valid: 3-6, try 4)
ol-align-column = 0
```

### Aligning ordered lists (`ol-align-column`)

By default MD030 uses a fixed number of spaces after every marker, so the text
column jumps as soon as a list crosses a digit boundary (`9.` → `10.`):

<!-- rumdl-disable MD029 MD030 -->

```markdown
1. one
9. nine
10. ten
```

<!-- rumdl-enable MD029 MD030 -->

As an alternative, you can set `ol-align-column` to line ordered list text up at
a fixed column (measured from the start of the marker; `4` is the usual choice).
Valid values are `0` (off) or `3` to `6`; CommonMark allows at most 4 spaces after
a marker, so columns outside that range are rejected. Narrower markers are padded
up to the column, overriding `ol-single` / `ol-multi`:

<!-- rumdl-disable MD029 MD030 -->

```markdown
1.  one
9.  nine
10. ten
```

<!-- rumdl-enable MD029 MD030 -->

A marker too wide for the column overflows with a single space rather than
pushing the rest of the list over, as it would easily reach the maximum of 4
spaces of indent available.

<!-- rumdl-disable MD029 MD030 -->

```markdown
1.  one
10. ten
100. hundred
```

<!-- rumdl-enable MD029 MD030 -->

The column is measured from each marker's own start, so nested lists align
relative to their own indentation, independent of the parent.

Aligning a marker moves the item's content, so its continuation and nested
content (sub-lists, blockquotes, code, paragraphs) shift by the same amount to
stay attached and aligned. For example, a nested blockquote:

```markdown
1.  > first line
    > second line
```

These shifts accumulate across nesting levels, so multi-line nested lists are
realigned in one pass. A nested unordered bullet that shares the marker's line
(e.g. `- x` in `1. - x`) also has `ul-single` / `ul-multi` applied, so the nested
list is spaced consistently with its siblings on their own lines.

## Automatic fixes

This rule will:

- Adjust spacing after list markers to match your configuration
- Preserve list item content and structure
- Handle single-line and multi-line items according to their specific settings
- Align ordered list text to a fixed column when `ol-align-column` is set

## Learn more

- [CommonMark Spec: List items](https://spec.commonmark.org/0.31.2/#list-items)
- [CommonMark Spec: Lists](https://spec.commonmark.org/0.31.2/#lists)

## Related rules

- [MD004 - Use consistent list markers](md004.md)
- [MD005 - Keep list indentation consistent](md005.md)
- [MD007 - Indent lists properly](md007.md)
- [MD029 - Use consistent numbers for ordered lists](md029.md)
