2015-03-12 23:42:06 -07:00
|
|
|
# Rules
|
|
|
|
|
|
|
|
This document contains a description of all rules, what they are checking for,
|
2020-12-28 13:28:38 -08:00
|
|
|
as well as examples of documents that break the rule and corrected
|
2023-11-09 19:47:15 -08:00
|
|
|
versions of the examples.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md001"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD001` - Heading levels should only increment by one level at a time
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `heading-increment`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
This rule is triggered when you skip heading levels in a Markdown document, for
|
2015-03-12 23:42:06 -07:00
|
|
|
example:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
### Heading 3
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
We skipped out a 2nd level heading in this document
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
When using multiple heading levels, nested headings should increase by only one
|
2015-03-12 23:42:06 -07:00
|
|
|
level at a time:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
### Heading 3
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
#### Heading 4
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Another Heading 2
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
### Another Heading 3
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Headings represent the structure of a document and can be confusing
|
|
|
|
when skipped - especially for accessibility scenarios. More information:
|
|
|
|
<https://www.w3.org/WAI/tutorials/page-structure/headings/>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md003"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD003` - Heading style
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `heading-style`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: Heading style (`string`, default `consistent`, values `atx` /
|
2022-11-05 17:34:37 -07:00
|
|
|
`atx_closed` / `consistent` / `setext` / `setext_with_atx` /
|
|
|
|
`setext_with_atx_closed`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-08 22:30:17 -08:00
|
|
|
This rule is triggered when different heading styles are used in the same
|
|
|
|
document:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# ATX style H1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
## Closed ATX style H2 ##
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Setext style H1
|
|
|
|
===============
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-08 22:30:17 -08:00
|
|
|
To fix the issue, use consistent heading styles throughout the document:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# ATX style H1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
## ATX style H2
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-08 22:30:17 -08:00
|
|
|
The `setext_with_atx` and `setext_with_atx_closed` settings allow ATX-style
|
|
|
|
headings of level 3 or more in documents with setext-style headings (which only
|
|
|
|
support level 1 and 2 headings):
|
2015-07-29 22:17:33 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Setext style H1
|
|
|
|
===============
|
2015-07-29 22:17:33 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Setext style H2
|
|
|
|
---------------
|
2015-07-29 22:17:33 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
### ATX style H3
|
|
|
|
```
|
2015-07-29 22:17:33 -07:00
|
|
|
|
2022-12-08 22:30:17 -08:00
|
|
|
Note: The configured heading style can be a specific style to require (`atx`,
|
|
|
|
`atx_closed`, `setext`, `setext_with_atx`, `setext_with_atx_closed`), or may
|
|
|
|
just require that usage is consistent within the document via `consistent`.
|
|
|
|
|
|
|
|
Note: The placement of a horizontal rule directly below a line of text can
|
|
|
|
trigger this rule by turning that text into a level 2 setext-style heading:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
A line of text followed by a horizontal rule becomes a heading
|
|
|
|
---
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md004"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD004` - Unordered list style
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `bullet`, `ul`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `ul-style`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: List style (`string`, default `consistent`, values `asterisk` /
|
2022-11-05 17:34:37 -07:00
|
|
|
`consistent` / `dash` / `plus` / `sublist`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2021-02-06 15:49:02 -08:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when the symbols used in the document for unordered
|
|
|
|
list items do not match the configured unordered list style:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Item 1
|
|
|
|
+ Item 2
|
|
|
|
- Item 3
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this issue, use the configured style for list items throughout the
|
|
|
|
document:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Item 1
|
|
|
|
* Item 2
|
|
|
|
* Item 3
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
The configured list style can be a specific symbol to use (asterisk, plus,
|
|
|
|
dash), to ensure that all list styling is consistent, or to ensure that each
|
2020-12-28 13:28:38 -08:00
|
|
|
sublist has a consistent symbol that differs from its parent list.
|
2016-07-04 14:32:40 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
For example, the following is valid for the `sublist` style because the
|
|
|
|
outer-most indent uses asterisk, the middle indent uses plus, and the inner-most
|
|
|
|
indent uses dash:
|
2016-07-04 14:32:40 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Item 1
|
|
|
|
+ Item 2
|
|
|
|
- Item 3
|
|
|
|
+ Item 4
|
|
|
|
* Item 4
|
|
|
|
+ Item 5
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md005"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD005` - Inconsistent indentation for list items at the same level
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `bullet`, `indentation`, `ul`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `list-indent`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when list items are parsed as being at the same level,
|
|
|
|
but don't have the same indentation:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Item 1
|
|
|
|
* Nested Item 1
|
|
|
|
* Nested Item 2
|
|
|
|
* A misaligned item
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Usually, this rule will be triggered because of a typo. Correct the indentation
|
2015-03-12 23:42:06 -07:00
|
|
|
for the list to fix it:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Item 1
|
|
|
|
* Nested Item 1
|
|
|
|
* Nested Item 2
|
|
|
|
* Nested Item 3
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-06-15 22:37:12 -07:00
|
|
|
Sequentially-ordered list markers are usually left-aligned such that all items
|
|
|
|
have the same starting column:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
...
|
|
|
|
8. Item
|
|
|
|
9. Item
|
|
|
|
10. Item
|
|
|
|
11. Item
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
|
|
|
This rule also supports right-alignment of list markers such that all items have
|
|
|
|
the same ending column:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
...
|
|
|
|
8. Item
|
|
|
|
9. Item
|
|
|
|
10. Item
|
|
|
|
11. Item
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Violations of this rule can lead to improperly rendered content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md007"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD007` - Unordered list indentation
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `bullet`, `indentation`, `ul`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `ul-indent`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2021-12-13 21:49:43 -08:00
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `indent`: Spaces for indent (`integer`, default `2`)
|
|
|
|
- `start_indent`: Spaces for first level indent (when start_indented is set)
|
2022-11-05 17:34:37 -07:00
|
|
|
(`integer`, default `2`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `start_indented`: Whether to indent the first level of the list (`boolean`,
|
2022-11-05 17:34:37 -07:00
|
|
|
default `false`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when list items are not indented by the configured
|
|
|
|
number of spaces (default: 2).
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* List item
|
|
|
|
* Nested list item indented by 3 spaces
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
Corrected Example:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* List item
|
|
|
|
* Nested list item indented by 2 spaces
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-06-26 11:56:48 -07:00
|
|
|
Note: This rule applies to a sublist only if its parent lists are all also
|
|
|
|
unordered (otherwise, extra indentation of ordered lists interferes with the
|
|
|
|
rule).
|
|
|
|
|
2020-01-01 15:53:03 -05:00
|
|
|
The `start_indented` parameter allows the first level of lists to be indented by
|
2023-11-09 19:47:15 -08:00
|
|
|
the configured number of spaces rather than starting at zero. The `start_indent`
|
|
|
|
parameter allows the first level of lists to be indented by a different number
|
|
|
|
of spaces than the rest (ignored when `start_indented` is not set).
|
2020-01-01 15:53:03 -05:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Indenting by 2 spaces allows the content of a nested list to be in
|
|
|
|
line with the start of the content of the parent list when a single space is
|
|
|
|
used after the list marker. Indenting by 4 spaces is consistent with code blocks
|
|
|
|
and simpler for editors to implement. Additionally, this can be a compatibility
|
2022-11-05 17:34:37 -07:00
|
|
|
issue for other Markdown parsers, which require 4-space indents. More
|
2023-09-10 20:21:51 -07:00
|
|
|
information: [Markdown Style Guide][markdown-style-guide].
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2021-08-13 22:18:39 -07:00
|
|
|
Note: See [Prettier.md](Prettier.md) for compatibility information.
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
[markdown-style-guide]: https://cirosantilli.com/markdown-style-guide#indentation-of-content-inside-lists
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md009"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD009` - Trailing spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-trailing-spaces`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2015-04-14 09:07:25 -07:00
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `br_spaces`: Spaces for line break (`integer`, default `2`)
|
|
|
|
- `list_item_empty_lines`: Allow spaces for empty lines in list items
|
2022-11-05 17:34:37 -07:00
|
|
|
(`boolean`, default `false`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `strict`: Include unnecessary breaks (`boolean`, default `false`)
|
2021-01-31 16:02:49 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
This rule is triggered on any lines that end with unexpected whitespace. To fix
|
|
|
|
this, remove the trailing space from the end of the line.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-11-21 16:53:31 -08:00
|
|
|
Note: Trailing space is allowed in indented and fenced code blocks because some
|
|
|
|
languages require it.
|
|
|
|
|
2018-04-30 21:34:19 -07:00
|
|
|
The `br_spaces` parameter allows an exception to this rule for a specific number
|
|
|
|
of trailing spaces, typically used to insert an explicit line break. The default
|
|
|
|
value allows 2 spaces to indicate a hard break (\<br> element).
|
2015-04-14 09:07:25 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Note: You must set `br_spaces` to a value >= 2 for this parameter to take
|
|
|
|
effect. Setting `br_spaces` to 1 behaves the same as 0, disallowing any trailing
|
|
|
|
spaces.
|
2015-04-14 09:07:25 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
By default, this rule will not trigger when the allowed number of spaces is
|
|
|
|
used, even when it doesn't create a hard break (for example, at the end of a
|
|
|
|
paragraph). To report such instances as well, set the `strict` parameter to
|
|
|
|
`true`.
|
2019-12-09 22:05:57 -08:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
Text text text
|
|
|
|
text[2 spaces]
|
|
|
|
```
|
|
|
|
|
2017-05-11 21:44:41 -07:00
|
|
|
Using spaces to indent blank lines inside a list item is usually not necessary,
|
|
|
|
but some parsers require it. Set the `list_item_empty_lines` parameter to `true`
|
2019-12-09 22:05:57 -08:00
|
|
|
to allow this (even when `strict` is `true`):
|
2017-05-11 21:44:41 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
- list item text
|
2018-04-30 21:34:19 -07:00
|
|
|
[2 spaces]
|
2018-03-09 22:50:01 -08:00
|
|
|
list item text
|
|
|
|
```
|
2017-05-11 21:44:41 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Except when being used to create a line break, trailing whitespace
|
|
|
|
has no purpose and does not affect the rendering of content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md010"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD010` - Hard tabs
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `hard_tab`, `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-hard-tabs`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `code_blocks`: Include code blocks (`boolean`, default `true`)
|
|
|
|
- `ignore_code_languages`: Fenced code languages to ignore (`string[]`, default
|
2022-11-05 17:34:37 -07:00
|
|
|
`[]`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `spaces_per_tab`: Number of spaces for each hard tab (`integer`, default `1`)
|
2016-09-29 21:25:10 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered by any lines that contain hard tab characters instead
|
|
|
|
of using spaces for indentation. To fix this, replace any hard tab characters
|
|
|
|
with spaces instead.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2020-09-06 16:31:26 -07:00
|
|
|
<!-- markdownlint-disable no-hard-tabs -->
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
* hard tab character used to indent the list item
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
Corrected example:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
* Spaces used to indent the list item instead
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2021-12-17 17:24:00 -08:00
|
|
|
You have the option to exclude this rule for code blocks and spans. To do so,
|
|
|
|
set the `code_blocks` parameter to `false`. Code blocks and spans are included
|
|
|
|
by default since handling of tabs by Markdown tools can be inconsistent (e.g.,
|
|
|
|
using 4 vs. 8 spaces).
|
|
|
|
|
2022-04-28 21:09:06 -07:00
|
|
|
When code blocks are scanned (e.g., by default or if `code_blocks` is `true`),
|
|
|
|
the `ignore_code_languages` parameter can be set to a list of languages that
|
|
|
|
should be ignored (i.e., hard tabs will be allowed, though not required). This
|
|
|
|
makes it easier for documents to include code for languages that require hard
|
|
|
|
tabs.
|
|
|
|
|
2021-12-17 17:24:00 -08:00
|
|
|
By default, violations of this rule are fixed by replacing the tab with 1 space
|
|
|
|
character. To use a different number of spaces, set the `spaces_per_tab`
|
|
|
|
parameter to the desired value.
|
2021-04-09 16:33:01 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Hard tabs are often rendered inconsistently by different editors and
|
|
|
|
can be harder to work with than spaces.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md011"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD011` - Reversed link syntax
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `links`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-reversed-links`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when text that appears to be a link is encountered, but
|
|
|
|
where the syntax appears to have been reversed (the `[]` and `()` are
|
|
|
|
reversed):
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
(Incorrect link syntax)[https://www.example.com/]
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this, swap the `[]` and `()` around:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
[Correct link syntax](https://www.example.com/)
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
Note: [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra)-style
|
|
|
|
footnotes do not trigger this rule:
|
2016-06-24 23:13:00 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
For (example)[^1]
|
|
|
|
```
|
2016-06-24 23:13:00 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Reversed links are not rendered as usable links.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md012"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD012` - Multiple consecutive blank lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blank_lines`, `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-multiple-blanks`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `maximum`: Consecutive blank lines (`integer`, default `1`)
|
2016-10-03 21:42:44 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when there are multiple consecutive blank lines in the
|
|
|
|
document:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text here
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some more text here
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this, delete the offending lines:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text here
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some more text here
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
Note: this rule will not be triggered if there are multiple consecutive blank
|
|
|
|
lines inside code blocks.
|
|
|
|
|
2016-10-03 21:42:44 -07:00
|
|
|
Note: The `maximum` parameter can be used to configure the maximum number of
|
|
|
|
consecutive blank lines.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Except in a code block, blank lines serve no purpose and do not
|
|
|
|
affect the rendering of content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md013"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD013` - Line length
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `line_length`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `line-length`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2018-03-19 23:39:42 +01:00
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `code_block_line_length`: Number of characters for code blocks (`integer`,
|
2022-11-05 17:34:37 -07:00
|
|
|
default `80`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `code_blocks`: Include code blocks (`boolean`, default `true`)
|
|
|
|
- `heading_line_length`: Number of characters for headings (`integer`, default
|
2022-11-05 17:34:37 -07:00
|
|
|
`80`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `headings`: Include headings (`boolean`, default `true`)
|
|
|
|
- `line_length`: Number of characters (`integer`, default `80`)
|
|
|
|
- `stern`: Stern length checking (`boolean`, default `false`)
|
|
|
|
- `strict`: Strict length checking (`boolean`, default `false`)
|
|
|
|
- `tables`: Include tables (`boolean`, default `true`)
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when there are lines that are longer than the
|
2019-03-26 22:34:19 -07:00
|
|
|
configured `line_length` (default: 80 characters). To fix this, split the line
|
|
|
|
up into multiple lines. To set a different maximum length for headings, use
|
2019-06-07 19:57:15 -07:00
|
|
|
`heading_line_length`. To set a different maximum length for code blocks, use
|
|
|
|
`code_block_line_length`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-03-22 14:06:29 -07:00
|
|
|
This rule has an exception when there is no whitespace beyond the configured
|
2022-11-08 21:40:33 -08:00
|
|
|
line length. This allows you to include items such as long URLs without being
|
|
|
|
forced to break them in the middle. To disable this exception, set the `strict`
|
|
|
|
parameter to `true` and an issue will be reported when any line is too long. To
|
|
|
|
warn for lines that are too long and could be fixed but allow long lines
|
|
|
|
without spaces, set the `stern` parameter to `true`.
|
2020-03-22 14:06:29 -07:00
|
|
|
|
|
|
|
For example (assuming normal behavior):
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
IF THIS LINE IS THE MAXIMUM LENGTH
|
|
|
|
This line is okay because there are-no-spaces-beyond-that-length
|
2024-03-19 21:46:34 -07:00
|
|
|
This line is a violation because there are spaces beyond that length
|
|
|
|
This-line-is-okay-because-there-are-no-spaces-anywhere-within
|
2020-03-22 14:06:29 -07:00
|
|
|
```
|
|
|
|
|
2024-03-19 21:46:34 -07:00
|
|
|
In `strict` mode, the last three lines above are all violations. In `stern`
|
|
|
|
mode, the middle two lines above are both violations, but the last is okay.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
You have the option to exclude this rule for code blocks, tables, or headings.
|
|
|
|
To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
|
2016-01-09 22:20:36 -08:00
|
|
|
|
|
|
|
Code blocks are included in this rule by default since it is often a
|
|
|
|
requirement for document readability, and tentatively compatible with code
|
|
|
|
rules. Still, some languages do not lend themselves to short lines.
|
|
|
|
|
2024-03-19 21:46:34 -07:00
|
|
|
Lines with link/image reference definitions and standalone lines (i.e., not part
|
|
|
|
of a paragraph) with only a link/image (possibly using (strong) emphasis) are
|
|
|
|
always exempted from this rule (even in `strict` mode) because there is often no
|
|
|
|
way to split such lines without breaking the URL.
|
2022-11-08 21:40:33 -08:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Extremely long lines can be difficult to work with in some editors.
|
|
|
|
More information: <https://cirosantilli.com/markdown-style-guide#line-wrapping>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md014"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD014` - Dollar signs used before commands without showing output
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `commands-show-output`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when there are code blocks showing shell commands to be
|
2020-01-18 21:28:42 -08:00
|
|
|
typed, and *all* of the shell commands are preceded by dollar signs ($):
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-09-06 16:31:26 -07:00
|
|
|
<!-- markdownlint-disable commands-show-output -->
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
$ ls
|
|
|
|
$ cat foo
|
|
|
|
$ less bar
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2020-01-18 21:28:42 -08:00
|
|
|
The dollar signs are unnecessary in this situation, and should not be
|
2015-03-12 23:42:06 -07:00
|
|
|
included:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
ls
|
|
|
|
cat foo
|
|
|
|
less bar
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-18 21:28:42 -08:00
|
|
|
Showing output for commands preceded by dollar signs does not trigger this rule:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
$ ls
|
|
|
|
foo bar
|
|
|
|
$ cat foo
|
|
|
|
Hello world
|
|
|
|
$ cat bar
|
|
|
|
baz
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-18 21:28:42 -08:00
|
|
|
Because some commands do not produce output, it is not a violation if *some*
|
|
|
|
commands do not have output:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
$ mkdir test
|
|
|
|
mkdir: created directory 'test'
|
|
|
|
$ ls test
|
|
|
|
```
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: It is easier to copy/paste and less noisy if the dollar signs
|
2015-03-12 23:42:06 -07:00
|
|
|
are omitted when they are not needed. See
|
2020-01-18 21:28:42 -08:00
|
|
|
<https://cirosantilli.com/markdown-style-guide#dollar-signs-in-shell-code>
|
2015-03-12 23:42:06 -07:00
|
|
|
for more information.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md018"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD018` - No space after hash on atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `atx`, `headings`, `spaces`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-missing-space-atx`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when spaces are missing after the hash characters
|
2018-03-19 23:39:42 +01:00
|
|
|
in an atx style heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
#Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
##Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, separate the heading text from the hash character by a single
|
2015-03-12 23:42:06 -07:00
|
|
|
space:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Violations of this rule can lead to improperly rendered content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md019"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD019` - Multiple spaces after hash on atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `atx`, `headings`, `spaces`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-multiple-space-atx`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when more than one space is used to separate the
|
2018-03-19 23:39:42 +01:00
|
|
|
heading text from the hash characters in an atx style heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, separate the heading text from the hash character by a single
|
2015-03-12 23:42:06 -07:00
|
|
|
space:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Extra space has no purpose and does not affect the rendering of
|
|
|
|
content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md020"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD020` - No space inside hashes on closed atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `atx_closed`, `headings`, `spaces`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-missing-space-closed-atx`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when spaces are missing inside the hash characters
|
2018-03-19 23:39:42 +01:00
|
|
|
in a closed atx style heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
#Heading 1#
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
##Heading 2##
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, separate the heading text from the hash character by a single
|
2015-03-12 23:42:06 -07:00
|
|
|
space:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1 #
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2 ##
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Note: this rule will fire if either side of the heading is missing spaces.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Violations of this rule can lead to improperly rendered content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md021"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD021` - Multiple spaces inside hashes on closed atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `atx_closed`, `headings`, `spaces`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-multiple-space-closed-atx`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when more than one space is used to separate the
|
2018-03-19 23:39:42 +01:00
|
|
|
heading text from the hash characters in a closed atx style heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1 #
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2 ##
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, separate the heading text from the hash character by a single
|
2015-03-12 23:42:06 -07:00
|
|
|
space:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1 #
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2 ##
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Note: this rule will fire if either side of the heading contains multiple
|
2015-03-12 23:42:06 -07:00
|
|
|
spaces.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Extra space has no purpose and does not affect the rendering of
|
|
|
|
content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md022"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD022` - Headings should be surrounded by blank lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `blank_lines`, `headings`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `blanks-around-headings`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2023-08-08 22:56:47 -07:00
|
|
|
- `lines_above`: Blank lines above heading (`integer|integer[]`, default `1`)
|
|
|
|
- `lines_below`: Blank lines below heading (`integer|integer[]`, default `1`)
|
2019-03-24 21:50:56 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
This rule is triggered when headings (any style) are either not preceded or not
|
2019-03-24 21:50:56 -07:00
|
|
|
followed by at least one blank line:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2018-03-09 22:50:01 -08:00
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some more text
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, ensure that all headings have a blank line both before and after
|
|
|
|
(except where the heading is at the beginning or end of the document):
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading 1
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some more text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading 2
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
The `lines_above` and `lines_below` parameters can be used to specify a
|
2023-08-08 22:56:47 -07:00
|
|
|
different number of blank lines (including `0`) above or below each heading.
|
|
|
|
If the value `-1` is used for either parameter, any number of blank lines is
|
|
|
|
allowed. To customize the number of lines above or below each heading level
|
|
|
|
individually, specify a `number[]` where values correspond to heading levels
|
|
|
|
1-6 (in order).
|
|
|
|
|
|
|
|
Notes: If `lines_above` or `lines_below` are configured to require more than one
|
|
|
|
blank line, [MD012/no-multiple-blanks](md012.md) should also be customized. This
|
|
|
|
rule checks for *at least* as many blank lines as specified; any extra blank
|
|
|
|
lines are ignored.
|
2019-03-24 21:50:56 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Rationale: Aside from aesthetic reasons, some parsers, including `kramdown`,
|
|
|
|
will not parse headings that don't have a blank line before, and will parse them
|
|
|
|
as regular text.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md023"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD023` - Headings must start at the beginning of the line
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`, `spaces`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `heading-start-left`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
This rule is triggered when a heading is indented by one or more spaces:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
# Indented heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, ensure that all headings start at the beginning of the line:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
# Heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-10-23 20:37:38 -07:00
|
|
|
Note that scenarios like block quotes "indent" the start of the line, so the
|
|
|
|
following is also correct:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
> # Heading in Block Quote
|
|
|
|
```
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Rationale: Headings that don't start at the beginning of the line will not be
|
|
|
|
parsed as headings, and will instead appear as regular text.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md024"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD024` - Multiple headings with the same content
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `no-duplicate-heading`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `siblings_only`: Only check sibling headings (`boolean`, default `false`)
|
2018-07-19 21:49:30 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
This rule is triggered if there are multiple headings in the document that have
|
2015-03-12 23:42:06 -07:00
|
|
|
the same text:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
## Some text
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To fix this, ensure that the content of each heading is different:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
## Some more text
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-12-05 19:23:17 -08:00
|
|
|
If the parameter `siblings_only` is set to `true`, duplication is allowed for
|
|
|
|
headings with different parents (as is common in changelogs):
|
2018-07-19 21:49:30 -07:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Change log
|
|
|
|
|
|
|
|
## 1.0.0
|
|
|
|
|
|
|
|
### Features
|
|
|
|
|
|
|
|
## 2.0.0
|
|
|
|
|
|
|
|
### Features
|
|
|
|
```
|
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
Rationale: Some Markdown parsers generate anchors for headings based on the
|
2020-01-20 15:10:17 -08:00
|
|
|
heading name; headings with the same content can cause problems with that.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md025"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD025` - Multiple top-level headings in the same document
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `single-h1`, `single-title`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `front_matter_title`: RegExp for matching title in front matter (`string`,
|
2022-11-05 17:34:37 -07:00
|
|
|
default `^\s*title\s*[:=]`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `level`: Heading level (`integer`, default `1`)
|
2016-07-04 23:23:29 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
This rule is triggered when a top-level heading is in use (the first line of
|
|
|
|
the file is an h1 heading), and more than one h1 heading is in use in the
|
2015-03-12 23:42:06 -07:00
|
|
|
document:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Top level heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
# Another top-level heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
To fix, structure your document so there is a single h1 heading that is
|
|
|
|
the title for the document. Subsequent headings must be
|
|
|
|
lower-level headings (h2, h3, etc.):
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# Title
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## Another heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
|
|
|
cases where an h1 is added externally.
|
2016-07-04 23:23:29 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
|
|
|
contains a `title` property (commonly used with blog posts), this rule treats
|
|
|
|
that as a top level heading and will report a violation for any subsequent
|
|
|
|
top-level headings. To use a different property name in the front matter,
|
|
|
|
specify the text of a regular expression via the `front_matter_title` parameter.
|
|
|
|
To disable the use of front matter by this rule, specify `""` for
|
|
|
|
`front_matter_title`.
|
2019-03-16 20:21:57 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Rationale: A top-level heading is an h1 on the first line of the file, and
|
2020-01-20 15:10:17 -08:00
|
|
|
serves as the title for the document. If this convention is in use, then there
|
2022-11-05 17:34:37 -07:00
|
|
|
can not be more than one title for the document, and the entire document should
|
|
|
|
be contained within this heading.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md026"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD026` - Trailing punctuation in heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-trailing-punctuation`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2023-07-29 15:20:10 -07:00
|
|
|
- `punctuation`: Punctuation characters (`string`, default `.,;:!。,;:!`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2019-07-26 23:03:56 -07:00
|
|
|
This rule is triggered on any heading that has one of the specified normal or
|
|
|
|
full-width punctuation characters as the last character in the line:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# This is a heading.
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-07-26 23:03:56 -07:00
|
|
|
To fix this, remove the trailing punctuation:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# This is a heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-07-26 23:03:56 -07:00
|
|
|
Note: The `punctuation` parameter can be used to specify what characters count
|
|
|
|
as punctuation at the end of a heading. For example, you can change it to
|
2020-12-30 16:45:15 -08:00
|
|
|
`".,;:"` to allow headings that end with an exclamation point. `?` is
|
2022-11-05 17:34:37 -07:00
|
|
|
allowed by default because of how common it is in headings of FAQ-style
|
|
|
|
documents. Setting the `punctuation` parameter to `""` allows all characters -
|
|
|
|
and is equivalent to disabling the rule.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Note: The trailing semicolon of [HTML entity references][html-entity-references]
|
2020-11-23 15:23:39 -08:00
|
|
|
like `©`, `©`, and `©` is ignored by this rule.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Headings are not meant to be full sentences. More information:
|
2022-11-05 17:34:37 -07:00
|
|
|
[Punctuation at the end of headers][end-punctuation].
|
|
|
|
|
|
|
|
[end-punctuation]: https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers
|
|
|
|
[html-entity-references]: https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md027"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD027` - Multiple spaces after blockquote symbol
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blockquote`, `indentation`, `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-multiple-space-blockquote`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when blockquotes have more than one space after the
|
|
|
|
blockquote (`>`) symbol:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2020-12-28 13:28:38 -08:00
|
|
|
> This is a blockquote with bad indentation
|
2018-03-09 22:50:01 -08:00
|
|
|
> there should only be one.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix, remove any extraneous space:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
> This is a blockquote with correct
|
|
|
|
> indentation.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md028"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD028` - Blank line inside blockquote
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blockquote`, `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-blanks-blockquote`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when two blockquote blocks are separated by nothing
|
|
|
|
except for a blank line:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
> This is a blockquote
|
|
|
|
> which is immediately followed by
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
> this blockquote. Unfortunately
|
|
|
|
> In some parsers, these are treated as the same blockquote.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this, ensure that any blockquotes that are right next to each other
|
|
|
|
have some text in between:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
> This is a blockquote.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
And Jimmy also said:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
> This too is a blockquote.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
Alternatively, if they are supposed to be the same quote, then add the
|
|
|
|
blockquote symbol at the beginning of the blank line:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
> This is a blockquote.
|
|
|
|
>
|
|
|
|
> This is the same blockquote.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
Rationale: Some Markdown parsers will treat two blockquotes separated by one
|
2015-03-12 23:42:06 -07:00
|
|
|
or more blank lines as the same blockquote, while others will treat them as
|
|
|
|
separate blockquotes.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md029"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD029` - Ordered list item prefix
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `ol`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `ol-prefix`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: List style (`string`, default `one_or_ordered`, values `one` /
|
2022-11-05 17:34:37 -07:00
|
|
|
`one_or_ordered` / `ordered` / `zero`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-03-06 21:57:19 -08:00
|
|
|
This rule is triggered for ordered lists that do not either start with '1.' or
|
2015-03-12 23:42:06 -07:00
|
|
|
do not have a prefix that increases in numerical order (depending on the
|
2020-12-28 13:28:38 -08:00
|
|
|
configured style). The less-common pattern of using '0.' as a first prefix or
|
2020-03-18 21:50:10 -07:00
|
|
|
for all prefixes is also supported.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
Example valid list if the style is configured as 'one':
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
1. Do this.
|
|
|
|
1. Do that.
|
|
|
|
1. Done.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-03-18 21:50:10 -07:00
|
|
|
Examples of valid lists if the style is configured as 'ordered':
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
1. Do this.
|
|
|
|
2. Do that.
|
|
|
|
3. Done.
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-03-18 21:50:10 -07:00
|
|
|
```markdown
|
|
|
|
0. Do this.
|
|
|
|
1. Do that.
|
|
|
|
2. Done.
|
|
|
|
```
|
|
|
|
|
|
|
|
All three examples are valid when the style is configured as 'one_or_ordered'.
|
2017-12-12 22:41:11 -08:00
|
|
|
|
2019-03-06 21:57:19 -08:00
|
|
|
Example valid list if the style is configured as 'zero':
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
0. Do this.
|
|
|
|
0. Do that.
|
|
|
|
0. Done.
|
|
|
|
```
|
|
|
|
|
2017-12-12 22:41:11 -08:00
|
|
|
Example invalid list for all styles:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
1. Do this.
|
|
|
|
3. Done.
|
|
|
|
```
|
2017-12-12 22:41:11 -08:00
|
|
|
|
2018-06-15 22:37:12 -07:00
|
|
|
This rule supports 0-prefixing ordered list items for uniform indentation:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
...
|
|
|
|
08. Item
|
|
|
|
09. Item
|
|
|
|
10. Item
|
|
|
|
11. Item
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
Note: This rule will report violations for cases like the following where an
|
|
|
|
improperly-indented code block (or similar) appears between two list items and
|
|
|
|
"breaks" the list in two:
|
2020-09-06 16:31:26 -07:00
|
|
|
|
|
|
|
<!-- markdownlint-disable code-fence-style -->
|
2020-03-05 11:41:59 -08:00
|
|
|
|
|
|
|
~~~markdown
|
|
|
|
1. First list
|
|
|
|
|
|
|
|
```text
|
|
|
|
Code block
|
|
|
|
```
|
|
|
|
|
|
|
|
1. Second list
|
|
|
|
~~~
|
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
The fix is to indent the code block so it becomes part of the preceding list
|
|
|
|
item as intended:
|
2020-03-05 11:41:59 -08:00
|
|
|
|
|
|
|
~~~markdown
|
|
|
|
1. First list
|
|
|
|
|
|
|
|
```text
|
|
|
|
Code block
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Still first list
|
|
|
|
~~~
|
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md030"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD030` - Spaces after list markers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `ol`, `ul`, `whitespace`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `list-marker-space`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `ol_multi`: Spaces for multi-line ordered list items (`integer`, default `1`)
|
|
|
|
- `ol_single`: Spaces for single-line ordered list items (`integer`, default
|
2022-11-05 17:34:37 -07:00
|
|
|
`1`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `ul_multi`: Spaces for multi-line unordered list items (`integer`, default
|
2022-11-05 17:34:37 -07:00
|
|
|
`1`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `ul_single`: Spaces for single-line unordered list items (`integer`, default
|
2022-11-05 17:34:37 -07:00
|
|
|
`1`)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule checks for the number of spaces between a list marker (e.g. '`-`',
|
|
|
|
'`*`', '`+`' or '`1.`') and the text of the list item.
|
|
|
|
|
|
|
|
The number of spaces checked for depends on the document style in use, but the
|
|
|
|
default is 1 space after any list marker:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Foo
|
|
|
|
* Bar
|
|
|
|
* Baz
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
1. Foo
|
|
|
|
1. Bar
|
|
|
|
1. Baz
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
1. Foo
|
|
|
|
* Bar
|
|
|
|
1. Baz
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
A document style may change the number of spaces after unordered list items
|
|
|
|
and ordered list items independently, as well as based on whether the content
|
2020-12-28 13:28:38 -08:00
|
|
|
of every item in the list consists of a single paragraph or multiple
|
2015-03-12 23:42:06 -07:00
|
|
|
paragraphs (including sub-lists and code blocks).
|
|
|
|
|
|
|
|
For example, the style guide at
|
2020-01-18 21:28:42 -08:00
|
|
|
<https://cirosantilli.com/markdown-style-guide#spaces-after-list-marker>
|
2015-03-12 23:42:06 -07:00
|
|
|
specifies that 1 space after the list marker should be used if every item in
|
|
|
|
the list fits within a single paragraph, but to use 2 or 3 spaces (for ordered
|
|
|
|
and unordered lists respectively) if there are multiple paragraphs of content
|
|
|
|
inside the list:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Foo
|
|
|
|
* Bar
|
|
|
|
* Baz
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
vs.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
* Foo
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Second paragraph
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
* Bar
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
or
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
1. Foo
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Second paragraph
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
1. Bar
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
To fix this, ensure the correct number of spaces are used after the list marker
|
2015-03-12 23:42:06 -07:00
|
|
|
for your selected document style.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Violations of this rule can lead to improperly rendered content.
|
|
|
|
|
2021-08-13 22:18:39 -07:00
|
|
|
Note: See [Prettier.md](Prettier.md) for compatibility information.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md031"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD031` - Fenced code blocks should be surrounded by blank lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blank_lines`, `code`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `blanks-around-fences`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `list_items`: Include list items (`boolean`, default `true`)
|
2019-08-02 22:58:41 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when fenced code blocks are either not preceded or not
|
|
|
|
followed by a blank line:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
````markdown
|
|
|
|
Some text
|
|
|
|
```
|
|
|
|
Code block
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
|
|
|
Another code block
|
|
|
|
```
|
|
|
|
Some more text
|
|
|
|
````
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this, ensure that all fenced code blocks have a blank line both before
|
|
|
|
and after (except where the block is at the beginning or end of the document):
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
````markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
|
|
|
Code block
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
|
|
|
Another code block
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Some more text
|
|
|
|
````
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-08-02 22:58:41 -07:00
|
|
|
Set the `list_items` parameter to `false` to disable this rule for list items.
|
|
|
|
Disabling this behavior for lists can be useful if it is necessary to create a
|
|
|
|
[tight](https://spec.commonmark.org/0.29/#tight) list containing a code fence.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
|
|
|
|
not parse fenced code blocks that don't have blank lines before and after them.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md032"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD032` - Lists should be surrounded by blank lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blank_lines`, `bullet`, `ol`, `ul`
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `blanks-around-lists`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
This rule is triggered when lists (of any kind) are either not preceded or not
|
|
|
|
followed by a blank line:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2023-09-14 20:59:24 -07:00
|
|
|
* List item
|
|
|
|
* List item
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
1. List item
|
|
|
|
2. List item
|
|
|
|
***
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
In the first case above, text immediately precedes the unordered list. In the
|
|
|
|
second case above, a thematic break immediately follows the ordered list. To fix
|
|
|
|
violations of this rule, ensure that all lists have a blank line both before and
|
|
|
|
after (except when the list is at the very beginning or end of the document):
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some text
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
* List item
|
|
|
|
* List item
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
1. List item
|
|
|
|
2. List item
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
***
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2023-09-14 20:59:24 -07:00
|
|
|
Note that the following case is **not** a violation of this rule:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
1. List item
|
|
|
|
More item 1
|
|
|
|
2. List item
|
|
|
|
More item 2
|
|
|
|
```
|
|
|
|
|
|
|
|
Although it is not indented, the text "More item 2" is referred to as a
|
|
|
|
[lazy continuation line][lazy-continuation] and considered part of the second
|
|
|
|
list item.
|
|
|
|
|
|
|
|
Rationale: In addition to aesthetic reasons, some parsers, including kramdown,
|
|
|
|
will not parse lists that don't have blank lines before and after them.
|
|
|
|
|
|
|
|
[lazy-continuation]: https://spec.commonmark.org/0.30/#lazy-continuation-line
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md033"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD033` - Inline HTML
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `html`
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-inline-html`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `allowed_elements`: Allowed elements (`string[]`, default `[]`)
|
2015-12-15 21:30:37 -08:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
This rule is triggered whenever raw HTML is used in a Markdown document:
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
<h1>Inline HTML heading</h1>
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
To fix this, use 'pure' Markdown instead of including raw HTML:
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# Markdown heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-13 08:47:15 -07:00
|
|
|
|
2022-08-02 20:36:47 -07:00
|
|
|
Note: To allow specific HTML elements, use the `allowed_elements` parameter.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
Rationale: Raw HTML is allowed in Markdown, but this rule is included for
|
|
|
|
those who want their documents to only include "pure" Markdown, or for those
|
|
|
|
who are rendering Markdown documents into something other than HTML.
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md034"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD034` - Bare URL used
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `links`, `url`
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-bare-urls`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2023-02-05 16:58:06 -08:00
|
|
|
This rule is triggered whenever a URL or email address appears without
|
|
|
|
surrounding angle brackets:
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2023-02-05 16:58:06 -08:00
|
|
|
For more info, visit https://www.example.com/ or email user@example.com.
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2023-02-05 16:58:06 -08:00
|
|
|
To fix this, add angle brackets around the URL or email address:
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2023-02-05 16:58:06 -08:00
|
|
|
For more info, visit <https://www.example.com/> or email <user@example.com>.
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2024-05-19 22:34:17 -07:00
|
|
|
If a URL or email address contains non-ASCII characters, it may be not be
|
|
|
|
handled as intended even when angle brackets are present. In such cases,
|
|
|
|
[percent-encoding](https://en.m.wikipedia.org/wiki/Percent-encoding) can be used
|
|
|
|
to comply with the required syntax for URL and email.
|
|
|
|
|
2023-02-05 16:58:06 -08:00
|
|
|
Note: To include a bare URL or email without it being converted into a link,
|
|
|
|
wrap it in a code span:
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2023-02-05 16:58:06 -08:00
|
|
|
Not a clickable link: `https://www.example.com`
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2023-02-05 16:58:06 -08:00
|
|
|
Note: The following scenario does not trigger this rule because it could be a
|
2023-02-06 21:09:58 -08:00
|
|
|
shortcut link:
|
2020-04-01 20:21:36 -07:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
[https://www.example.com]
|
|
|
|
```
|
|
|
|
|
2023-02-06 21:09:58 -08:00
|
|
|
Note: The following syntax triggers this rule because the nested link could be
|
|
|
|
a shortcut link (which takes precedence):
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[text [shortcut] text](https://example.com)
|
|
|
|
```
|
|
|
|
|
|
|
|
To avoid this, escape both inner brackets:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[link \[text\] link](https://example.com)
|
|
|
|
```
|
|
|
|
|
2023-02-05 16:58:06 -08:00
|
|
|
Rationale: Without angle brackets, a bare URL or email isn't converted into a
|
|
|
|
link by some Markdown parsers.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md035"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD035` - Horizontal rule style
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `hr`
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `hr-style`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: Horizontal rule style (`string`, default `consistent`)
|
2015-04-14 09:40:16 -07:00
|
|
|
|
|
|
|
This rule is triggered when inconsistent styles of horizontal rules are used
|
|
|
|
in the document:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
---
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
- - -
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
***
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
* * *
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
****
|
|
|
|
```
|
2015-04-14 09:40:16 -07:00
|
|
|
|
|
|
|
To fix this, ensure any horizontal rules used in the document are consistent,
|
|
|
|
or match the given style if the rule is so configured:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
---
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
---
|
|
|
|
```
|
2015-04-14 09:40:16 -07:00
|
|
|
|
|
|
|
Note: by default, this rule is configured to just require that all horizontal
|
2020-12-28 13:28:38 -08:00
|
|
|
rules in the document are the same and will trigger if any of the horizontal
|
2015-04-14 09:40:16 -07:00
|
|
|
rules are different than the first one encountered in the document. If you
|
|
|
|
want to configure the rule to match a specific style, the parameter given to
|
|
|
|
the 'style' option is a string containing the exact horizontal rule text that
|
|
|
|
is allowed.
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md036"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD036` - Emphasis used instead of a heading
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `emphasis`, `headings`
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `no-emphasis-as-heading`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `punctuation`: Punctuation characters (`string`, default `.,;:!?。,;:!?`)
|
2016-09-24 16:15:54 -07:00
|
|
|
|
2015-04-14 22:37:56 -07:00
|
|
|
This check looks for instances where emphasized (i.e. bold or italic) text is
|
2018-03-19 23:39:42 +01:00
|
|
|
used to separate sections, where a heading should be used instead:
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
**My document**
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Lorem ipsum dolor sit amet...
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
_Another section_
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Consectetur adipiscing elit, sed do eiusmod.
|
|
|
|
```
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2022-03-08 10:42:14 +05:30
|
|
|
To fix this, use Markdown headings instead of emphasized text to denote
|
2015-04-14 22:37:56 -07:00
|
|
|
sections:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# My document
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Lorem ipsum dolor sit amet...
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
## Another section
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Consectetur adipiscing elit, sed do eiusmod.
|
|
|
|
```
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Note: This rule looks for single-line paragraphs that consist entirely
|
2019-06-06 22:21:31 -07:00
|
|
|
of emphasized text. It won't fire on emphasis used within regular text,
|
|
|
|
multi-line emphasized paragraphs, or paragraphs ending in punctuation
|
|
|
|
(normal or full-width). Similarly to rule MD026, you can configure what
|
|
|
|
characters are recognized as punctuation.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Using emphasis instead of a heading prevents tools from inferring
|
|
|
|
the structure of a document. More information:
|
|
|
|
<https://cirosantilli.com/markdown-style-guide#emphasis-vs-headers>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md037"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD037` - Spaces inside emphasis markers
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `emphasis`, `whitespace`
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-space-in-emphasis`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-04-15 17:50:01 -07:00
|
|
|
This rule is triggered when emphasis markers (bold, italic) are used, but they
|
|
|
|
have spaces between the markers and the text:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Here is some ** bold ** text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some * italic * text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some more __ bold __ text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some more _ italic _ text.
|
|
|
|
```
|
2015-04-15 17:50:01 -07:00
|
|
|
|
|
|
|
To fix this, remove the spaces around the emphasis markers:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Here is some **bold** text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some *italic* text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some more __bold__ text.
|
2015-04-15 17:50:01 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
Here is some more _italic_ text.
|
|
|
|
```
|
2015-04-15 17:50:01 -07:00
|
|
|
|
|
|
|
Rationale: Emphasis is only parsed as such when the asterisks/underscores
|
2020-12-28 13:28:38 -08:00
|
|
|
aren't surrounded by spaces. This rule attempts to detect where
|
2015-04-15 17:50:01 -07:00
|
|
|
they were surrounded by spaces, but it appears that emphasized text was
|
|
|
|
intended by the author.
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md038"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD038` - Spaces inside code span elements
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`, `whitespace`
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-space-in-code`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2020-04-06 20:43:38 -07:00
|
|
|
This rule is triggered for code span elements that have spaces adjacent to the
|
2015-04-15 18:24:42 -07:00
|
|
|
backticks:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
`some text `
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
` some text`
|
|
|
|
```
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2020-04-06 20:43:38 -07:00
|
|
|
To fix this, remove any spaces adjacent to the backticks:
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
`some text`
|
|
|
|
```
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2020-04-06 20:43:38 -07:00
|
|
|
Note: A single leading and trailing space is allowed by the specification and
|
2022-12-08 22:07:10 -08:00
|
|
|
automatically trimmed (in order to allow for code spans that embed backticks):
|
2020-04-06 20:43:38 -07:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
`` `backticks` ``
|
|
|
|
```
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Note: A single leading or trailing space is allowed if used to separate code
|
2022-12-08 22:07:10 -08:00
|
|
|
span markers from an embedded backtick (though the space is not trimmed):
|
2017-02-18 22:56:06 -08:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
`` ` embedded backtick``
|
|
|
|
```
|
2017-02-18 22:56:06 -08:00
|
|
|
|
2022-12-08 22:07:10 -08:00
|
|
|
Rationale: Violations of this rule are usually unintentional and may lead to
|
|
|
|
improperly-rendered content. If spaces beside backticks are intentional, this
|
|
|
|
rule can be disabled for that line or file.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md039"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD039` - Spaces inside link text
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `links`, `whitespace`
|
2015-04-15 18:24:42 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-space-in-links`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2015-04-15 18:24:42 -07:00
|
|
|
This rule is triggered on links that have spaces surrounding the link text:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
[ a link ](https://www.example.com/)
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-15 18:24:42 -07:00
|
|
|
|
|
|
|
To fix this, remove the spaces surrounding the link text:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
[a link](https://www.example.com/)
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-16 09:13:56 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md040"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD040` - Fenced code blocks should have a language specified
|
2015-04-16 09:13:56 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`, `language`
|
2015-04-16 09:13:56 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `fenced-code-language`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `allowed_languages`: List of languages (`string[]`, default `[]`)
|
|
|
|
- `language_only`: Require language only (`boolean`, default `false`)
|
2022-10-18 03:29:29 +08:00
|
|
|
|
2015-04-16 09:13:56 -07:00
|
|
|
This rule is triggered when fenced code blocks are used, but a language isn't
|
|
|
|
specified:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
````markdown
|
|
|
|
```
|
|
|
|
#!/bin/bash
|
|
|
|
echo Hello world
|
|
|
|
```
|
|
|
|
````
|
2015-04-16 09:13:56 -07:00
|
|
|
|
|
|
|
To fix this, add a language specifier to the code block:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
````markdown
|
|
|
|
```bash
|
|
|
|
#!/bin/bash
|
|
|
|
echo Hello world
|
|
|
|
```
|
|
|
|
````
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2021-03-09 13:00:04 -08:00
|
|
|
To display a code block without syntax highlighting, use:
|
|
|
|
|
|
|
|
````markdown
|
|
|
|
```text
|
|
|
|
Plain text in a code block
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
2022-10-18 03:29:29 +08:00
|
|
|
You can configure the `allowed_languages` parameter to specify a list of
|
2022-11-06 01:41:27 +01:00
|
|
|
languages code blocks could use. Languages are case sensitive. The default value
|
|
|
|
is `[]` which means any language specifier is valid.
|
2022-10-18 03:29:29 +08:00
|
|
|
|
2022-11-11 07:07:04 +01:00
|
|
|
You can prevent extra data from being present in the info string of fenced code
|
|
|
|
blocks. To do so, set the `language_only` parameter to `true`.
|
|
|
|
|
|
|
|
<!-- markdownlint-disable-next-line no-space-in-code -->
|
|
|
|
Info strings with leading/trailing whitespace (ex: `js `) or other content (ex:
|
|
|
|
`ruby startline=3`) will trigger this rule.
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Specifying a language improves content rendering by using the
|
|
|
|
correct syntax highlighting for code. More information:
|
|
|
|
<https://cirosantilli.com/markdown-style-guide#option-code-fenced>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md041"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD041` - First line in a file should be a top-level heading
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `first-line-h1`, `first-line-heading`
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `front_matter_title`: RegExp for matching title in front matter (`string`,
|
2022-11-05 17:34:37 -07:00
|
|
|
default `^\s*title\s*[:=]`)
|
2022-11-13 20:53:10 -08:00
|
|
|
- `level`: Heading level (`integer`, default `1`)
|
2016-07-04 23:23:29 -07:00
|
|
|
|
2019-03-10 22:10:33 -07:00
|
|
|
This rule is intended to ensure documents have a title and is triggered when
|
2020-12-28 13:28:38 -08:00
|
|
|
the first line in the file isn't a top-level (h1) heading:
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
This is a file without a heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
To fix this, add a top-level heading to the beginning of the file:
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2018-03-19 23:39:42 +01:00
|
|
|
# File with heading
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
This is a file with a top-level heading
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2016-06-27 22:19:02 -07:00
|
|
|
|
2021-01-31 15:48:00 -08:00
|
|
|
Because it is common for projects on GitHub to use an image for the heading of
|
|
|
|
`README.md` and that is not well-supported by Markdown, HTML headings are also
|
|
|
|
permitted by this rule. For example:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
<h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
|
|
|
|
|
|
|
|
This is a file with a top-level HTML heading
|
|
|
|
```
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
|
|
|
cases where an h1 is added externally.
|
2017-05-06 15:25:14 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
|
|
|
contains a `title` property (commonly used with blog posts), this rule will not
|
|
|
|
report a violation. To use a different property name in the front matter,
|
|
|
|
specify the text of a regular expression via the `front_matter_title` parameter.
|
2022-11-05 17:34:37 -07:00
|
|
|
To disable the use of front matter by this rule, specify `""` for
|
|
|
|
`front_matter_title`.
|
2016-07-04 23:23:29 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Rationale: The top-level heading often acts as the title of a document. More
|
2020-01-20 15:10:17 -08:00
|
|
|
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md042"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD042` - No empty links
|
2016-06-27 22:19:02 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `links`
|
2016-06-27 22:19:02 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-empty-links`
|
2016-06-27 22:19:02 -07:00
|
|
|
|
|
|
|
This rule is triggered when an empty link is encountered:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
[an empty link]()
|
|
|
|
```
|
2016-06-27 22:19:02 -07:00
|
|
|
|
|
|
|
To fix the violation, provide a destination for the link:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
[a valid link](https://example.com/)
|
|
|
|
```
|
2016-06-27 22:19:02 -07:00
|
|
|
|
|
|
|
Empty fragments will trigger this rule:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
[an empty fragment](#)
|
|
|
|
```
|
2016-06-27 22:19:02 -07:00
|
|
|
|
|
|
|
But non-empty fragments will not:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
[a valid fragment](#fragment)
|
|
|
|
```
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Rationale: Empty links do not lead anywhere and therefore don't function as
|
|
|
|
links.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md043"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD043` - Required heading structure
|
2018-03-19 23:39:42 +01:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `required-headings`
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `headings`: List of headings (`string[]`, default `[]`)
|
|
|
|
- `match_case`: Match case of headings (`boolean`, default `false`)
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
This rule is triggered when the headings in a file do not match the array of
|
|
|
|
headings passed to the rule. It can be used to enforce a standard heading
|
2016-07-02 22:37:52 -07:00
|
|
|
structure for a set of files.
|
|
|
|
|
|
|
|
To require exactly the following structure:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# Head
|
|
|
|
## Item
|
|
|
|
### Detail
|
|
|
|
```
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Set the `headings` parameter to:
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```json
|
|
|
|
[
|
|
|
|
"# Head",
|
|
|
|
"## Item",
|
|
|
|
"### Detail"
|
|
|
|
]
|
|
|
|
```
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
To allow optional headings as with the following structure:
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
# Head
|
|
|
|
## Item
|
|
|
|
### Detail (optional)
|
|
|
|
## Foot
|
|
|
|
### Notes (optional)
|
|
|
|
```
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2020-11-23 20:47:28 -08:00
|
|
|
Use the special value `"*"` meaning "zero or more unspecified headings" or the
|
|
|
|
special value `"+"` meaning "one or more unspecified headings" and set the
|
|
|
|
`headings` parameter to:
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```json
|
|
|
|
[
|
|
|
|
"# Head",
|
|
|
|
"## Item",
|
|
|
|
"*",
|
|
|
|
"## Foot",
|
|
|
|
"*"
|
|
|
|
]
|
|
|
|
```
|
2016-07-02 22:37:52 -07:00
|
|
|
|
|
|
|
When an error is detected, this rule outputs the line number of the first
|
2018-03-19 23:39:42 +01:00
|
|
|
problematic heading (otherwise, it outputs the last line number of the file).
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Note that while the `headings` parameter uses the "## Text" ATX heading style
|
|
|
|
for simplicity, a file may use any supported heading style.
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
By default, the case of headings in the document is not required to match that
|
|
|
|
of `headings`. To require that case match exactly, set the `match_case`
|
|
|
|
parameter to `true`.
|
2022-10-22 03:15:50 -04:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Projects may wish to enforce a consistent document structure across
|
|
|
|
a set of similar content.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md044"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD044` - Proper names should have the correct capitalization
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `spelling`
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `proper-names`
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `code_blocks`: Include code blocks (`boolean`, default `true`)
|
|
|
|
- `html_elements`: Include HTML elements (`boolean`, default `true`)
|
|
|
|
- `names`: List of proper names (`string[]`, default `[]`)
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2016-12-22 13:34:18 -08:00
|
|
|
This rule is triggered when any of the strings in the `names` array do not have
|
|
|
|
the specified capitalization. It can be used to enforce a standard letter case
|
|
|
|
for the names of projects and products.
|
|
|
|
|
|
|
|
For example, the language "JavaScript" is usually written with both the 'J' and
|
2022-11-05 17:34:37 -07:00
|
|
|
'S' capitalized - though sometimes the 's' or 'j' appear in lower-case. To
|
|
|
|
enforce the proper capitalization, specify the desired letter case in the
|
|
|
|
`names` array:
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```json
|
|
|
|
[
|
|
|
|
"JavaScript"
|
|
|
|
]
|
|
|
|
```
|
2017-03-18 19:47:26 -07:00
|
|
|
|
2024-07-12 08:20:14 +00:00
|
|
|
Sometimes a proper name is capitalized differently in certain contexts. In such
|
|
|
|
cases, add both forms to the `names` array:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
"GitHub",
|
|
|
|
"github.com"
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2021-11-23 04:40:05 +00:00
|
|
|
Set the `code_blocks` parameter to `false` to disable this rule for code blocks
|
2022-04-25 21:50:33 -07:00
|
|
|
and spans. Set the `html_elements` parameter to `false` to disable this rule
|
|
|
|
for HTML elements and attributes (such as when using a proper name as part of
|
|
|
|
a path for `a`/`href` or `img`/`src`).
|
2017-12-29 17:01:21 -08:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Incorrect capitalization of proper names is usually a mistake.
|
|
|
|
|
2017-12-29 17:01:21 -08:00
|
|
|
<a name="md045"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD045` - Images should have alternate text (alt text)
|
2017-12-29 17:01:21 -08:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `accessibility`, `images`
|
2017-12-29 17:01:21 -08:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `no-alt-text`
|
2017-12-29 17:01:21 -08:00
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
This rule is triggered when an image is missing alternate text (alt text)
|
|
|
|
information.
|
2018-01-06 18:06:32 -08:00
|
|
|
|
|
|
|
Alternate text is commonly specified inline as:
|
|
|
|
|
2018-03-03 22:22:02 -08:00
|
|
|
```markdown
|
2018-01-06 18:06:32 -08:00
|
|
|

|
|
|
|
```
|
|
|
|
|
|
|
|
Or with reference syntax as:
|
|
|
|
|
2018-03-03 22:22:02 -08:00
|
|
|
```markdown
|
2018-01-06 18:06:32 -08:00
|
|
|
![Alternate text][ref]
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
[ref]: image.jpg "Optional title"
|
|
|
|
```
|
|
|
|
|
2023-10-18 23:20:19 -07:00
|
|
|
Or with HTML as:
|
|
|
|
|
|
|
|
```html
|
|
|
|
<img src="image.jpg" alt="Alternate text" />
|
|
|
|
```
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Guidance for writing alternate text is available from the [W3C][w3c],
|
|
|
|
[Wikipedia][wikipedia], and [other locations][phase2technology].
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Alternate text is important for accessibility and describes the
|
|
|
|
content of an image for people who may not be able to see it.
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
[phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
|
|
|
|
[w3c]: https://www.w3.org/WAI/alt/
|
|
|
|
[wikipedia]: https://en.wikipedia.org/wiki/Alt_attribute
|
|
|
|
|
2019-04-17 14:42:17 -07:00
|
|
|
<a name="md046"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD046` - Code block style
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `code-block-style`
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: Block style (`string`, default `consistent`, values `consistent` /
|
2022-11-05 17:34:37 -07:00
|
|
|
`fenced` / `indented`)
|
2019-04-17 14:42:17 -07:00
|
|
|
|
|
|
|
This rule is triggered when unwanted or different code block styles are used in
|
|
|
|
the same document.
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
In the default configuration this rule reports a violation for the following
|
|
|
|
document:
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2020-09-06 16:31:26 -07:00
|
|
|
<!-- markdownlint-disable code-block-style -->
|
|
|
|
|
2019-04-17 14:42:17 -07:00
|
|
|
Some text.
|
|
|
|
|
|
|
|
# Indented code
|
|
|
|
|
|
|
|
More text.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# Fenced code
|
|
|
|
```
|
|
|
|
|
|
|
|
More text.
|
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
To fix violations of this rule, use a consistent style (either indenting or code
|
|
|
|
fences).
|
2019-04-17 14:42:17 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
The specified style can be specific (`fenced`, `indented`) or simply require
|
|
|
|
that usage be consistent within the document (`consistent`).
|
2019-04-05 12:36:12 +02:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2019-04-05 12:36:12 +02:00
|
|
|
<a name="md047"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD047` - Files should end with a single newline character
|
2019-04-05 12:36:12 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `blank_lines`
|
2019-04-05 12:36:12 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `single-trailing-newline`
|
2019-04-05 12:36:12 +02:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2020-06-21 23:11:33 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
This rule is triggered when there is not a single newline character at the end
|
|
|
|
of a file.
|
2019-04-05 12:36:12 +02:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
An example that triggers the rule:
|
2019-04-05 12:36:12 +02:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading
|
|
|
|
|
|
|
|
This file ends without a newline.[EOF]
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix the violation, add a newline character to the end of the file:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading
|
|
|
|
|
|
|
|
This file ends with a newline.
|
|
|
|
[EOF]
|
|
|
|
```
|
2019-10-08 21:10:02 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Some programs have trouble with files that do not end with a newline.
|
2022-11-05 17:34:37 -07:00
|
|
|
|
|
|
|
More information: [What's the point in adding a new line to the end of a
|
|
|
|
file?][stack-exchange]
|
|
|
|
|
|
|
|
[stack-exchange]: https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file
|
2020-01-20 15:10:17 -08:00
|
|
|
|
2019-10-08 21:10:02 -07:00
|
|
|
<a name="md048"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD048` - Code fence style
|
2019-10-08 21:10:02 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `code`
|
2019-10-08 21:10:02 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `code-fence-style`
|
2019-10-08 21:10:02 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `style`: Code fence style (`string`, default `consistent`, values `backtick`
|
2022-11-05 17:34:37 -07:00
|
|
|
/ `consistent` / `tilde`)
|
2019-10-08 21:10:02 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
This rule is triggered when the symbols used in the document for fenced code
|
|
|
|
blocks do not match the configured code fence style:
|
2019-10-08 21:10:02 -07:00
|
|
|
|
|
|
|
````markdown
|
|
|
|
```ruby
|
|
|
|
# Fenced code
|
|
|
|
```
|
|
|
|
|
|
|
|
~~~ruby
|
|
|
|
# Fenced code
|
|
|
|
~~~
|
|
|
|
````
|
|
|
|
|
|
|
|
To fix this issue, use the configured code fence style throughout the
|
|
|
|
document:
|
|
|
|
|
|
|
|
````markdown
|
|
|
|
```ruby
|
|
|
|
# Fenced code
|
|
|
|
```
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# Fenced code
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
|
|
|
The configured list style can be a specific symbol to use (backtick, tilde), or
|
|
|
|
can require that usage be consistent within the document.
|
2020-01-20 15:10:17 -08:00
|
|
|
|
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
2021-10-21 06:42:48 +02:00
|
|
|
|
2021-10-24 06:54:58 +02:00
|
|
|
<a name="md049"></a>
|
|
|
|
|
2023-10-25 20:05:19 -07:00
|
|
|
## `MD049` - Emphasis style
|
2021-10-24 06:54:58 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `emphasis`
|
2021-10-24 06:54:58 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `emphasis-style`
|
2021-10-24 06:54:58 +02:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2023-07-29 15:20:10 -07:00
|
|
|
- `style`: Emphasis style (`string`, default `consistent`, values `asterisk` /
|
|
|
|
`consistent` / `underscore`)
|
2021-10-24 06:54:58 +02:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2021-11-28 23:18:57 -08:00
|
|
|
|
2021-10-24 06:54:58 +02:00
|
|
|
This rule is triggered when the symbols used in the document for emphasis do not
|
|
|
|
match the configured emphasis style:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
*Text*
|
|
|
|
_Text_
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix this issue, use the configured emphasis style throughout the document:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
*Text*
|
|
|
|
*Text*
|
|
|
|
```
|
|
|
|
|
|
|
|
The configured emphasis style can be a specific symbol to use ("asterisk",
|
|
|
|
"underscore"), or can require that usage be consistent within the document.
|
|
|
|
|
2024-02-19 15:41:10 -08:00
|
|
|
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
|
|
unwanted emphasis for words containing internal underscores like_this_one.
|
|
|
|
|
2021-10-24 06:54:58 +02:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
|
2021-10-21 06:42:48 +02:00
|
|
|
<a name="md050"></a>
|
|
|
|
|
2023-10-25 20:05:19 -07:00
|
|
|
## `MD050` - Strong style
|
2021-10-21 06:42:48 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `emphasis`
|
2021-10-21 06:42:48 +02:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `strong-style`
|
2021-10-21 06:42:48 +02:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2023-07-29 15:20:10 -07:00
|
|
|
- `style`: Strong style (`string`, default `consistent`, values `asterisk` /
|
|
|
|
`consistent` / `underscore`)
|
2021-10-21 06:42:48 +02:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2021-11-28 23:18:57 -08:00
|
|
|
|
2021-10-21 06:42:48 +02:00
|
|
|
This rule is triggered when the symbols used in the document for strong do not
|
|
|
|
match the configured strong style:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
**Text**
|
|
|
|
__Text__
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix this issue, use the configured strong style throughout the document:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
**Text**
|
|
|
|
**Text**
|
|
|
|
```
|
|
|
|
|
|
|
|
The configured strong style can be a specific symbol to use ("asterisk",
|
|
|
|
"underscore"), or can require that usage be consistent within the document.
|
|
|
|
|
2024-02-19 15:41:10 -08:00
|
|
|
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
|
|
unwanted emphasis for words containing internal underscores like_this_one.
|
|
|
|
|
2021-10-21 06:42:48 +02:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
2022-01-26 00:21:08 +01:00
|
|
|
|
|
|
|
<a name="md051"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD051` - Link fragments should be valid
|
2022-01-26 00:21:08 +01:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `links`
|
2022-01-26 00:21:08 +01:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `link-fragments`
|
2022-01-26 00:21:08 +01:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2022-12-16 13:50:38 -08:00
|
|
|
|
2022-11-05 16:49:38 -07:00
|
|
|
This rule is triggered when a link fragment does not match any of the fragments
|
|
|
|
that are automatically generated for headings in a document:
|
2022-01-26 00:21:08 +01:00
|
|
|
|
|
|
|
```markdown
|
2023-07-08 22:14:00 -07:00
|
|
|
# Heading Name
|
2022-01-26 00:21:08 +01:00
|
|
|
|
2022-04-10 05:37:57 +00:00
|
|
|
[Link](#fragment)
|
|
|
|
```
|
|
|
|
|
2023-07-08 22:14:00 -07:00
|
|
|
To fix this issue, change the link fragment to reference an existing heading's
|
|
|
|
generated name (see below):
|
2022-04-10 05:37:57 +00:00
|
|
|
|
|
|
|
```markdown
|
2023-07-08 22:14:00 -07:00
|
|
|
# Heading Name
|
|
|
|
|
|
|
|
[Link](#heading-name)
|
|
|
|
```
|
|
|
|
|
2024-02-10 15:36:12 -08:00
|
|
|
Link fragments may be handled case-sensitively, so this rule requires fragments
|
|
|
|
to exactly match the [GitHub heading algorithm][github-heading-algorithm].
|
|
|
|
Therefore, the following example is reported as a violation:
|
2024-02-07 20:45:56 +01:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading Name
|
|
|
|
|
|
|
|
[Link](#Heading-Name)
|
|
|
|
```
|
|
|
|
|
2023-07-08 22:14:00 -07:00
|
|
|
Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
|
|
|
|
within a heading to provide a specific name (consisting of only lower-case
|
|
|
|
letters, numbers, `-`, and `_`):
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading Name {#custom-name}
|
2022-11-05 16:49:38 -07:00
|
|
|
|
2023-07-08 22:14:00 -07:00
|
|
|
[Link](#custom-name)
|
2022-01-26 00:21:08 +01:00
|
|
|
```
|
|
|
|
|
2023-08-04 20:53:38 -07:00
|
|
|
Alternatively, any HTML tag with an `id` attribute or an `a` tag with a `name`
|
|
|
|
attribute can be used to define a fragment:
|
2022-04-10 05:37:57 +00:00
|
|
|
|
|
|
|
```markdown
|
2022-11-05 16:49:38 -07:00
|
|
|
<a id="bookmark"></a>
|
|
|
|
|
|
|
|
[Link](#bookmark)
|
2022-04-10 05:37:57 +00:00
|
|
|
```
|
|
|
|
|
2022-11-05 16:49:38 -07:00
|
|
|
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
|
|
|
control over the text of the fragment identifier.
|
|
|
|
|
2024-02-10 15:36:12 -08:00
|
|
|
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
|
|
|
[specific content in a document][github-linking-to-content].
|
2024-02-07 20:45:56 +01:00
|
|
|
|
2024-02-10 15:36:12 -08:00
|
|
|
For example, this link to line 20:
|
2024-02-07 20:45:56 +01:00
|
|
|
|
|
|
|
```markdown
|
2024-02-10 15:36:12 -08:00
|
|
|
[Link](#L20)
|
2024-02-07 20:45:56 +01:00
|
|
|
```
|
|
|
|
|
2024-02-10 15:36:12 -08:00
|
|
|
And this link to content starting within line 19 running into line 21:
|
2024-02-07 20:45:56 +01:00
|
|
|
|
|
|
|
```markdown
|
2024-02-10 15:36:12 -08:00
|
|
|
[Link](#L19C5-L21C11)
|
2024-02-07 20:45:56 +01:00
|
|
|
```
|
|
|
|
|
2022-11-05 17:34:37 -07:00
|
|
|
Rationale: [GitHub section links][github-section-links] are created
|
|
|
|
automatically for every heading when Markdown content is displayed on GitHub.
|
|
|
|
This makes it easy to link directly to different sections within a document.
|
|
|
|
However, section links change if headings are renamed or removed. This rule
|
|
|
|
helps identify broken section links within a document.
|
2022-04-10 05:37:57 +00:00
|
|
|
|
2022-11-05 16:49:38 -07:00
|
|
|
Section links are **not** part of the CommonMark specification. This rule
|
|
|
|
enforces the [GitHub heading algorithm][github-heading-algorithm] which is:
|
2022-11-05 17:34:37 -07:00
|
|
|
convert heading to lowercase, remove punctuation, convert spaces to dashes,
|
|
|
|
append an incrementing integer as needed for uniqueness.
|
2022-04-10 05:37:57 +00:00
|
|
|
|
|
|
|
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
2022-12-31 21:06:48 +00:00
|
|
|
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
2024-02-10 15:36:12 -08:00
|
|
|
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
2022-01-26 00:21:08 +01:00
|
|
|
|
2022-06-01 20:23:08 -07:00
|
|
|
<a name="md052"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD052` - Reference links and images should use a label that is defined
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `images`, `links`
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `reference-links-images`
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2023-09-04 16:40:48 -07:00
|
|
|
Parameters:
|
|
|
|
|
|
|
|
- `shortcut_syntax`: Include shortcut syntax (`boolean`, default `false`)
|
|
|
|
|
2022-06-01 20:23:08 -07:00
|
|
|
Links and images in Markdown can provide the link destination or image source
|
|
|
|
at the time of use or can define it elsewhere and use a label for reference.
|
|
|
|
The reference format is convenient for keeping paragraph text clutter-free
|
|
|
|
and makes it easy to reuse the same URL in multiple places.
|
|
|
|
|
|
|
|
There are three kinds of reference links and images:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
Full: [text][label]
|
|
|
|
Collapsed: [label][]
|
|
|
|
Shortcut: [label]
|
|
|
|
|
|
|
|
Full: ![text][image]
|
|
|
|
Collapsed: ![image][]
|
|
|
|
Shortcut: ![image]
|
|
|
|
|
|
|
|
[label]: https://example.com/label
|
|
|
|
[image]: https://example.com/image
|
|
|
|
```
|
|
|
|
|
2023-09-04 16:40:48 -07:00
|
|
|
A link or image renders correctly when the corresponding label is defined, but
|
|
|
|
displays as text with brackets when the label is not present. By default, this
|
|
|
|
rule warns of undefined labels for "full" and "collapsed" reference syntax but
|
|
|
|
not for "shortcut" syntax because it is ambiguous.
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2023-09-04 16:40:48 -07:00
|
|
|
The text `[example]` could be a shortcut link or the text "example" in brackets,
|
|
|
|
so "shortcut" syntax is ignored by default. To include "shortcut" syntax, set
|
|
|
|
the `include_shortcut` parameter to `true`. Note that doing so produces warnings
|
|
|
|
for *all* text in the document that *could* be a shortcut. If bracketed text is
|
|
|
|
intentional, brackets can be escaped with the `\` character: `\[example\]`.
|
2022-06-01 20:23:08 -07:00
|
|
|
|
|
|
|
<a name="md053"></a>
|
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
## `MD053` - Link and image reference definitions should be needed
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Tags: `images`, `links`
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2022-10-30 15:13:19 -07:00
|
|
|
Aliases: `link-image-reference-definitions`
|
2022-06-01 20:23:08 -07:00
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Parameters:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
- `ignored_definitions`: Ignored definitions (`string[]`, default `["//"]`)
|
2022-08-02 20:36:47 -07:00
|
|
|
|
2022-12-16 13:53:03 -08:00
|
|
|
Fixable: Some violations can be fixed by tooling
|
2022-06-01 20:23:08 -07:00
|
|
|
|
|
|
|
Links and images in Markdown can provide the link destination or image source
|
2023-10-25 20:05:19 -07:00
|
|
|
at the time of use or can use a label to reference a definition elsewhere in
|
|
|
|
the document. The latter reference format is convenient for keeping paragraph
|
|
|
|
text clutter-free and makes it easy to reuse the same URL in multiple places.
|
2022-06-01 20:23:08 -07:00
|
|
|
|
|
|
|
Because link and image reference definitions are located separately from
|
|
|
|
where they are used, there are two scenarios where a definition can be
|
|
|
|
unnecessary:
|
|
|
|
|
|
|
|
1. If a label is not referenced by any link or image in a document, that
|
|
|
|
definition is unused and can be deleted.
|
2022-11-13 20:53:10 -08:00
|
|
|
2. If a label is defined multiple times in a document, the first definition is
|
2022-06-01 20:23:08 -07:00
|
|
|
used and the others can be deleted.
|
|
|
|
|
|
|
|
This rule considers a reference definition to be used if any link or image
|
2022-08-02 20:36:47 -07:00
|
|
|
reference has the corresponding label. The "full", "collapsed", and "shortcut"
|
2022-06-01 20:23:08 -07:00
|
|
|
formats are all supported.
|
|
|
|
|
2022-08-02 20:36:47 -07:00
|
|
|
If there are reference definitions that are deliberately unreferenced, they can
|
|
|
|
be ignored by setting the `ignored_definitions` parameter. The default value of
|
|
|
|
this parameter ignores the following convention for adding non-HTML comments to
|
|
|
|
Markdown:
|
|
|
|
|
2022-11-13 20:53:10 -08:00
|
|
|
```markdown
|
2022-08-02 20:36:47 -07:00
|
|
|
[//]: # (This behaves like a comment)
|
|
|
|
```
|
|
|
|
|
2023-10-25 20:05:19 -07:00
|
|
|
<a name="md054"></a>
|
|
|
|
|
|
|
|
## `MD054` - Link and image style
|
|
|
|
|
|
|
|
Tags: `images`, `links`
|
|
|
|
|
|
|
|
Aliases: `link-image-style`
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
- `autolink`: Allow autolinks (`boolean`, default `true`)
|
2023-11-11 22:12:50 -08:00
|
|
|
- `collapsed`: Allow collapsed reference links and images (`boolean`, default
|
|
|
|
`true`)
|
|
|
|
- `full`: Allow full reference links and images (`boolean`, default `true`)
|
2023-10-25 20:05:19 -07:00
|
|
|
- `inline`: Allow inline links and images (`boolean`, default `true`)
|
2023-11-11 22:12:50 -08:00
|
|
|
- `shortcut`: Allow shortcut reference links and images (`boolean`, default
|
|
|
|
`true`)
|
2023-11-12 22:42:02 -08:00
|
|
|
- `url_inline`: Allow URLs as inline links (`boolean`, default `true`)
|
2023-10-25 20:05:19 -07:00
|
|
|
|
|
|
|
Fixable: Some violations can be fixed by tooling
|
|
|
|
|
|
|
|
Links and images in Markdown can provide the link destination or image source at
|
|
|
|
the time of use or can use a label to reference a definition elsewhere in the
|
2023-11-11 22:12:50 -08:00
|
|
|
document. The three reference formats are convenient for keeping paragraph text
|
|
|
|
clutter-free and make it easy to reuse the same URL in multiple places.
|
2023-10-25 20:05:19 -07:00
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
By default, this rule allows all link/image styles.
|
2023-10-25 20:05:19 -07:00
|
|
|
|
|
|
|
Setting the `autolink` parameter to `false` disables autolinks:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
<https://example.com>
|
|
|
|
```
|
|
|
|
|
|
|
|
Setting the `inline` parameter to `false` disables inline links and images:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[link](https://example.com)
|
|
|
|
|
|
|
|

|
|
|
|
```
|
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
Setting the `full` parameter to `false` disables full reference links and
|
|
|
|
images:
|
2023-10-25 20:05:19 -07:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
[link][url]
|
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
![image][url]
|
2023-10-25 20:05:19 -07:00
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
[url]: https://example.com
|
|
|
|
```
|
2023-10-25 20:05:19 -07:00
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
Setting the `collapsed` parameter to `false` disables collapsed reference links
|
|
|
|
and images:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[url][]
|
2023-10-25 20:05:19 -07:00
|
|
|
|
|
|
|
![url][]
|
|
|
|
|
2023-11-11 22:12:50 -08:00
|
|
|
[url]: https://example.com
|
|
|
|
```
|
|
|
|
|
|
|
|
Setting the `shortcut` parameter to `false` disables shortcut reference links
|
|
|
|
and images:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[url]
|
|
|
|
|
2023-10-25 20:05:19 -07:00
|
|
|
![url]
|
|
|
|
|
|
|
|
[url]: https://example.com
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix violations of this rule, change the link or image to use an allowed
|
|
|
|
style. This rule can automatically fix violations when a link or image can be
|
|
|
|
converted to the `inline` style (preferred) or a link can be converted to the
|
|
|
|
`autolink` style (which does not support images and must be an absolute URL).
|
2023-11-11 22:12:50 -08:00
|
|
|
This rule does *not* fix scenarios that require converting a link or image to
|
|
|
|
the `full`, `collapsed`, or `shortcut` reference styles because that involves
|
|
|
|
naming the reference and determining where to insert it in the document.
|
2023-10-25 20:05:19 -07:00
|
|
|
|
2023-11-12 22:42:02 -08:00
|
|
|
Setting the `url_inline` parameter to `false` prevents the use of inline links
|
|
|
|
with the same absolute URL text/destination and no title because such links can
|
|
|
|
be converted to autolinks:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[https://example.com](https://example.com)
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix `url_inline` violations, use the simpler autolink syntax instead:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
<https://example.com>
|
|
|
|
```
|
|
|
|
|
2023-10-25 20:05:19 -07:00
|
|
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
|
|
Autolinks are concise, but appear as URLs which can be long and confusing.
|
|
|
|
Inline links and images can include descriptive text, but take up more space in
|
|
|
|
Markdown form. Reference links and images can be easier to read and manipulate
|
2023-11-11 22:12:50 -08:00
|
|
|
in Markdown form, but require a separate link reference definition.
|
2023-10-25 20:05:19 -07:00
|
|
|
|
2023-12-30 18:15:38 -08:00
|
|
|
<a name="md055"></a>
|
|
|
|
|
|
|
|
## `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
|
|
|
|
is used to determine the style that is enforced for all tables in that document.
|
|
|
|
A specific style can be required by setting the `style` parameter accordingly.
|
|
|
|
|
|
|
|
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-
|
|
|
|
|
|
|
|
<a name="md056"></a>
|
|
|
|
|
|
|
|
## `MD056` - Table column count
|
|
|
|
|
|
|
|
Tags: `table`
|
|
|
|
|
|
|
|
Aliases: `table-column-count`
|
|
|
|
|
|
|
|
This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-056]
|
|
|
|
does not have the same number of cells in every row.
|
|
|
|
|
|
|
|
This table's second data row has too few cells and its third data row has too
|
|
|
|
many cells:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
| Header | Header |
|
|
|
|
| ------ | ------ |
|
|
|
|
| Cell | Cell |
|
|
|
|
| Cell |
|
|
|
|
| Cell | Cell | Cell |
|
|
|
|
```
|
|
|
|
|
|
|
|
To fix these issues, ensure every row has the same number of cells:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
| Header | Header |
|
|
|
|
| ------ | ------ |
|
|
|
|
| Cell | Cell |
|
|
|
|
| Cell | Cell |
|
|
|
|
| Cell | Cell |
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that a table's header row and its delimiter row must have the same number
|
|
|
|
of cells or it will not be recognized as a table (per specification).
|
|
|
|
|
|
|
|
Rationale: Extra cells in a row are usually not shown, so their data is lost.
|
|
|
|
Missing cells in a row create holes in the table and suggest an omission.
|
|
|
|
|
|
|
|
[gfm-table-056]: https://github.github.com/gfm/#tables-extension-
|
2023-12-30 18:15:38 -08:00
|
|
|
|
2024-06-01 21:32:10 -07:00
|
|
|
<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.
|
|
|
|
|
2022-04-10 05:37:57 +00:00
|
|
|
<!-- markdownlint-configure-file {
|
|
|
|
"no-inline-html": {
|
|
|
|
"allowed_elements": [
|
|
|
|
"a"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
} -->
|