2023-12-30 18:15:38 -08:00
|
|
|
# `MD055` - Table pipe style
|
|
|
|
|
|
|
|
Tags: `table`
|
|
|
|
|
|
|
|
Aliases: `table-pipe-style`
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
- `style`: Table pipe style (`string`, default `consistent`, values
|
|
|
|
`consistent` / `leading_and_trailing` / `leading_only` /
|
|
|
|
`no_leading_or_trailing` / `trailing_only`)
|
|
|
|
|
2024-01-04 23:07:55 -08:00
|
|
|
This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
|
|
|
|
is inconsistent about its use of leading and trailing pipe characters (`|`).
|
2023-12-30 18:15:38 -08:00
|
|
|
|
|
|
|
By default (`consistent` style), the header row of the first table in a document
|
2024-10-07 22:08:16 -07:00
|
|
|
is used to determine the style that is enforced for every table in the document.
|
|
|
|
A specific style can be used instead (`leading_and_trailing`, `leading_only`,
|
|
|
|
`no_leading_or_trailing`, `trailing_only`).
|
2023-12-30 18:15:38 -08:00
|
|
|
|
|
|
|
This table's header row has leading and trailing pipes, but its delimiter row is
|
|
|
|
missing the trailing pipe and its first row of cells is missing the leading
|
|
|
|
pipe:
|
|
|
|
|
|
|
|
```markdown
|
2024-01-04 23:07:55 -08:00
|
|
|
| Header | Header |
|
|
|
|
| ------ | ------
|
|
|
|
Cell | Cell |
|
2023-12-30 18:15:38 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
To fix these issues, make sure there is a pipe character at the beginning and
|
|
|
|
end of every row:
|
|
|
|
|
|
|
|
```markdown
|
2024-01-04 23:07:55 -08:00
|
|
|
| Header | Header |
|
|
|
|
| ------ | ------ |
|
|
|
|
| Cell | Cell |
|
2023-12-30 18:15:38 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Note that text immediately following a table (i.e., not separated by an empty
|
|
|
|
line) is treated as part of the table (per the specification) and may also
|
|
|
|
trigger this rule:
|
|
|
|
|
|
|
|
```markdown
|
2024-01-04 23:07:55 -08:00
|
|
|
| Header | Header |
|
|
|
|
| ------ | ------ |
|
|
|
|
| Cell | Cell |
|
2023-12-30 18:15:38 -08:00
|
|
|
This text is part of the table
|
|
|
|
```
|
|
|
|
|
|
|
|
Rationale: Some parsers have difficulty with tables that are missing their
|
|
|
|
leading or trailing pipe characters. The use of leading/trailing pipes can also
|
|
|
|
help provide visual clarity.
|
|
|
|
|
2024-01-04 23:07:55 -08:00
|
|
|
[gfm-table-055]: https://github.github.com/gfm/#tables-extension-
|