mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Add new rule MD058/blanks-around-tables (fixes #132).
This commit is contained in:
parent
5ecdb045a5
commit
26466108e9
27 changed files with 914 additions and 76 deletions
51
doc/Rules.md
51
doc/Rules.md
|
@ -2458,6 +2458,57 @@ Missing cells in a row create holes in the table and suggest an omission.
|
|||
|
||||
[gfm-table-056]: https://github.github.com/gfm/#tables-extension-
|
||||
|
||||
<a name="md058"></a>
|
||||
|
||||
## `MD058` - Tables should be surrounded by blank lines
|
||||
|
||||
Tags: `table`
|
||||
|
||||
Aliases: `blanks-around-tables`
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered when tables are either not preceded or not followed by a
|
||||
blank line:
|
||||
|
||||
```markdown
|
||||
Some text
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
> Blockquote
|
||||
```
|
||||
|
||||
To fix violations of this rule, ensure that all tables have a blank line both
|
||||
before and after (except when the table is at the very beginning or end of the
|
||||
document):
|
||||
|
||||
```markdown
|
||||
Some text
|
||||
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
|
||||
> Blockquote
|
||||
```
|
||||
|
||||
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 will not
|
||||
trigger this rule:
|
||||
|
||||
```markdown
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
This text is part of the table and the next line is blank
|
||||
|
||||
Some text
|
||||
```
|
||||
|
||||
Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
|
||||
tables that don't have blank lines before and after them.
|
||||
|
||||
<!-- markdownlint-configure-file {
|
||||
"no-inline-html": {
|
||||
"allowed_elements": [
|
||||
|
|
48
doc/md058.md
Normal file
48
doc/md058.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# `MD058` - Tables should be surrounded by blank lines
|
||||
|
||||
Tags: `table`
|
||||
|
||||
Aliases: `blanks-around-tables`
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered when tables are either not preceded or not followed by a
|
||||
blank line:
|
||||
|
||||
```markdown
|
||||
Some text
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
> Blockquote
|
||||
```
|
||||
|
||||
To fix violations of this rule, ensure that all tables have a blank line both
|
||||
before and after (except when the table is at the very beginning or end of the
|
||||
document):
|
||||
|
||||
```markdown
|
||||
Some text
|
||||
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
|
||||
> Blockquote
|
||||
```
|
||||
|
||||
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 will not
|
||||
trigger this rule:
|
||||
|
||||
```markdown
|
||||
| Header | Header |
|
||||
| ------ | ------ |
|
||||
| Cell | Cell |
|
||||
This text is part of the table and the next line is blank
|
||||
|
||||
Some text
|
||||
```
|
||||
|
||||
Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
|
||||
tables that don't have blank lines before and after them.
|
Loading…
Add table
Add a link
Reference in a new issue