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
|
2019-07-08 13:10:08 -05:00
|
|
|
versions of the examples. Any rule whose heading is ~~struck through~~ is
|
|
|
|
deprecated, but still provided for backward-compatibility.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md001"></a>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD001 - Heading levels should only increment by one level at a time
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: heading-increment, header-increment
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
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="md002"></a>
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
## ~~MD002 - First heading should be a top-level heading~~
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: first-heading-h1, first-header-h1
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2016-07-04 23:23:29 -07:00
|
|
|
Parameters: level (number; default 1)
|
|
|
|
|
2019-03-12 22:23:12 -07:00
|
|
|
> Note: *MD002 has been deprecated and is disabled by default.*
|
2019-03-24 21:50:56 -07:00
|
|
|
> [MD041/first-line-heading](#md041) offers an improved implementation.
|
2019-03-12 22:23:12 -07:00
|
|
|
|
2019-03-10 22:10:33 -07:00
|
|
|
This rule is intended to ensure document headings start at the top level and
|
2020-12-28 13:28:38 -08:00
|
|
|
is triggered when the first heading in the document isn't an h1 heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2020-12-28 13:28:38 -08:00
|
|
|
## This isn't an H1 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
|
|
|
The first heading in the document should be an h1 heading:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2020-12-28 13:28:38 -08:00
|
|
|
# Start with an H1 heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-03-10 22:10:33 -07:00
|
|
|
## Then use an H2 for subsections
|
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
|
|
|
|
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="md003"></a>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD003 - Heading style
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: heading-style, header-style
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2016-02-23 21:22:46 -08:00
|
|
|
Parameters: style ("consistent", "atx", "atx_closed", "setext",
|
|
|
|
"setext_with_atx", "setext_with_atx_closed"; default "consistent")
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
This rule is triggered when different heading styles (atx, setext, and 'closed'
|
2015-03-12 23:42:06 -07:00
|
|
|
atx) are used in the same document:
|
|
|
|
|
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
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Be consistent with the style of heading used in a 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
|
|
|
|
2017-09-06 09:35:37 +02:00
|
|
|
The setext_with_atx and setext_with_atx_closed doc styles allow atx-style
|
2018-03-19 23:39:42 +01:00
|
|
|
headings of level 3 or more in documents with setext style 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
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Note: the configured heading style can be a specific style to use (atx,
|
2016-02-23 21:22:46 -08:00
|
|
|
atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
|
2020-12-28 13:28:38 -08:00
|
|
|
that the usage is consistent within the document.
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD004 - Unordered list style
|
|
|
|
|
|
|
|
Tags: bullet, ul
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: ul-style
|
|
|
|
|
2016-07-04 14:32:40 -07:00
|
|
|
Parameters: style ("consistent", "asterisk", "plus", "dash", "sublist"; default
|
|
|
|
"consistent")
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2021-02-06 15:49:02 -08:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
2016-07-04 14:32:40 -07:00
|
|
|
The configured list style can be a specific symbol to use (asterisk, plus, dash),
|
2020-12-28 13:28:38 -08:00
|
|
|
to ensure that all list styling is consistent, or to ensure that each
|
|
|
|
sublist has a consistent symbol that differs from its parent list.
|
2016-07-04 14:32:40 -07:00
|
|
|
|
|
|
|
For example, the following is valid for the `sublist` style because the outer-most
|
2021-01-31 16:02:49 -08:00
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD005 - Inconsistent indentation for list items at the same level
|
|
|
|
|
|
|
|
Tags: bullet, ul, indentation
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: list-indent
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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="md006"></a>
|
|
|
|
|
2020-01-13 19:19:49 -08:00
|
|
|
## ~~MD006 - Consider starting bulleted lists at the beginning of the line~~
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
Tags: bullet, ul, indentation
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: ul-start-left
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
This rule is triggered when top-level lists don't start at the beginning of a
|
2015-03-12 23:42:06 -07:00
|
|
|
line:
|
|
|
|
|
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
|
|
|
* List item
|
|
|
|
* List item
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
To fix, ensure that top-level list items are not indented:
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
Some test
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
* List item
|
|
|
|
* List item
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-06-26 11:56:48 -07:00
|
|
|
Note: This rule is triggered for the following scenario because the unordered
|
|
|
|
sublist is not recognized as such by the parser. Not being nested 3 characters
|
|
|
|
as required by the outer ordered list, it creates a top-level unordered list
|
|
|
|
instead.
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
1. List item
|
|
|
|
- List item
|
|
|
|
- List item
|
|
|
|
1. List item
|
|
|
|
```
|
2016-06-26 11:56:48 -07:00
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Starting lists at the beginning of the line means that nested list
|
|
|
|
items can all be indented by the same amount when an editor's indent function
|
|
|
|
or the tab key is used to indent. Starting a list 1 space in means that the
|
|
|
|
indent of the first nested list is less than the indent of the second level (3
|
|
|
|
characters if you use 4 space tabs, or 1 character if you use 2 space tabs).
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md007"></a>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD007 - Unordered list indentation
|
|
|
|
|
|
|
|
Tags: bullet, ul, indentation
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: ul-indent
|
|
|
|
|
2020-01-01 15:53:03 -05:00
|
|
|
Parameters: indent, start_indented (number; default 2, boolean; default false)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
the configured number of spaces rather than starting at zero (the inverse of
|
|
|
|
MD006).
|
|
|
|
|
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
|
2020-12-28 13:28:38 -08:00
|
|
|
issue for multi-markdown parsers, which require 4-space indents. More information:
|
2020-01-20 15:10:17 -08:00
|
|
|
<https://cirosantilli.com/markdown-style-guide#indentation-of-content-inside-lists>
|
|
|
|
and <http://support.markedapp.com/discussions/problems/21-sub-lists-not-indenting>.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md009"></a>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD009 - Trailing spaces
|
|
|
|
|
|
|
|
Tags: whitespace
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-trailing-spaces
|
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-disable line-length -->
|
|
|
|
|
2019-12-09 22:05:57 -08:00
|
|
|
Parameters: br_spaces, list_item_empty_lines, strict (number; default 2, boolean; default false, boolean; default false)
|
2015-04-14 09:07:25 -07:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
2018-04-30 21:34:19 -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
|
|
|
|
2018-04-30 21:34:19 -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
|
|
|
|
2019-12-09 22:05:57 -08: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`.
|
|
|
|
|
|
|
|
```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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD010 - Hard tabs
|
|
|
|
|
|
|
|
Tags: whitespace, hard_tab
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-hard-tabs
|
|
|
|
|
2016-09-29 21:25:10 -07:00
|
|
|
Parameters: code_blocks (boolean; default true)
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
2016-09-29 21:25:10 -07:00
|
|
|
You have the option to exclude this rule for code blocks. To do so, set the
|
|
|
|
`code_blocks` parameter to `false`. Code blocks are included by default since
|
|
|
|
handling of tabs by tools is often inconsistent (ex: using 4 vs. 8 spaces).
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD011 - Reversed link syntax
|
|
|
|
|
|
|
|
Tags: links
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-reversed-links
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD012 - Multiple consecutive blank lines
|
|
|
|
|
|
|
|
Tags: whitespace, blank_lines
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-multiple-blanks
|
|
|
|
|
2016-10-03 21:42:44 -07:00
|
|
|
Parameters: maximum (number; default 1)
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD013 - Line length
|
|
|
|
|
|
|
|
Tags: line_length
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: line-length
|
|
|
|
|
2020-09-06 16:31:26 -07:00
|
|
|
<!-- markdownlint-disable line-length -->
|
|
|
|
|
2020-03-22 14:06:29 -07:00
|
|
|
Parameters: line_length, heading_line_length, code_block_line_length, code_blocks, tables, headings, headers, strict, stern (number; default 80 for *_length, boolean; default true (except strict/stern which default false))
|
2018-03-19 23:39:42 +01:00
|
|
|
|
2021-01-31 16:02:49 -08:00
|
|
|
<!-- markdownlint-restore -->
|
2020-09-06 16:31:26 -07:00
|
|
|
|
2018-04-18 22:25:45 -07:00
|
|
|
> If `headings` is not provided, `headers` (deprecated) will be used.
|
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
|
2015-03-12 23:42:06 -07:00
|
|
|
line length. This allows you to still include items such as long URLs without
|
2019-12-12 21:22:45 -08:00
|
|
|
being forced to break them in the middle. To disable this exception, set the
|
2020-03-22 14:06:29 -07:00
|
|
|
`strict` parameter to `true` to report an issue when any line is too long.
|
|
|
|
To warn for lines that are too long and could be fixed but allow lines without
|
|
|
|
spaces, set the `stern` parameter to `true`.
|
|
|
|
|
|
|
|
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
|
|
|
|
And this line is a violation because there are
|
|
|
|
This-line-is-also-okay-because-there-are-no-spaces
|
|
|
|
```
|
|
|
|
|
|
|
|
In `strict` or `stern` modes, the two middle lines above are a violation. The
|
2020-12-28 13:28:38 -08:00
|
|
|
third line is a violation in `strict` mode but allowed in `stern` mode.
|
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.
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD014 - Dollar signs used before commands without showing output
|
|
|
|
|
|
|
|
Tags: code
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: commands-show-output
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD018 - No space after hash on atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, atx, spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-missing-space-atx
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD019 - Multiple spaces after hash on atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, atx, spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-multiple-space-atx
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD020 - No space inside hashes on closed atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, atx_closed, spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-missing-space-closed-atx
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD021 - Multiple spaces inside hashes on closed atx style heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, atx_closed, spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-multiple-space-closed-atx
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD022 - Headings should be surrounded by blank lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, blank_lines
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: blanks-around-headings, blanks-around-headers
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2019-03-24 21:50:56 -07:00
|
|
|
Parameters: lines_above, lines_below (number; default 1)
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
2019-03-24 21:50:56 -07:00
|
|
|
The `lines_above` and `lines_below` parameters can be used to specify a different
|
|
|
|
number of blank lines (including 0) above or below each heading.
|
|
|
|
|
|
|
|
Note: If `lines_above` or `lines_below` are configured to require more than one
|
|
|
|
blank line, [MD012/no-multiple-blanks](#md012) should also be customized.
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Rationale: Aside from aesthetic reasons, some parsers, including `kramdown`, will
|
2020-01-20 15:10:17 -08:00
|
|
|
not parse headings that don't have a blank line before, and will parse them as
|
|
|
|
regular text.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md023"></a>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD023 - Headings must start at the beginning of the line
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, spaces
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: heading-start-left, header-start-left
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD024 - Multiple headings with the same content
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: no-duplicate-heading, no-duplicate-header
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2018-07-19 21:49:30 -07:00
|
|
|
Parameters: siblings_only, allow_different_nesting (boolean; default `false`)
|
|
|
|
|
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
|
|
|
|
2018-07-19 21:49:30 -07:00
|
|
|
If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
|
|
|
|
set to `true`, heading duplication is allowed for non-sibling headings (common
|
2020-12-28 13:28:38 -08:00
|
|
|
in changelogs):
|
2018-07-19 21:49:30 -07:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Change log
|
|
|
|
|
|
|
|
## 1.0.0
|
|
|
|
|
|
|
|
### Features
|
|
|
|
|
|
|
|
## 2.0.0
|
|
|
|
|
|
|
|
### Features
|
|
|
|
```
|
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Some markdown parsers generate anchors for headings based on the
|
|
|
|
heading name; headings with the same content can cause problems with that.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md025"></a>
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
## MD025 - Multiple top-level headings in the same document
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2019-03-16 20:21:57 -07:00
|
|
|
Aliases: single-title, single-h1
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2020-11-14 19:40:15 -08:00
|
|
|
Parameters: level, front_matter_title (number; default 1, string; default "^\s*"?title"?\s*[:=]")
|
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
|
|
|
|
2019-03-16 20:21:57 -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
|
2020-12-28 13:28:38 -08:00
|
|
|
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
|
2019-03-16 20:21:57 -07:00
|
|
|
expression via the `front_matter_title` parameter. To disable the use of front
|
|
|
|
matter by this rule, specify `""` for `front_matter_title`.
|
|
|
|
|
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
|
|
|
|
can not be more than one title for the document, and the entire document
|
|
|
|
should be contained within this heading.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md026"></a>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD026 - Trailing punctuation in heading
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-trailing-punctuation
|
|
|
|
|
2020-11-17 20:32:17 -08:00
|
|
|
Parameters: punctuation (string; default ".,;:!。,;:!")
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
2020-11-17 20:32:17 -08:00
|
|
|
allowed by default because of how common it is in headings of FAQ-style documents.
|
2019-07-26 23:03:56 -07:00
|
|
|
Setting the `punctuation` parameter to `""` allows all characters - and is
|
|
|
|
equivalent to disabling the rule.
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-11-23 15:23:39 -08:00
|
|
|
Note: The trailing semicolon of
|
|
|
|
[HTML entity references](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references)
|
|
|
|
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:
|
|
|
|
<https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers>
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md027"></a>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD027 - Multiple spaces after blockquote symbol
|
|
|
|
|
|
|
|
Tags: blockquote, whitespace, indentation
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-multiple-space-blockquote
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD028 - Blank line inside blockquote
|
|
|
|
|
|
|
|
Tags: blockquote, whitespace
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-blanks-blockquote
|
|
|
|
|
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
|
|
|
|
|
|
|
Rationale: Some markdown parsers will treat two blockquotes separated by one
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD029 - Ordered list item prefix
|
|
|
|
|
|
|
|
Tags: ol
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: ol-prefix
|
|
|
|
|
2019-03-06 21:57:19 -08:00
|
|
|
Parameters: style ("one", "ordered", "one_or_ordered", "zero"; default "one_or_ordered")
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD030 - Spaces after list markers
|
|
|
|
|
|
|
|
Tags: ol, ul, whitespace
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: list-marker-space
|
|
|
|
|
2016-07-02 22:37:52 -07:00
|
|
|
Parameters: ul_single, ol_single, ul_multi, ol_multi (number; default 1)
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md031"></a>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD031 - Fenced code blocks should be surrounded by blank lines
|
|
|
|
|
|
|
|
Tags: code, blank_lines
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: blanks-around-fences
|
|
|
|
|
2019-08-02 22:58:41 -07:00
|
|
|
Parameters: list_items (boolean; default true)
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-03-12 23:42:06 -07:00
|
|
|
## MD032 - Lists should be surrounded by blank lines
|
|
|
|
|
|
|
|
Tags: bullet, ul, ol, blank_lines
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: blanks-around-lists
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
* Some
|
|
|
|
* List
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
1. Some
|
|
|
|
2. List
|
|
|
|
Some text
|
|
|
|
```
|
2015-03-12 23:42:06 -07:00
|
|
|
|
|
|
|
To fix this, ensure that all lists 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
|
|
|
* Some
|
|
|
|
* List
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
1. Some
|
|
|
|
2. List
|
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
|
|
|
|
|
|
|
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
|
|
|
|
not parse lists that don't have blank lines before and after them.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md033"></a>
|
|
|
|
|
2015-04-13 08:47:15 -07:00
|
|
|
## MD033 - Inline HTML
|
|
|
|
|
|
|
|
Tags: html
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-inline-html
|
|
|
|
|
2015-12-15 21:30:37 -08:00
|
|
|
Parameters: allowed_elements (array of string; default empty)
|
|
|
|
|
2015-04-13 08:47:15 -07:00
|
|
|
This rule is triggered whenever raw HTML is used in a markdown document:
|
|
|
|
|
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
|
|
|
|
|
|
|
To fix this, use 'pure' markdown instead of including raw HTML:
|
|
|
|
|
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
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Note: To allow specific HTML elements, use the 'allowed_elements' parameter.
|
|
|
|
|
2015-04-13 08:47:15 -07:00
|
|
|
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 in something other than HTML.
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md034"></a>
|
|
|
|
|
2015-04-14 00:01:57 -07:00
|
|
|
## MD034 - Bare URL used
|
|
|
|
|
|
|
|
Tags: links, url
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-bare-urls
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
2015-04-14 00:01:57 -07:00
|
|
|
This rule is triggered whenever a URL is given that isn't surrounded by angle
|
|
|
|
brackets:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
For more information, see https://www.example.com/.
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 00:01:57 -07:00
|
|
|
|
|
|
|
To fix this, add angle brackets around the URL:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
For more information, see <https://www.example.com/>.
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2020-04-01 20:21:36 -07:00
|
|
|
Note: To use a bare URL without it being converted into a link, enclose it in
|
|
|
|
a code block, otherwise in some markdown parsers it _will_ be converted:
|
2015-04-14 00:01:57 -07:00
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
2019-02-10 11:38:01 -08:00
|
|
|
`https://www.example.com`
|
2018-03-09 22:50:01 -08:00
|
|
|
```
|
2015-04-14 09:40:16 -07:00
|
|
|
|
2020-04-01 20:21:36 -07:00
|
|
|
Note: The following scenario does _not_ trigger this rule to avoid conflicts
|
|
|
|
with `MD011`/`no-reversed-links`:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
[https://www.example.com]
|
|
|
|
```
|
|
|
|
|
2020-04-08 21:58:52 -07:00
|
|
|
The use of quotes around a bare link will _not_ trigger this rule, either:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
"https://www.example.com"
|
|
|
|
'https://www.example.com'
|
|
|
|
```
|
|
|
|
|
|
|
|
Rationale: Without angle brackets, the URL isn't converted into a link by many
|
2020-01-20 15:10:17 -08:00
|
|
|
markdown parsers.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md035"></a>
|
|
|
|
|
2015-04-14 09:40:16 -07:00
|
|
|
## MD035 - Horizontal rule style
|
|
|
|
|
|
|
|
Tags: hr
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: hr-style
|
|
|
|
|
2015-04-14 09:40:16 -07:00
|
|
|
Parameters: style ("consistent", "---", "***", or other string specifying the
|
|
|
|
horizontal rule; default "consistent")
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD036 - Emphasis used instead of a heading
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers, emphasis
|
2015-04-14 22:37:56 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: no-emphasis-as-heading, no-emphasis-as-header
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2019-06-06 22:21:31 -07:00
|
|
|
Parameters: punctuation (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
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
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>
|
|
|
|
|
2015-04-15 17:50:01 -07:00
|
|
|
## MD037 - Spaces inside emphasis markers
|
|
|
|
|
|
|
|
Tags: whitespace, emphasis
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-space-in-emphasis
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-04-15 18:24:42 -07:00
|
|
|
## MD038 - Spaces inside code span elements
|
|
|
|
|
|
|
|
Tags: whitespace, code
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-space-in-code
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
automatically trimmed (to allow for embedded backticks):
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
`` `backticks` ``
|
|
|
|
```
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
Note: A single leading or trailing space is allowed if used to separate code span
|
2017-02-18 22:56:06 -08:00
|
|
|
markers from an embedded backtick:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```markdown
|
|
|
|
`` ` embedded backtick``
|
|
|
|
```
|
2017-02-18 22:56:06 -08: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="md039"></a>
|
|
|
|
|
2015-04-15 18:24:42 -07:00
|
|
|
## MD039 - Spaces inside link text
|
|
|
|
|
|
|
|
Tags: whitespace, links
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: no-space-in-links
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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>
|
|
|
|
|
2015-04-16 09:13:56 -07:00
|
|
|
## MD040 - Fenced code blocks should have a language specified
|
|
|
|
|
|
|
|
Tags: code, language
|
|
|
|
|
2016-01-12 21:29:17 -08:00
|
|
|
Aliases: fenced-code-language
|
|
|
|
|
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
|
|
|
|
```
|
|
|
|
````
|
|
|
|
|
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>
|
|
|
|
|
2020-12-28 13:28:38 -08:00
|
|
|
## MD041 - First line in a file should be a top-level heading
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Tags: headings, headers
|
2015-07-20 22:06:48 -07:00
|
|
|
|
2019-03-13 21:39:15 -07:00
|
|
|
Aliases: first-line-heading, first-line-h1
|
2016-01-12 21:29:17 -08:00
|
|
|
|
2020-11-14 19:40:15 -08:00
|
|
|
Parameters: level, front_matter_title (number; default 1, string; default "^\s*"?title"?\s*[:=]")
|
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
|
|
|
|
```
|
|
|
|
|
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.
|
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.
|
|
|
|
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>
|
|
|
|
|
2016-06-27 22:19:02 -07:00
|
|
|
## MD042 - No empty links
|
|
|
|
|
|
|
|
Tags: links
|
|
|
|
|
|
|
|
Aliases: no-empty-links
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-01-20 15:10:17 -08:00
|
|
|
Rationale: Empty links do not lead anywhere and therefore don't function as links.
|
|
|
|
|
2017-05-07 12:48:04 -07:00
|
|
|
<a name="md043"></a>
|
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
## MD043 - Required heading structure
|
|
|
|
|
|
|
|
Tags: headings, headers
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Aliases: required-headings, required-headers
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-03-19 23:39:42 +01:00
|
|
|
Parameters: headings, headers (array of string; default `null` for disabled)
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2018-04-18 22:25:45 -07:00
|
|
|
> If `headings` is not provided, `headers` (deprecated) will be used.
|
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
|
|
|
|
2018-03-19 23:39:42 +01: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
|
|
|
|
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>
|
|
|
|
|
2016-12-22 13:34:18 -08:00
|
|
|
## MD044 - Proper names should have the correct capitalization
|
|
|
|
|
|
|
|
Tags: spelling
|
|
|
|
|
|
|
|
Aliases: proper-names
|
|
|
|
|
2017-03-18 19:47:26 -07:00
|
|
|
Parameters: names, code_blocks (string array; default `null`, boolean; default `true`)
|
2016-12-22 13:34:18 -08:00
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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
|
|
|
|
'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:
|
|
|
|
|
2018-03-09 22:50:01 -08:00
|
|
|
```json
|
|
|
|
[
|
|
|
|
"JavaScript"
|
|
|
|
]
|
|
|
|
```
|
2017-03-18 19:47:26 -07:00
|
|
|
|
|
|
|
Set the `code_blocks` parameter to `false` to disable this rule for code blocks.
|
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>
|
|
|
|
|
2018-01-06 18:06:32 -08:00
|
|
|
## MD045 - Images should have alternate text (alt text)
|
2017-12-29 17:01:21 -08:00
|
|
|
|
|
|
|
Tags: accessibility, images
|
|
|
|
|
|
|
|
Aliases: no-alt-text
|
|
|
|
|
2018-01-06 18:06:32 -08:00
|
|
|
This rule is triggered when an image is missing alternate text (alt text) information.
|
|
|
|
|
|
|
|
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"
|
|
|
|
```
|
|
|
|
|
|
|
|
Guidance for writing alternate text is available from the [W3C](https://www.w3.org/WAI/alt/),
|
|
|
|
[Wikipedia](https://en.wikipedia.org/wiki/Alt_attribute), and
|
2020-09-30 21:59:22 -07:00
|
|
|
[other locations](https://www.phase2technology.com/blog/no-more-excuses).
|
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.
|
|
|
|
|
2019-04-17 14:42:17 -07:00
|
|
|
<a name="md046"></a>
|
|
|
|
|
|
|
|
## MD046 - Code block style
|
|
|
|
|
|
|
|
Tags: code
|
|
|
|
|
|
|
|
Aliases: code-block-style
|
|
|
|
|
|
|
|
Parameters: style ("consistent", "fenced", "indented"; default "consistent")
|
|
|
|
|
|
|
|
This rule is triggered when unwanted or different code block styles are used in
|
|
|
|
the same document.
|
|
|
|
|
|
|
|
In the default configuration this rule reports a violation for the following document:
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
## MD047 - Files should end with a single newline character
|
|
|
|
|
|
|
|
Tags: blank_lines
|
|
|
|
|
|
|
|
Aliases: single-trailing-newline
|
|
|
|
|
2020-06-21 23:11:33 -07:00
|
|
|
Fixable: Most violations can be fixed by tooling
|
|
|
|
|
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.
|
|
|
|
More information: <https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file>.
|
|
|
|
|
2019-10-08 21:10:02 -07:00
|
|
|
<a name="md048"></a>
|
|
|
|
|
|
|
|
## MD048 - Code fence style
|
|
|
|
|
|
|
|
Tags: code
|
|
|
|
|
|
|
|
Aliases: code-fence-style
|
|
|
|
|
|
|
|
Parameters: style ("consistent", "tilde", "backtick"; default "consistent")
|
|
|
|
|
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.
|