Change "header" to "heading" across the library

This should be backward compatible, as all "header" aliases are still
available, though documented as discouraged for future use.
This commit is contained in:
Milos Levacic 2018-03-19 23:39:42 +01:00 committed by David Anson
parent e938f421a9
commit 45424cf459
148 changed files with 861 additions and 699 deletions

View file

@ -46,9 +46,9 @@ playground for learning and exploring.
## Rules / Aliases
* **[MD001](doc/Rules.md#md001)** *header-increment* - Header levels should only increment by one level at a time
* **[MD002](doc/Rules.md#md002)** *first-header-h1* - First header should be a top level header
* **[MD003](doc/Rules.md#md003)** *header-style* - Header style
* **[MD001](doc/Rules.md#md001)** *heading-increment, header-increment* - Heading levels should only increment by one level at a time
* **[MD002](doc/Rules.md#md002)** *first-heading-h1, first-header-h1* - First heading should be a top level heading
* **[MD003](doc/Rules.md#md003)** *heading-style, header-style* - Heading style
* **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style
* **[MD005](doc/Rules.md#md005)** *list-indent* - Inconsistent indentation for list items at the same level
* **[MD006](doc/Rules.md#md006)** *ul-start-left* - Consider starting bulleted lists at the beginning of the line
@ -59,15 +59,15 @@ playground for learning and exploring.
* **[MD012](doc/Rules.md#md012)** *no-multiple-blanks* - Multiple consecutive blank lines
* **[MD013](doc/Rules.md#md013)** *line-length* - Line length
* **[MD014](doc/Rules.md#md014)** *commands-show-output* - Dollar signs used before commands without showing output
* **[MD018](doc/Rules.md#md018)** *no-missing-space-atx* - No space after hash on atx style header
* **[MD019](doc/Rules.md#md019)** *no-multiple-space-atx* - Multiple spaces after hash on atx style header
* **[MD020](doc/Rules.md#md020)** *no-missing-space-closed-atx* - No space inside hashes on closed atx style header
* **[MD021](doc/Rules.md#md021)** *no-multiple-space-closed-atx* - Multiple spaces inside hashes on closed atx style header
* **[MD022](doc/Rules.md#md022)** *blanks-around-headers* - Headers should be surrounded by blank lines
* **[MD023](doc/Rules.md#md023)** *header-start-left* - Headers must start at the beginning of the line
* **[MD024](doc/Rules.md#md024)** *no-duplicate-header* - Multiple headers with the same content
* **[MD025](doc/Rules.md#md025)** *single-h1* - Multiple top level headers in the same document
* **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in header
* **[MD018](doc/Rules.md#md018)** *no-missing-space-atx* - No space after hash on atx style heading
* **[MD019](doc/Rules.md#md019)** *no-multiple-space-atx* - Multiple spaces after hash on atx style heading
* **[MD020](doc/Rules.md#md020)** *no-missing-space-closed-atx* - No space inside hashes on closed atx style heading
* **[MD021](doc/Rules.md#md021)** *no-multiple-space-closed-atx* - Multiple spaces inside hashes on closed atx style heading
* **[MD022](doc/Rules.md#md022)** *blanks-around-headings, blanks-around-headers* - Headings should be surrounded by blank lines
* **[MD023](doc/Rules.md#md023)** *heading-start-left, header-start-left* - Headings must start at the beginning of the line
* **[MD024](doc/Rules.md#md024)** *no-duplicate-heading, no-duplicate-header* - Multiple headings with the same content
* **[MD025](doc/Rules.md#md025)** *single-h1* - Multiple top level headings in the same document
* **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in heading
* **[MD027](doc/Rules.md#md027)** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol
* **[MD028](doc/Rules.md#md028)** *no-blanks-blockquote* - Blank line inside blockquote
* **[MD029](doc/Rules.md#md029)** *ol-prefix* - Ordered list item prefix
@ -77,19 +77,23 @@ playground for learning and exploring.
* **[MD033](doc/Rules.md#md033)** *no-inline-html* - Inline HTML
* **[MD034](doc/Rules.md#md034)** *no-bare-urls* - Bare URL used
* **[MD035](doc/Rules.md#md035)** *hr-style* - Horizontal rule style
* **[MD036](doc/Rules.md#md036)** *no-emphasis-as-header* - Emphasis used instead of a header
* **[MD036](doc/Rules.md#md036)** *no-emphasis-as-heading, no-emphasis-as-header* - Emphasis used instead of a heading
* **[MD037](doc/Rules.md#md037)** *no-space-in-emphasis* - Spaces inside emphasis markers
* **[MD038](doc/Rules.md#md038)** *no-space-in-code* - Spaces inside code span elements
* **[MD039](doc/Rules.md#md039)** *no-space-in-links* - Spaces inside link text
* **[MD040](doc/Rules.md#md040)** *fenced-code-language* - Fenced code blocks should have a language specified
* **[MD041](doc/Rules.md#md041)** *first-line-h1* - First line in file should be a top level header
* **[MD041](doc/Rules.md#md041)** *first-line-h1* - First line in file should be a top level heading
* **[MD042](doc/Rules.md#md042)** *no-empty-links* - No empty links
* **[MD043](doc/Rules.md#md043)** *required-headers* - Required header structure
* **[MD043](doc/Rules.md#md043)** *required-headings, required-headers* - Required heading structure
* **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
* **[MD045](doc/Rules.md#md045)** *no-alt-text* - Images should have alternate text (alt text)
See [Rules.md](doc/Rules.md) for more details.
> All rules with `heading` as part of their name are also available as `header`
> aliases, e.g. `heading-increment` is also available as `header-increment`.
> This is provided for backward compatibility, though its usage is discouraged.
## Tags
* **accessibility** - MD045
@ -101,6 +105,8 @@ See [Rules.md](doc/Rules.md) for more details.
* **code** - MD014, MD031, MD038, MD040
* **emphasis** - MD036, MD037
* **hard_tab** - MD010
* **headings** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
MD024, MD025, MD026, MD036, MD041, MD043
* **headers** - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023,
MD024, MD025, MD026, MD036, MD041, MD043
* **hr** - MD035
@ -473,13 +479,13 @@ Output:
```text
bad.string: 3: MD010/no-hard-tabs Hard tabs [Column: 19]
bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#bad.string"]
bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#This string fails some rules."]
bad.string: 1: MD041/first-line-h1 First line in file should be a top level header [Context: "#bad.string"]
bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.string"]
bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This string fails some rules."]
bad.string: 1: MD041/first-line-h1 First line in file should be a top level heading [Context: "#bad.string"]
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level header [Context: "#bad.md"]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
```
Or invoke `markdownlint.sync` for a synchronous call:
@ -513,19 +519,19 @@ Output:
"errorRange": [ 17, 1 ] },
{ "lineNumber": 1,
"ruleNames": [ "MD018", "no-missing-space-atx" ],
"ruleDescription": "No space after hash on atx style header",
"ruleDescription": "No space after hash on atx style heading",
"errorDetail": null,
"errorContext": "#bad.md",
"errorRange": [ 1, 2 ] },
{ "lineNumber": 3,
"ruleNames": [ "MD018", "no-missing-space-atx" ],
"ruleDescription": "No space after hash on atx style header",
"ruleDescription": "No space after hash on atx style heading",
"errorDetail": null,
"errorContext": "#This file fails\tsome rules.",
"errorRange": [ 1, 2 ] },
{ "lineNumber": 1,
"ruleNames": [ "MD041", "first-line-h1" ],
"ruleDescription": "First line in file should be a top level header",
"ruleDescription": "First line in file should be a top level heading",
"errorDetail": null,
"errorContext": "#bad.md",
"errorRange": null }
@ -561,9 +567,9 @@ Output:
```text
[00:00:00] Starting 'markdownlint'...
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level header [Context: "#bad.md"]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
[00:00:00] Finished 'markdownlint' after 10 ms
```
@ -602,9 +608,9 @@ Output:
Running "markdownlint:example" (markdownlint) task
Warning:
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style header [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level header [Context: "#bad.md"]
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
bad.md: 1: MD041/first-line-h1 First line in file should be a top level heading [Context: "#bad.md"]
Use --force to continue.
```

View file

@ -6,62 +6,62 @@ versions of the examples.
<a name="md001"></a>
## MD001 - Header levels should only increment by one level at a time
## MD001 - Heading levels should only increment by one level at a time
Tags: headers
Tags: headings, headers
Aliases: header-increment
Aliases: heading-increment, header-increment
This rule is triggered when you skip header levels in a markdown document, for
This rule is triggered when you skip heading levels in a markdown document, for
example:
```markdown
# Header 1
# Heading 1
### Header 3
### Heading 3
We skipped out a 2nd level header in this document
We skipped out a 2nd level heading in this document
```
When using multiple header levels, nested headers should increase by only one
When using multiple heading levels, nested headings should increase by only one
level at a time:
```markdown
# Header 1
# Heading 1
## Header 2
## Heading 2
### Header 3
### Heading 3
#### Header 4
#### Heading 4
## Another Header 2
## Another Heading 2
### Another Header 3
### Another Heading 3
```
<a name="md002"></a>
## MD002 - First header should be a top level header
## MD002 - First heading should be a top level heading
Tags: headers
Tags: headings, headers
Aliases: first-header-h1
Aliases: first-heading-h1, first-header-h1
Parameters: level (number; default 1)
This rule is triggered when the first header in the document isn't a h1 header:
This rule is triggered when the first heading in the document isn't a h1 heading:
```markdown
## This isn't a H1 header
## This isn't a H1 heading
### Another header
### Another heading
```
The first header in the document should be a h1 header:
The first heading in the document should be a h1 heading:
```markdown
# Start with a H1 header
# Start with a H1 heading
## Then use a H2 for subsections
```
@ -71,16 +71,16 @@ cases where an h1 is added externally.
<a name="md003"></a>
## MD003 - Header style
## MD003 - Heading style
Tags: headers
Tags: headings, headers
Aliases: header-style
Aliases: heading-style, header-style
Parameters: style ("consistent", "atx", "atx_closed", "setext",
"setext_with_atx", "setext_with_atx_closed"; default "consistent")
This rule is triggered when different header styles (atx, setext, and 'closed'
This rule is triggered when different heading styles (atx, setext, and 'closed'
atx) are used in the same document:
```markdown
@ -92,7 +92,7 @@ Setext style H1
===============
```
Be consistent with the style of header used in a document:
Be consistent with the style of heading used in a document:
```markdown
# ATX style H1
@ -101,7 +101,7 @@ Be consistent with the style of header used in a document:
```
The setext_with_atx and setext_with_atx_closed doc styles allow atx-style
headers of level 3 or more in documents with setext style headers:
headings of level 3 or more in documents with setext style headings:
```markdown
Setext style H1
@ -113,7 +113,7 @@ Setext style H2
### ATX style H3
```
Note: the configured header style can be a specific style to use (atx,
Note: the configured heading style can be a specific style to use (atx,
atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
that the usage be consistent within the document.
@ -416,7 +416,9 @@ Tags: line_length
Aliases: line-length
Parameters: line_length, code_blocks, tables, headers (number; default 80, boolean; default true)
Parameters: line_length, code_blocks, tables, headings, headers (number; default 80, boolean; default true)
> If a `headings` parameter is not provided, `headers` will be checked instead for backward compatibility.
This rule is triggered when there are lines that are longer than the
configured line length (default: 80 characters). To fix this, split the line
@ -426,8 +428,8 @@ This rule has an exception where there is no whitespace beyond the configured
line length. This allows you to still include items such as long URLs without
being forced to break them in the middle.
You have the option to exclude this rule for code blocks, tables, or headers.
To do so, set the `code_blocks`, `tables`, or `headers` parameter(s) to false.
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.
Code blocks are included in this rule by default since it is often a
requirement for document readability, and tentatively compatible with code
@ -478,185 +480,185 @@ for more information.
<a name="md018"></a>
## MD018 - No space after hash on atx style header
## MD018 - No space after hash on atx style heading
Tags: headers, atx, spaces
Tags: headings, headers, atx, spaces
Aliases: no-missing-space-atx
This rule is triggered when spaces are missing after the hash characters
in an atx style header:
in an atx style heading:
```markdown
#Header 1
#Heading 1
##Header 2
##Heading 2
```
To fix this, separate the header text from the hash character by a single
To fix this, separate the heading text from the hash character by a single
space:
```markdown
# Header 1
# Heading 1
## Header 2
## Heading 2
```
<a name="md019"></a>
## MD019 - Multiple spaces after hash on atx style header
## MD019 - Multiple spaces after hash on atx style heading
Tags: headers, atx, spaces
Tags: headings, headers, atx, spaces
Aliases: no-multiple-space-atx
This rule is triggered when more than one space is used to separate the
header text from the hash characters in an atx style header:
heading text from the hash characters in an atx style heading:
```markdown
# Header 1
# Heading 1
## Header 2
## Heading 2
```
To fix this, separate the header text from the hash character by a single
To fix this, separate the heading text from the hash character by a single
space:
```markdown
# Header 1
# Heading 1
## Header 2
## Heading 2
```
<a name="md020"></a>
## MD020 - No space inside hashes on closed atx style header
## MD020 - No space inside hashes on closed atx style heading
Tags: headers, atx_closed, spaces
Tags: headings, headers, atx_closed, spaces
Aliases: no-missing-space-closed-atx
This rule is triggered when spaces are missing inside the hash characters
in a closed atx style header:
in a closed atx style heading:
```markdown
#Header 1#
#Heading 1#
##Header 2##
##Heading 2##
```
To fix this, separate the header text from the hash character by a single
To fix this, separate the heading text from the hash character by a single
space:
```markdown
# Header 1 #
# Heading 1 #
## Header 2 ##
## Heading 2 ##
```
Note: this rule will fire if either side of the header is missing spaces.
Note: this rule will fire if either side of the heading is missing spaces.
<a name="md021"></a>
## MD021 - Multiple spaces inside hashes on closed atx style header
## MD021 - Multiple spaces inside hashes on closed atx style heading
Tags: headers, atx_closed, spaces
Tags: headings, headers, atx_closed, spaces
Aliases: no-multiple-space-closed-atx
This rule is triggered when more than one space is used to separate the
header text from the hash characters in a closed atx style header:
heading text from the hash characters in a closed atx style heading:
```markdown
# Header 1 #
# Heading 1 #
## Header 2 ##
## Heading 2 ##
```
To fix this, separate the header text from the hash character by a single
To fix this, separate the heading text from the hash character by a single
space:
```markdown
# Header 1 #
# Heading 1 #
## Header 2 ##
## Heading 2 ##
```
Note: this rule will fire if either side of the header contains multiple
Note: this rule will fire if either side of the heading contains multiple
spaces.
<a name="md022"></a>
## MD022 - Headers should be surrounded by blank lines
## MD022 - Headings should be surrounded by blank lines
Tags: headers, blank_lines
Tags: headings, headers, blank_lines
Aliases: blanks-around-headers
Aliases: blanks-around-headings, blanks-around-headers
This rule is triggered when headers (any style) are either not preceded or not
This rule is triggered when headings (any style) are either not preceded or not
followed by a blank line:
```markdown
# Header 1
# Heading 1
Some text
Some more text
## Header 2
## Heading 2
```
To fix this, ensure that all headers have a blank line both before and after
(except where the header is at the beginning or end of the document):
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):
```markdown
# Header 1
# Heading 1
Some text
Some more text
## Header 2
## Heading 2
```
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will
not parse headers that don't have a blank line before, and will parse them as
not parse headings that don't have a blank line before, and will parse them as
regular text.
<a name="md023"></a>
## MD023 - Headers must start at the beginning of the line
## MD023 - Headings must start at the beginning of the line
Tags: headers, spaces
Tags: headings, headers, spaces
Aliases: header-start-left
Aliases: heading-start-left, header-start-left
This rule is triggered when a header is indented by one or more spaces:
This rule is triggered when a heading is indented by one or more spaces:
```markdown
Some text
# Indented header
# Indented heading
```
To fix this, ensure that all headers start at the beginning of the line:
To fix this, ensure that all headings start at the beginning of the line:
```markdown
Some text
# Header
# Heading
```
Rationale: Headers that don't start at the beginning of the line will not be
parsed as headers, and will instead appear as regular text.
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.
<a name="md024"></a>
## MD024 - Multiple headers with the same content
## MD024 - Multiple headings with the same content
Tags: headers
Tags: headings, headers
Aliases: no-duplicate-header
Aliases: no-duplicate-heading, no-duplicate-header
This rule is triggered if there are multiple headers in the document that have
This rule is triggered if there are multiple headings in the document that have
the same text:
```markdown
@ -665,7 +667,7 @@ the same text:
## Some text
```
To fix this, ensure that the content of each header is different:
To fix this, ensure that the content of each heading is different:
```markdown
# Some text
@ -673,76 +675,76 @@ To fix this, ensure that the content of each header is different:
## Some more text
```
Rationale: Some markdown parses generate anchors for headers based on the
header name, and having headers with the same content can cause problems with
Rationale: Some markdown parses generate anchors for headings based on the
heading name, and having headings with the same content can cause problems with
this.
<a name="md025"></a>
## MD025 - Multiple top level headers in the same document
## MD025 - Multiple top level headings in the same document
Tags: headers
Tags: headings, headers
Aliases: single-h1
Parameters: level (number; default 1)
This rule is triggered when a top level header is in use (the first line of
the file is a h1 header), and more than one h1 header is in use in the
This rule is triggered when a top level heading is in use (the first line of
the file is a h1 heading), and more than one h1 heading is in use in the
document:
```markdown
# Top level header
# Top level heading
# Another top level header
# Another top level heading
```
To fix, structure your document so that there is a single h1 header that is
the title for the document, and all later headers are h2 or lower level
headers:
To fix, structure your document so that there is a single h1 heading that is
the title for the document, and all later headings are h2 or lower level
headings:
```markdown
# Title
## Header
## Heading
## Another header
## Another heading
```
Rationale: A top level header is a h1 on the first line of the file, and
Rationale: A top level heading is a h1 on the first line of the file, and
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 header.
should be contained within this heading.
Note: The `level` parameter can be used to change the top level (ex: to h2) in
cases where an h1 is added externally.
<a name="md026"></a>
## MD026 - Trailing punctuation in header
## MD026 - Trailing punctuation in heading
Tags: headers
Tags: headings, headers
Aliases: no-trailing-punctuation
Parameters: punctuation (string; default ".,;:!?")
This rule is triggered on any header that has a punctuation character as the
This rule is triggered on any heading that has a punctuation character as the
last character in the line:
```markdown
# This is a header.
# This is a heading.
```
To fix this, remove any trailing punctuation:
```markdown
# This is a header
# This is a heading
```
Note: The punctuation parameter can be used to specify what characters class
as punctuation at the end of the header. For example, you can set it to
`".,;:!"` to allow headers with question marks in them, such as might be used
as punctuation at the end of the heading. For example, you can set it to
`".,;:!"` to allow headings with question marks in them, such as might be used
in an FAQ.
<a name="md027"></a>
@ -1027,13 +1029,13 @@ Parameters: allowed_elements (array of string; default empty)
This rule is triggered whenever raw HTML is used in a markdown document:
```markdown
<h1>Inline HTML header</h1>
<h1>Inline HTML heading</h1>
```
To fix this, use 'pure' markdown instead of including raw HTML:
```markdown
# Markdown header
# Markdown heading
```
Rationale: Raw HTML is allowed in markdown, but this rule is included for
@ -1118,16 +1120,16 @@ is allowed.
<a name="md036"></a>
## MD036 - Emphasis used instead of a header
## MD036 - Emphasis used instead of a heading
Tags: headers, emphasis
Tags: headings, headers, emphasis
Aliases: no-emphasis-as-header
Aliases: no-emphasis-as-heading, no-emphasis-as-header
Parameters: punctuation (string; default ".,;:!?")
This check looks for instances where emphasized (i.e. bold or italic) text is
used to separate sections, where a header should be used instead:
used to separate sections, where a heading should be used instead:
```markdown
**My document**
@ -1139,7 +1141,7 @@ _Another section_
Consectetur adipiscing elit, sed do eiusmod.
```
To fix this, use markdown headers instead of emphasized text to denote
To fix this, use markdown headings instead of emphasized text to denote
sections:
```markdown
@ -1277,27 +1279,27 @@ echo Hello world
<a name="md041"></a>
## MD041 - First line in file should be a top level header
## MD041 - First line in file should be a top level heading
Tags: headers
Tags: headings, headers
Aliases: first-line-h1
Parameters: level, front_matter_title (number; default 1, string; default "^\s*title:")
This rule is triggered when the first line in the file isn't a top level (h1)
header:
heading:
```markdown
This is a file without a header
This is a file without a heading
```
To fix this, add a header to the top of your file:
To fix this, add a heading to the top of your file:
```markdown
# File with header
# File with heading
This is a file with a top level header
This is a file with a top level heading
```
The `level` parameter can be used to change the top level (ex: to h2) in cases
@ -1343,16 +1345,18 @@ But non-empty fragments will not:
<a name="md043"></a>
## MD043 - Required header structure
## MD043 - Required heading structure
Tags: headers
Tags: headings, headers
Aliases: required-headers
Aliases: required-headings, required-headers
Parameters: headers (array of string; default `null` for disabled)
Parameters: headings, headers (array of string; default `null` for disabled)
This rule is triggered when the headers in a file do not match the array of
headers passed to the rule. It can be used to enforce a standard header
> If a `headings` parameter is not provided, `headers` will be checked instead for backward compatibility.
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
structure for a set of files.
To require exactly the following structure:
@ -1363,7 +1367,7 @@ To require exactly the following structure:
### Detail
```
Set the `headers` parameter to:
Set the `headings` parameter to:
```json
[
@ -1373,7 +1377,7 @@ Set the `headers` parameter to:
]
```
To allow optional headers as with the following structure:
To allow optional headings as with the following structure:
```markdown
# Head
@ -1383,8 +1387,8 @@ To allow optional headers as with the following structure:
### Notes (optional)
```
Use the special value `"*"` meaning "one or more unspecified headers" and set
the `headers` parameter to:
Use the special value `"*"` meaning "one or more unspecified headings" and set
the `headings` parameter to:
```json
[
@ -1397,10 +1401,10 @@ the `headers` parameter to:
```
When an error is detected, this rule outputs the line number of the first
problematic header (otherwise, it outputs the last line number of the file).
problematic heading (otherwise, it outputs the last line number of the file).
Note that while the `headers` parameter uses the "## Text" ATX header style for
simplicity, a file may use any supported header style.
Note that while the `headings` parameter uses the "## Text" ATX heading style for
simplicity, a file may use any supported heading style.
<a name="md044"></a>

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD001", "header-increment" ],
"description": "Header levels should only increment by one level at a time",
"tags": [ "headers" ],
"names": [ "MD001", "heading-increment", "header-increment" ],
"description": "Heading levels should only increment by one level at a time",
"tags": [ "headings", "headers" ],
"function": function MD001(params, onError) {
var prevLevel = 0;
shared.filterTokens(params, "heading_open", function forToken(token) {

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD002", "first-header-h1" ],
"description": "First header should be a top level header",
"tags": [ "headers" ],
"names": [ "MD002", "first-heading-h1", "first-header-h1" ],
"description": "First heading should be a top level heading",
"tags": [ "headings", "headers" ],
"function": function MD002(params, onError) {
var level = params.config.level || 1;
var tag = "h" + level;

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD003", "header-style" ],
"description": "Header style",
"tags": [ "headers" ],
"names": [ "MD003", "heading-style", "header-style" ],
"description": "Heading style",
"tags": [ "headings", "headers" ],
"function": function MD003(params, onError) {
var style = params.config.style || "consistent";
shared.filterTokens(params, "heading_open", function forToken(token) {

View file

@ -16,12 +16,15 @@ module.exports = {
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
var tables = params.config.tables;
var includeTables = (tables === undefined) ? true : !!tables;
var headers = params.config.headers;
var includeHeaders = (headers === undefined) ? true : !!headers;
var headerLineNumbers = [];
if (!includeHeaders) {
var headings = params.config.headings;
if (headings === undefined) {
headings = params.config.headers;
}
var includeHeadings = (headings === undefined) ? true : !!headings;
var headingLineNumbers = [];
if (!includeHeadings) {
shared.forEachHeading(params, function forHeading(heading) {
headerLineNumbers.push(heading.lineNumber);
headingLineNumbers.push(heading.lineNumber);
});
}
var tokenTypeMap = {
@ -51,7 +54,7 @@ module.exports = {
var lineNumber = lineIndex + 1;
if ((includeCodeBlocks || !inCode) &&
(includeTables || !inTable) &&
(includeHeaders || (headerLineNumbers.indexOf(lineNumber)) < 0) &&
(includeHeadings || (headingLineNumbers.indexOf(lineNumber)) < 0) &&
(linkOnlyLineNumbers.indexOf(lineNumber) < 0) &&
longLineRe.test(line) &&
!labelRe.test(line)) {

View file

@ -6,13 +6,13 @@ var shared = require("./shared");
module.exports = {
"names": [ "MD018", "no-missing-space-atx" ],
"description": "No space after hash on atx style header",
"tags": [ "headers", "atx", "spaces" ],
"description": "No space after hash on atx style heading",
"tags": [ "headings", "headers", "atx", "spaces" ],
"function": function MD018(params, onError) {
shared.forEachLine(function forLine(line, lineIndex, inCode) {
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
null, shared.rangeFromRegExp(line, shared.atxHeaderSpaceRe));
null, shared.rangeFromRegExp(line, shared.atxHeadingSpaceRe));
}
});
}

View file

@ -6,15 +6,15 @@ var shared = require("./shared");
module.exports = {
"names": [ "MD019", "no-multiple-space-atx" ],
"description": "Multiple spaces after hash on atx style header",
"tags": [ "headers", "atx", "spaces" ],
"description": "Multiple spaces after hash on atx style heading",
"tags": [ "headings", "headers", "atx", "spaces" ],
"function": function MD019(params, onError) {
shared.filterTokens(params, "heading_open", function forToken(token) {
if ((shared.headingStyleFor(token) === "atx") &&
/^#+\s\s/.test(token.line)) {
shared.addErrorContext(onError, token.lineNumber, token.line.trim(),
null, null,
shared.rangeFromRegExp(token.line, shared.atxHeaderSpaceRe));
shared.rangeFromRegExp(token.line, shared.atxHeadingSpaceRe));
}
});
}

View file

@ -4,12 +4,12 @@
var shared = require("./shared");
var atxClosedHeaderNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
var atxClosedHeadingNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
module.exports = {
"names": [ "MD020", "no-missing-space-closed-atx" ],
"description": "No space inside hashes on closed atx style header",
"tags": [ "headers", "atx_closed", "spaces" ],
"description": "No space inside hashes on closed atx style heading",
"tags": [ "headings", "headers", "atx_closed", "spaces" ],
"function": function MD020(params, onError) {
shared.forEachLine(function forLine(line, lineIndex, inCode) {
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
@ -17,7 +17,7 @@ module.exports = {
var right = /[^#\s]#+$/.test(line);
if (left || right) {
shared.addErrorContext(onError, lineIndex + 1, line.trim(), left,
right, shared.rangeFromRegExp(line, atxClosedHeaderNoSpaceRe));
right, shared.rangeFromRegExp(line, atxClosedHeadingNoSpaceRe));
}
}
});

View file

@ -4,12 +4,12 @@
var shared = require("./shared");
var atxClosedHeaderSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
var atxClosedHeadingSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
module.exports = {
"names": [ "MD021", "no-multiple-space-closed-atx" ],
"description": "Multiple spaces inside hashes on closed atx style header",
"tags": [ "headers", "atx_closed", "spaces" ],
"description": "Multiple spaces inside hashes on closed atx style heading",
"tags": [ "headings", "headers", "atx_closed", "spaces" ],
"function": function MD021(params, onError) {
shared.filterTokens(params, "heading_open", function forToken(token) {
if (shared.headingStyleFor(token) === "atx_closed") {
@ -18,7 +18,7 @@ module.exports = {
if (left || right) {
shared.addErrorContext(onError, token.lineNumber, token.line.trim(),
left, right,
shared.rangeFromRegExp(token.line, atxClosedHeaderSpaceRe));
shared.rangeFromRegExp(token.line, atxClosedHeadingSpaceRe));
}
}
});

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD022", "blanks-around-headers" ],
"description": "Headers should be surrounded by blank lines",
"tags": [ "headers", "blank_lines" ],
"names": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
"description": "Headings should be surrounded by blank lines",
"tags": [ "headings", "headers", "blank_lines" ],
"function": function MD022(params, onError) {
var prevHeadingLineNumber = 0;
var prevMaxLineIndex = -1;

View file

@ -4,17 +4,17 @@
var shared = require("./shared");
var spaceBeforeHeaderRe = /^\s+\S/;
var spaceBeforeHeadingRe = /^\s+\S/;
module.exports = {
"names": [ "MD023", "header-start-left" ],
"description": "Headers must start at the beginning of the line",
"tags": [ "headers", "spaces" ],
"names": [ "MD023", "heading-start-left", "header-start-left" ],
"description": "Headings must start at the beginning of the line",
"tags": [ "headings", "headers", "spaces" ],
"function": function MD023(params, onError) {
shared.filterTokens(params, "heading_open", function forToken(token) {
if (spaceBeforeHeaderRe.test(token.line)) {
if (spaceBeforeHeadingRe.test(token.line)) {
shared.addErrorContext(onError, token.lineNumber, token.line, null,
null, shared.rangeFromRegExp(token.line, spaceBeforeHeaderRe));
null, shared.rangeFromRegExp(token.line, spaceBeforeHeadingRe));
}
});
}

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD024", "no-duplicate-header" ],
"description": "Multiple headers with the same content",
"tags": [ "headers" ],
"names": [ "MD024", "no-duplicate-heading", "no-duplicate-header" ],
"description": "Multiple headings with the same content",
"tags": [ "headings", "headers" ],
"function": function MD024(params, onError) {
var knownContent = [];
shared.forEachHeading(params, function forHeading(heading, content) {

View file

@ -6,8 +6,8 @@ var shared = require("./shared");
module.exports = {
"names": [ "MD025", "single-h1" ],
"description": "Multiple top level headers in the same document",
"tags": [ "headers" ],
"description": "Multiple top level headings in the same document",
"tags": [ "headings", "headers" ],
"function": function MD025(params, onError) {
var level = params.config.level || 1;
var tag = "h" + level;

View file

@ -6,8 +6,8 @@ var shared = require("./shared");
module.exports = {
"names": [ "MD026", "no-trailing-punctuation" ],
"description": "Trailing punctuation in header",
"tags": [ "headers" ],
"description": "Trailing punctuation in heading",
"tags": [ "headings", "headers" ],
"function": function MD026(params, onError) {
var punctuation = params.config.punctuation || ".,;:!?";
var trailingPunctuationRe = new RegExp("[" + punctuation + "]$");

View file

@ -5,9 +5,9 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD036", "no-emphasis-as-header" ],
"description": "Emphasis used instead of a header",
"tags": [ "headers", "emphasis" ],
"names": [ "MD036", "no-emphasis-as-heading", "no-emphasis-as-header" ],
"description": "Emphasis used instead of a heading",
"tags": [ "headings", "headers", "emphasis" ],
"function": function MD036(params, onError) {
var punctuation = params.config.punctuation || ".,;:!?";
var re = new RegExp("[" + punctuation + "]$");

View file

@ -6,8 +6,8 @@ var shared = require("./shared");
module.exports = {
"names": [ "MD041", "first-line-h1" ],
"description": "First line in file should be a top level header",
"tags": [ "headers" ],
"description": "First line in file should be a top level heading",
"tags": [ "headings", "headers" ],
"function": function MD041(params, onError) {
var level = params.config.level || 1;
var frontMatterTitle = params.config.front_matter_title;

View file

@ -5,12 +5,12 @@
var shared = require("./shared");
module.exports = {
"names": [ "MD043", "required-headers" ],
"description": "Required header structure",
"tags": [ "headers" ],
"names": [ "MD043", "required-headings", "required-headers" ],
"description": "Required heading structure",
"tags": [ "headings", "headers" ],
"function": function MD043(params, onError) {
var requiredHeaders = params.config.headers;
if (requiredHeaders) {
var requiredHeadings = params.config.headings || params.config.headers;
if (requiredHeadings) {
var levels = {};
[ 1, 2, 3, 4, 5, 6 ].forEach(function forLevel(level) {
levels["h" + level] = "######".substr(-level);
@ -21,7 +21,7 @@ module.exports = {
shared.forEachHeading(params, function forHeading(heading, content) {
if (!errorCount) {
var actual = levels[heading.tag] + " " + content;
var expected = requiredHeaders[i++] || "[None]";
var expected = requiredHeadings[i++] || "[None]";
if (expected === "*") {
optional = true;
} else if (expected.toLowerCase() === actual.toLowerCase()) {
@ -35,9 +35,9 @@ module.exports = {
}
}
});
if ((i < requiredHeaders.length) && !errorCount) {
if ((i < requiredHeadings.length) && !errorCount) {
shared.addErrorContext(onError, params.lines.length,
requiredHeaders[i]);
requiredHeadings[i]);
}
}
}

View file

@ -14,7 +14,7 @@ var inlineCommentRe =
module.exports.inlineCommentRe = inlineCommentRe;
// Regular expressions for range matching
module.exports.atxHeaderSpaceRe = /^#+\s*\S/;
module.exports.atxHeadingSpaceRe = /^#+\s*\S/;
module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s]*/i;
module.exports.listItemMarkerRe = /^[\s>]*(?:[*+-]|\d+\.)\s+/;

View file

@ -42,7 +42,7 @@ rules.forEach(function forRule(rule) {
case "MD025":
scheme.properties = {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
}
@ -51,7 +51,7 @@ rules.forEach(function forRule(rule) {
case "MD003":
scheme.properties = {
"style": {
"description": "Header style",
"description": "Heading style",
"type": "string",
"enum": [
"consistent",
@ -139,8 +139,13 @@ rules.forEach(function forRule(rule) {
"type": "boolean",
"default": true
},
"headings": {
"description": "Include headings",
"type": "boolean",
"default": true
},
"headers": {
"description": "Include headers",
"description": "Include headings",
"type": "boolean",
"default": true
}
@ -218,7 +223,7 @@ rules.forEach(function forRule(rule) {
case "MD041":
scheme.properties = {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
},
@ -231,8 +236,16 @@ rules.forEach(function forRule(rule) {
break;
case "MD043":
scheme.properties = {
"headings": {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
},
"default": null
},
"headers": {
"description": "List of headers",
"description": "List of headings",
"type": "array",
"items": {
"type": "string"

View file

@ -13,17 +13,22 @@
"default": null
},
"MD001": {
"description": "MD001/header-increment - Header levels should only increment by one level at a time",
"description": "MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time",
"type": "boolean",
"default": true
},
"heading-increment": {
"description": "MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time",
"type": "boolean",
"default": true
},
"header-increment": {
"description": "MD001/header-increment - Header levels should only increment by one level at a time",
"description": "MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time",
"type": "boolean",
"default": true
},
"MD002": {
"description": "MD002/first-header-h1 - First header should be a top level header",
"description": "MD002/first-heading-h1/first-header-h1 - First heading should be a top level heading",
"type": [
"boolean",
"object"
@ -31,7 +36,23 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
}
},
"additionalProperties": false
},
"first-heading-h1": {
"description": "MD002/first-heading-h1/first-header-h1 - First heading should be a top level heading",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"level": {
"description": "Heading level",
"type": "integer",
"default": 1
}
@ -39,7 +60,7 @@
"additionalProperties": false
},
"first-header-h1": {
"description": "MD002/first-header-h1 - First header should be a top level header",
"description": "MD002/first-heading-h1/first-header-h1 - First heading should be a top level heading",
"type": [
"boolean",
"object"
@ -47,7 +68,7 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
}
@ -55,7 +76,7 @@
"additionalProperties": false
},
"MD003": {
"description": "MD003/header-style - Header style",
"description": "MD003/heading-style/header-style - Heading style",
"type": [
"boolean",
"object"
@ -63,7 +84,31 @@
"default": true,
"properties": {
"style": {
"description": "Header style",
"description": "Heading style",
"type": "string",
"enum": [
"consistent",
"atx",
"atx_closed",
"setext",
"setext_with_atx",
"setext_with_atx_closed"
],
"default": "consistent"
}
},
"additionalProperties": false
},
"heading-style": {
"description": "MD003/heading-style/header-style - Heading style",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"style": {
"description": "Heading style",
"type": "string",
"enum": [
"consistent",
@ -79,7 +124,7 @@
"additionalProperties": false
},
"header-style": {
"description": "MD003/header-style - Header style",
"description": "MD003/heading-style/header-style - Heading style",
"type": [
"boolean",
"object"
@ -87,7 +132,7 @@
"default": true,
"properties": {
"style": {
"description": "Header style",
"description": "Heading style",
"type": "string",
"enum": [
"consistent",
@ -339,8 +384,13 @@
"type": "boolean",
"default": true
},
"headings": {
"description": "Include headings",
"type": "boolean",
"default": true
},
"headers": {
"description": "Include headers",
"description": "Include headings",
"type": "boolean",
"default": true
}
@ -370,8 +420,13 @@
"type": "boolean",
"default": true
},
"headings": {
"description": "Include headings",
"type": "boolean",
"default": true
},
"headers": {
"description": "Include headers",
"description": "Include headings",
"type": "boolean",
"default": true
}
@ -389,77 +444,92 @@
"default": true
},
"MD018": {
"description": "MD018/no-missing-space-atx - No space after hash on atx style header",
"description": "MD018/no-missing-space-atx - No space after hash on atx style heading",
"type": "boolean",
"default": true
},
"no-missing-space-atx": {
"description": "MD018/no-missing-space-atx - No space after hash on atx style header",
"description": "MD018/no-missing-space-atx - No space after hash on atx style heading",
"type": "boolean",
"default": true
},
"MD019": {
"description": "MD019/no-multiple-space-atx - Multiple spaces after hash on atx style header",
"description": "MD019/no-multiple-space-atx - Multiple spaces after hash on atx style heading",
"type": "boolean",
"default": true
},
"no-multiple-space-atx": {
"description": "MD019/no-multiple-space-atx - Multiple spaces after hash on atx style header",
"description": "MD019/no-multiple-space-atx - Multiple spaces after hash on atx style heading",
"type": "boolean",
"default": true
},
"MD020": {
"description": "MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style header",
"description": "MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style heading",
"type": "boolean",
"default": true
},
"no-missing-space-closed-atx": {
"description": "MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style header",
"description": "MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style heading",
"type": "boolean",
"default": true
},
"MD021": {
"description": "MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style header",
"description": "MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading",
"type": "boolean",
"default": true
},
"no-multiple-space-closed-atx": {
"description": "MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style header",
"description": "MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading",
"type": "boolean",
"default": true
},
"MD022": {
"description": "MD022/blanks-around-headers - Headers should be surrounded by blank lines",
"description": "MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines",
"type": "boolean",
"default": true
},
"blanks-around-headings": {
"description": "MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines",
"type": "boolean",
"default": true
},
"blanks-around-headers": {
"description": "MD022/blanks-around-headers - Headers should be surrounded by blank lines",
"description": "MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines",
"type": "boolean",
"default": true
},
"MD023": {
"description": "MD023/header-start-left - Headers must start at the beginning of the line",
"description": "MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line",
"type": "boolean",
"default": true
},
"heading-start-left": {
"description": "MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line",
"type": "boolean",
"default": true
},
"header-start-left": {
"description": "MD023/header-start-left - Headers must start at the beginning of the line",
"description": "MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line",
"type": "boolean",
"default": true
},
"MD024": {
"description": "MD024/no-duplicate-header - Multiple headers with the same content",
"description": "MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content",
"type": "boolean",
"default": true
},
"no-duplicate-heading": {
"description": "MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content",
"type": "boolean",
"default": true
},
"no-duplicate-header": {
"description": "MD024/no-duplicate-header - Multiple headers with the same content",
"description": "MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content",
"type": "boolean",
"default": true
},
"MD025": {
"description": "MD025/single-h1 - Multiple top level headers in the same document",
"description": "MD025/single-h1 - Multiple top level headings in the same document",
"type": [
"boolean",
"object"
@ -467,7 +537,7 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
}
@ -475,7 +545,7 @@
"additionalProperties": false
},
"single-h1": {
"description": "MD025/single-h1 - Multiple top level headers in the same document",
"description": "MD025/single-h1 - Multiple top level headings in the same document",
"type": [
"boolean",
"object"
@ -483,7 +553,7 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
}
@ -491,7 +561,7 @@
"additionalProperties": false
},
"MD026": {
"description": "MD026/no-trailing-punctuation - Trailing punctuation in header",
"description": "MD026/no-trailing-punctuation - Trailing punctuation in heading",
"type": [
"boolean",
"object"
@ -507,7 +577,7 @@
"additionalProperties": false
},
"no-trailing-punctuation": {
"description": "MD026/no-trailing-punctuation - Trailing punctuation in header",
"description": "MD026/no-trailing-punctuation - Trailing punctuation in heading",
"type": [
"boolean",
"object"
@ -747,7 +817,23 @@
"additionalProperties": false
},
"MD036": {
"description": "MD036/no-emphasis-as-header - Emphasis used instead of a header",
"description": "MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"punctuation": {
"description": "Punctuation characters",
"type": "string",
"default": ".,;:!?"
}
},
"additionalProperties": false
},
"no-emphasis-as-heading": {
"description": "MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading",
"type": [
"boolean",
"object"
@ -763,7 +849,7 @@
"additionalProperties": false
},
"no-emphasis-as-header": {
"description": "MD036/no-emphasis-as-header - Emphasis used instead of a header",
"description": "MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading",
"type": [
"boolean",
"object"
@ -819,7 +905,7 @@
"default": true
},
"MD041": {
"description": "MD041/first-line-h1 - First line in file should be a top level header",
"description": "MD041/first-line-h1 - First line in file should be a top level heading",
"type": [
"boolean",
"object"
@ -827,7 +913,7 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
},
@ -840,7 +926,7 @@
"additionalProperties": false
},
"first-line-h1": {
"description": "MD041/first-line-h1 - First line in file should be a top level header",
"description": "MD041/first-line-h1 - First line in file should be a top level heading",
"type": [
"boolean",
"object"
@ -848,7 +934,7 @@
"default": true,
"properties": {
"level": {
"description": "Header level",
"description": "Heading level",
"type": "integer",
"default": 1
},
@ -871,15 +957,50 @@
"default": true
},
"MD043": {
"description": "MD043/required-headers - Required header structure",
"description": "MD043/required-headings/required-headers - Required heading structure",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"headings": {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
},
"default": null
},
"headers": {
"description": "List of headers",
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
},
"default": null
}
},
"additionalProperties": false
},
"required-headings": {
"description": "MD043/required-headings/required-headers - Required heading structure",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"headings": {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
},
"default": null
},
"headers": {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
@ -890,15 +1011,23 @@
"additionalProperties": false
},
"required-headers": {
"description": "MD043/required-headers - Required header structure",
"description": "MD043/required-headings/required-headers - Required heading structure",
"type": [
"boolean",
"object"
],
"default": true,
"properties": {
"headings": {
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
},
"default": null
},
"headers": {
"description": "List of headers",
"description": "List of headings",
"type": "array",
"items": {
"type": "string"
@ -966,6 +1095,11 @@
"type": "boolean",
"default": true
},
"headings": {
"description": "headings - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023, MD024, MD025, MD026, MD036, MD041, MD043",
"type": "boolean",
"default": true
},
"headers": {
"description": "headers - MD001, MD002, MD003, MD018, MD019, MD020, MD021, MD022, MD023, MD024, MD025, MD026, MD036, MD041, MD043",
"type": "boolean",

View file

@ -1,3 +0,0 @@
## A level 2 top level header
## Another one {MD025}

View file

@ -0,0 +1,3 @@
## A level 2 top level heading
## Another one {MD025}

View file

@ -1,17 +0,0 @@
#Header 1 {MD020} #
## Header 2 {MD020}##
##Header 3 {MD020}##
## Header 4 {MD021} ##
## Header 5 {MD021} ##
## Header 6 {MD021} ##
## Header 7 {MD021} ##
## Header 8 \#
## Header 9 \#

View file

@ -0,0 +1,17 @@
#Heading 1 {MD020} #
## Heading 2 {MD020}##
##Heading 3 {MD020}##
## Heading 4 {MD021} ##
## Heading 5 {MD021} ##
## Heading 6 {MD021} ##
## Heading 7 {MD021} ##
## Heading 8 \#
## Heading 9 \#

View file

@ -1,5 +0,0 @@
#Header 1 {MD018}
## Header 2 {MD019}
## Header 3 {MD019}

View file

@ -0,0 +1,5 @@
#Heading 1 {MD018}
## Heading 2 {MD019}
## Heading 3 {MD019}

View file

@ -2,9 +2,9 @@
"default": true,
"MD041": true,
"MD043": {
"headers": [
"## Header 1 {MD002} {MD041}",
"#### Header 2 {MD001}",
"headings": [
"## Heading 1 {MD002} {MD041}",
"#### Heading 2 {MD001}",
"# Broken"
]
},

View file

@ -1,8 +1,8 @@
## Header 1 {MD002} {MD041}
## Heading 1 {MD002} {MD041}
#### Header 2 {MD001}
#### Heading 2 {MD001}
# Header 3 {MD003} {MD043} #
# Heading 3 {MD003} {MD043} #
* list
+ list {MD004} {MD006} {MD007} {MD030}
@ -22,22 +22,22 @@ long line long line long line long line long line long line long line long line
$ dollar {MD014}
#Header 4 {MD018}
#Heading 4 {MD018}
# Header 5 {MD019}
# Heading 5 {MD019}
#Header 6 {MD020} #
# Header 7 {MD021} {MD022} {MD023} {MD003} #
#Heading 6 {MD020} #
# Heading 7 {MD021} {MD022} {MD023} {MD003} #
# Header 8
# Heading 8
# Header 8
# Heading 8
{MD024:34}
Note: Can not break MD025 and MD002 in the same file
# Header 9 {MD026}.
# Heading 9 {MD026}.
> {MD027}
@ -62,7 +62,7 @@ http://example.com/page {MD034}
{MD035:61}
_Section {MD036} Header_
_Section {MD036} Heading_
Emphasis *with * space {MD037}

View file

@ -1,3 +1,3 @@
# Header
# Heading
Text

View file

@ -1,4 +1,4 @@
# Header
# Heading
```js

View file

@ -1,4 +1,4 @@
# header
# heading
```fence
$ code

View file

@ -1,24 +1,24 @@
[
{
"lineNumber": 3,
"ruleNames": [ "MD001", "header-increment" ],
"ruleDescription": "Header levels should only increment by one level at a time",
"ruleNames": [ "MD001", "heading-increment", "header-increment" ],
"ruleDescription": "Heading levels should only increment by one level at a time",
"errorDetail": "Expected: h3; Actual: h4",
"errorContext": null,
"errorRange": null
},
{
"lineNumber": 1,
"ruleNames": [ "MD002", "first-header-h1" ],
"ruleDescription": "First header should be a top level header",
"ruleNames": [ "MD002", "first-heading-h1", "first-header-h1" ],
"ruleDescription": "First heading should be a top level heading",
"errorDetail": "Expected: h1; Actual: h2",
"errorContext": null,
"errorRange": null
},
{
"lineNumber": 5,
"ruleNames": [ "MD003", "header-style" ],
"ruleDescription": "Header style",
"ruleNames": [ "MD003", "heading-style", "header-style" ],
"ruleDescription": "Heading style",
"errorDetail": "Expected: atx; Actual: atx_closed",
"errorContext": null,
"errorRange": null

View file

@ -1,4 +1,4 @@
# Top level header
# Top level heading
<!-- markdownlint-disable MD003 -->

View file

@ -34,7 +34,7 @@
{
"lineNumber": 12,
"ruleNames": [ "MD018", "no-missing-space-atx" ],
"ruleDescription": "No space after hash on atx style header",
"ruleDescription": "No space after hash on atx style heading",
"errorDetail": null,
"errorContext": "##No space A",
"errorRange": [1, 3]
@ -42,7 +42,7 @@
{
"lineNumber": 14,
"ruleNames": [ "MD019", "no-multiple-space-atx" ],
"ruleDescription": "Multiple spaces after hash on atx style header",
"ruleDescription": "Multiple spaces after hash on atx style heading",
"errorDetail": null,
"errorContext": "## Multiple spaces B",
"errorRange": [1, 5]
@ -50,7 +50,7 @@
{
"lineNumber": 16,
"ruleNames": [ "MD020", "no-missing-space-closed-atx" ],
"ruleDescription": "No space inside hashes on closed atx style header",
"ruleDescription": "No space inside hashes on closed atx style heading",
"errorDetail": null,
"errorContext": "##No space C ##",
"errorRange": [1, 3]
@ -58,7 +58,7 @@
{
"lineNumber": 18,
"ruleNames": [ "MD020", "no-missing-space-closed-atx" ],
"ruleDescription": "No space inside hashes on closed atx style header",
"ruleDescription": "No space inside hashes on closed atx style heading",
"errorDetail": null,
"errorContext": "## No space D##",
"errorRange": [13, 3]
@ -66,7 +66,7 @@
{
"lineNumber": 20,
"ruleNames": [ "MD021", "no-multiple-space-closed-atx" ],
"ruleDescription": "Multiple spaces inside hashes on closed atx style header",
"ruleDescription": "Multiple spaces inside hashes on closed atx style heading",
"errorDetail": null,
"errorContext": "## Multiple spaces E ##",
"errorRange": [1, 5]
@ -74,7 +74,7 @@
{
"lineNumber": 22,
"ruleNames": [ "MD021", "no-multiple-space-closed-atx" ],
"ruleDescription": "Multiple spaces inside hashes on closed atx style header",
"ruleDescription": "Multiple spaces inside hashes on closed atx style heading",
"errorDetail": null,
"errorContext": "## Multiple spaces F ##",
"errorRange": [20, 5]

View file

@ -1,24 +1,24 @@
[
{
"lineNumber": 1,
"ruleNames": [ "MD022", "blanks-around-headers" ],
"ruleDescription": "Headers should be surrounded by blank lines",
"ruleNames": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
"ruleDescription": "Headings should be surrounded by blank lines",
"errorDetail": null,
"errorContext": "# Heading",
"errorRange": null
},
{
"lineNumber": 1,
"ruleNames": [ "MD023", "header-start-left" ],
"ruleDescription": "Headers must start at the beginning of the line",
"ruleNames": [ "MD023", "heading-start-left", "header-start-left" ],
"ruleDescription": "Headings must start at the beginning of the line",
"errorDetail": null,
"errorContext": " # Heading",
"errorRange": [1, 2]
},
{
"lineNumber": 4,
"ruleNames": [ "MD024", "no-duplicate-header" ],
"ruleDescription": "Multiple headers with the same content",
"ruleNames": [ "MD024", "no-duplicate-heading", "no-duplicate-header" ],
"ruleDescription": "Multiple headings with the same content",
"errorDetail": null,
"errorContext": "# Heading",
"errorRange": null
@ -26,7 +26,7 @@
{
"lineNumber": 4,
"ruleNames": [ "MD025", "single-h1" ],
"ruleDescription": "Multiple top level headers in the same document",
"ruleDescription": "Multiple top level headings in the same document",
"errorDetail": null,
"errorContext": "# Heading",
"errorRange": null
@ -34,7 +34,7 @@
{
"lineNumber": 6,
"ruleNames": [ "MD026", "no-trailing-punctuation" ],
"ruleDescription": "Trailing punctuation in header",
"ruleDescription": "Trailing punctuation in heading",
"errorDetail": "Punctuation: '.'",
"errorContext": null,
"errorRange": [19, 1]

View file

@ -41,8 +41,8 @@
},
{
"lineNumber": 13,
"ruleNames": [ "MD036", "no-emphasis-as-header" ],
"ruleDescription": "Emphasis used instead of a header",
"ruleNames": [ "MD036", "no-emphasis-as-heading", "no-emphasis-as-header" ],
"ruleDescription": "Emphasis used instead of a heading",
"errorDetail": null,
"errorContext": "Emphasis",
"errorRange": null

View file

@ -2,8 +2,8 @@
"default": true,
"MD041": true,
"MD043": {
"headers": [
"# Header"
"headings": [
"# Heading"
]
},
"MD044": {

View file

@ -1,4 +1,4 @@
Not a header
Not a heading
An [empty]() link

View file

@ -2,9 +2,9 @@
{
"lineNumber": 1,
"ruleNames": [ "MD041", "first-line-h1" ],
"ruleDescription": "First line in file should be a top level header",
"ruleDescription": "First line in file should be a top level heading",
"errorDetail": null,
"errorContext": "Not a header",
"errorContext": "Not a heading",
"errorRange": null
},
{
@ -41,10 +41,10 @@
},
{
"lineNumber": 20,
"ruleNames": [ "MD043", "required-headers" ],
"ruleDescription": "Required header structure",
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
"ruleDescription": "Required heading structure",
"errorDetail": null,
"errorContext": "# Header",
"errorContext": "# Heading",
"errorRange": null
},
{

View file

@ -10,7 +10,7 @@
{
"lineNumber": 4,
"ruleNames": [ "MD041", "first-line-h1" ],
"ruleDescription": "First line in file should be a top level header",
"ruleDescription": "First line in file should be a top level heading",
"errorDetail": null,
"errorContext": "Text",
"errorRange": null

View file

@ -35,6 +35,6 @@ This is another **normal** paragraph with some text in it. This also should
not trigger the rule.
**This is an entire paragraph that has been emphasized, and shouldn't be
detected as a header because it's on multiple lines**
detected as a heading because it's on multiple lines**
**This also shouldn't be detected as a header as it ends in punctuation.**
**This also shouldn't be detected as a heading as it ends in punctuation.**

View file

@ -1,4 +1,4 @@
# header
# heading
text
```fence {MD031}

View file

@ -1 +0,0 @@
## Header {MD002}

View file

@ -1,2 +0,0 @@
Header {MD002}
--------------

View file

@ -1 +0,0 @@
# Header

View file

@ -1,2 +0,0 @@
Header
======

View file

@ -0,0 +1 @@
## Heading {MD002}

View file

@ -0,0 +1,2 @@
Heading {MD002}
--------------

View file

@ -0,0 +1 @@
# Heading

View file

@ -0,0 +1,2 @@
Heading
=======

View file

@ -1,3 +0,0 @@
# First line is a top level header
This shouldn't trigger MD041

View file

@ -1,4 +0,0 @@
First line top level header
===========================
This shouldn't trigger MD041

View file

@ -0,0 +1,3 @@
# First line is a top level heading
This shouldn't trigger MD041

View file

@ -0,0 +1,4 @@
First line top level heading
============================
This shouldn't trigger MD041

View file

@ -1,6 +1,6 @@
+++
date = "2017-01-26T22:17:00+02:00"
alternate = "My document title and header"
alternate = "My document title and heading"
+++
Some plain text here.

View file

@ -1,5 +1,5 @@
---
---
# Header
# Heading
# Another {MD025}

View file

@ -4,6 +4,6 @@ notitle: "Welcome to Jekyll!"
date: 2015-11-17 16:16:01 -0600
categories: jekyll update
---
# Top level header
# Top level heading
Front matter from [Jekyll documentation](https://jekyllrb.com/docs/posts/#a-typical-post).

View file

@ -4,6 +4,6 @@ title: "Welcome to Jekyll!"
date: 2015-11-17 16:16:01 -0600
categories: jekyll update
---
# Top level header
# Top level heading
Front matter from [Jekyll documentation](https://jekyllrb.com/docs/posts/#a-typical-post).

View file

@ -1,6 +1,6 @@
+++
date = "2017-01-26T22:17:00+02:00"
title = "My document title and header"
title = "My document title and heading"
+++
Some plain text here.

View file

@ -3,7 +3,7 @@ layout: post
title: Title with ---
tags: front matter
---
## Header {MD002}
## Heading {MD002}
---

View file

@ -1,6 +1,6 @@
---
front: matter
---
# Header 1
# Heading 1
## Header 2
## Heading 2

View file

@ -1,11 +0,0 @@
# Header 1
## Header 2
## Header 1
### Header 2
## Header 3
{MD024:5} {MD024:7}

View file

@ -1,7 +0,0 @@
# Header
### Header 3 {MD001}
## Header 2
#### Header 4 {MD001}

View file

@ -1,11 +0,0 @@
Header 1
========
Header 2
--------
## Header 2 {MD003}
### Header 3
#### Header 4 {MD003} ####

View file

@ -1,11 +0,0 @@
Header 1
========
Header 2
--------
## Header 2 {MD003} ##
### Header 3 ###
#### Header 4 {MD003}

View file

@ -1,12 +0,0 @@
# Header 1
## Header 2 {MD022}
Some text
## Header 3 {MD022}
Some text
## Header 4 {MD022}
## Header 5
* This shouldn't trigger MD022, but did because of some bug where we tried to
#catch headers that kramdown didn't parse correctly.

View file

@ -1,15 +0,0 @@
Header 1
========
Header 2 {MD022}
----------------
Some text {MD022} {MD025}
Header 3
================
Some text {MD022} {MD025}
Header 4
================
Some text
Header 5
--------

View file

@ -0,0 +1,11 @@
# Heading 1
## Heading 2
## Heading 1
### Heading 2
## Heading 3
{MD024:5} {MD024:7}

7
test/headings_bad.md Normal file
View file

@ -0,0 +1,7 @@
# Heading
### Heading 3 {MD001}
## Heading 2
#### Heading 4 {MD001}

View file

@ -0,0 +1,11 @@
Heading 1
=========
Heading 2
---------
## Heading 2 {MD003}
### Heading 3
#### Heading 4 {MD003} ####

View file

@ -0,0 +1,11 @@
Heading 1
=========
Heading 2
---------
## Heading 2 {MD003} ##
### Heading 3 ###
#### Heading 4 {MD003}

View file

@ -0,0 +1,12 @@
# Heading 1
## Heading 2 {MD022}
Some text
## Heading 3 {MD022}
Some text
## Heading 4 {MD022}
## Heading 5
* This shouldn't trigger MD022, but did because of some bug where we tried to
#catch headings that kramdown didn't parse correctly.

View file

@ -0,0 +1,15 @@
Heading 1
=========
Heading 2 {MD022}
-----------------
Some text {MD022} {MD025}
Heading 3
=================
Some text {MD022} {MD025}
Heading 4
=================
Some text
Heading 5
---------

View file

@ -1,6 +1,6 @@
Some text
# Header 1 {MD023}
# Heading 1 {MD023}
Setext style fully indented {MD023}
===================================
@ -16,5 +16,5 @@ Some text
```
* This is another case where MD023 shouldn't be triggered
# Test {MD023} Valid header for CommonMark (see section 5.2)
# Test {MD023} Also valid header for CommonMark
# Test {MD023} Valid heading for CommonMark (see section 5.2)
# Test {MD023} Also valid heading for CommonMark

View file

@ -4,4 +4,4 @@ draft = true
title = "Good to Great Book Review"
+++
# Header 1
# Heading 1

View file

@ -5,4 +5,4 @@ title = "Good to Great Book Review"
+++
# Header 1 {MD041}
# Heading 1 {MD041}

View file

@ -1,6 +0,0 @@
# Header 1 {MD003} #
## Header 2
Header 3 {MD003}
----------------

View file

@ -1,6 +0,0 @@
# Header 1 #
## Header 2 {MD003}
Header 3 {MD003}
----------------

View file

@ -1,6 +0,0 @@
# Header 1 {MD003} #
## Header 2 {MD003}
Header 3
--------

View file

@ -0,0 +1,6 @@
# Heading 1 {MD003} #
## Heading 2
Heading 3 {MD003}
-----------------

View file

@ -0,0 +1,6 @@
# Heading 1 #
## Heading 2 {MD003}
Heading 3 {MD003}
-----------------

Some files were not shown because too many files have changed in this diff Show more