MDS025: table-format
Tables must have consistent edge pipes, equal column counts, surrounding blank lines, and prettier-style alignment.
A GFM table must satisfy four conditions:
- Every row’s leading/trailing pipe presence matches the configured
style(the markdownlint MD055 check). - Every non-header row, including the delimiter row, has the same logical cell count as the header (MD056).
- The table has a blank line before and after (MD058).
- Each bordered table has aligned column widths and consistent
padding (the prettier-style alignment pass that gave the rule its
name), with the configured
separator-style.
Conditions 1, 3, and 4 are auto-fixed by mdsmith fix. Condition 2
(MD056) is flagged but never auto-rewritten on its own: a missing
cell’s intended content is unknown. The alignment pass does pad
short rows with empty cells while it normalises widths, so a fixed
bordered table is structurally clean even when the original
missed a cell. A borderless table is not formatted by the
alignment pass — tablefmt requires edge pipes on every row. MD056
therefore keeps firing on a borderless short row after fix; add
the edge pipes or fill the cell to resolve it.
# Settings
| Setting | Type | Default | Description |
|---|---|---|---|
pad | int | 1 | spaces on each side of cell content |
separator-style | string | "spaced" | separator row layout (see examples below): spaced or compact |
style | string | "consistent" | edge-pipe style: consistent, leading_and_trailing, or no_leading_or_trailing |
consistent infers the required edge-pipe shape from each table’s
header row and holds every other row to it. The other two values
require or forbid leading and trailing pipes on every row.
Separator row examples:
spaced(the GFM-spec form):| --- |compact(dense form):|---|
# Config
rules:
table-format:
pad: 1
separator-style: spaced
style: consistentOpt into the dense compact form:
rules:
table-format:
separator-style: compactDisable:
rules:
table-format: false# Examples
# Good
# Formatted Table
| Name | Description |
| ------ | ------------------------- |
| foo | A short one |
| barbaz | A longer description here |# Good – alignment indicators
# Aligned Table
| Left | Center | Right |
| :--- | :----: | ----: |
| aaa | bbb | ccc |# Good – single column
# Single Column
| Item |
| ------ |
| first |
| second |# Good – compact (opt-in)
With separator-style: compact the same column widths apply; only the
separator row collapses its padding spaces. The fixture below carries
the setting in front matter so the integration tests exercise the
compact path.
# Formatted Compact Table
| Name | Description |
|--------|---------------------------|
| foo | A short one |
| barbaz | A longer description here |# Good – borderless
# Borderless table
No leading or trailing pipe on any row. The style is
consistent, so the table passes.
Key | Value
--- | -----
a | one
b | two# Good – blockquoted
# Blockquote table
> Quoted intro.
>
> | Key | Value |
> | --- | ----- |
> | a | one |
>
> Quoted outro.# Bad – misaligned
# Misaligned Table
| Name | Description |
|---|---|
| foo | A short one |
| barbaz | A longer description here |# Bad – alignment indicators
# Misaligned Alignment
| Left | Center | Right |
|:---|:---:|---:|
| aaa | bbb | ccc |# Bad – mixed edge pipes (MD055)
# Mixed pipes
Key | Value
--- | -----
| a | one |
b | two# Bad – missing cell (MD056)
# Missing cell
| Key | Value |
| --- | ----- |
| a | one |
| b |# Bad – no surrounding blanks (MD058)
# No blanks
Paragraph before.
| Key | Value |
| --- | ----- |
| a | one |
Paragraph after.# Edge Cases
| Scenario | Behavior |
|---|---|
| table inside blockquote | > prefix preserved on each line; MD058 blanks use the bare > marker |
| table inside list | indentation prefix preserved |
| table inside fenced code block | skipped, not checked or modified |
| table inside a generated section | skipped (both passes); the directive owns the bytes |
| escaped pipe in cell | | treated as literal, not a column boundary |
| single-column table | formatted normally with minimum width of 3 |
| inline code, links, emphasis | width measured in display columns, syntax included |
| short row (MD056) | flagged; the alignment pass pads it with empty cells while reformatting widths |
no_leading_or_trailing + bordered | edges stripped; alignment pass then leaves the now-borderless table alone (converges) |
# Meta-Information
- ID: MDS025
- Name:
table-format - Status: ready
- Default: enabled, pad: 1, separator-style: spaced, style: consistent
- Fixable: yes (MD055 edges, MD058 blanks, alignment; MD056 column count is flagged only)
- Implementation: source
- Category: table
- markdownlint:
- rumdl:
- obsidian-linter: empty-line-around-tables (partial)