Add short links to each rule in Rules.md, update README.md to use them (fixes #54).

This commit is contained in:
David Anson 2017-05-07 12:48:04 -07:00
parent da529ac286
commit b436640918
5 changed files with 133 additions and 43 deletions

8
.markdownlint.json Normal file
View file

@ -0,0 +1,8 @@
{
"line-length": false,
"no-inline-html": {
"allowed_elements": [
"a"
]
}
}

View file

@ -45,46 +45,46 @@ playground for learning and exploring.
## Rules / Aliases ## Rules / Aliases
* **MD001** *header-increment* - Header levels should only increment by one level at a time * **[MD001](doc/Rules.md#md001)** *header-increment* - Header levels should only increment by one level at a time
* **MD002** *first-header-h1* - First header should be a top level header * **[MD002](doc/Rules.md#md002)** *first-header-h1* - First header should be a top level header
* **MD003** *header-style* - Header style * **[MD003](doc/Rules.md#md003)** *header-style* - Header style
* **MD004** *ul-style* - Unordered list style * **[MD004](doc/Rules.md#md004)** *ul-style* - Unordered list style
* **MD005** *list-indent* - Inconsistent indentation for list items at the same level * **[MD005](doc/Rules.md#md005)** *list-indent* - Inconsistent indentation for list items at the same level
* **MD006** *ul-start-left* - Consider starting bulleted lists at the beginning of the line * **[MD006](doc/Rules.md#md006)** *ul-start-left* - Consider starting bulleted lists at the beginning of the line
* **MD007** *ul-indent* - Unordered list indentation * **[MD007](doc/Rules.md#md007)** *ul-indent* - Unordered list indentation
* **MD009** *no-trailing-spaces* - Trailing spaces * **[MD009](doc/Rules.md#md009)** *no-trailing-spaces* - Trailing spaces
* **MD010** *no-hard-tabs* - Hard tabs * **[MD010](doc/Rules.md#md010)** *no-hard-tabs* - Hard tabs
* **MD011** *no-reversed-links* - Reversed link syntax * **[MD011](doc/Rules.md#md011)** *no-reversed-links* - Reversed link syntax
* **MD012** *no-multiple-blanks* - Multiple consecutive blank lines * **[MD012](doc/Rules.md#md012)** *no-multiple-blanks* - Multiple consecutive blank lines
* **MD013** *line-length* - Line length * **[MD013](doc/Rules.md#md013)** *line-length* - Line length
* **MD014** *commands-show-output* - Dollar signs used before commands without showing output * **[MD014](doc/Rules.md#md014)** *commands-show-output* - Dollar signs used before commands without showing output
* **MD018** *no-missing-space-atx* - No space after hash on atx style header * **[MD018](doc/Rules.md#md018)** *no-missing-space-atx* - No space after hash on atx style header
* **MD019** *no-multiple-space-atx* - Multiple spaces after hash on atx style header * **[MD019](doc/Rules.md#md019)** *no-multiple-space-atx* - Multiple spaces after hash on atx style header
* **MD020** *no-missing-space-closed-atx* - No space inside hashes on closed atx style header * **[MD020](doc/Rules.md#md020)** *no-missing-space-closed-atx* - No space inside hashes on closed atx style header
* **MD021** *no-multiple-space-closed-atx* - Multiple spaces 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** *blanks-around-headers* - Headers should be surrounded by blank lines * **[MD022](doc/Rules.md#md022)** *blanks-around-headers* - Headers should be surrounded by blank lines
* **MD023** *header-start-left* - Headers must start at the beginning of the line * **[MD023](doc/Rules.md#md023)** *header-start-left* - Headers must start at the beginning of the line
* **MD024** *no-duplicate-header* - Multiple headers with the same content * **[MD024](doc/Rules.md#md024)** *no-duplicate-header* - Multiple headers with the same content
* **MD025** *single-h1* - Multiple top level headers in the same document * **[MD025](doc/Rules.md#md025)** *single-h1* - Multiple top level headers in the same document
* **MD026** *no-trailing-punctuation* - Trailing punctuation in header * **[MD026](doc/Rules.md#md026)** *no-trailing-punctuation* - Trailing punctuation in header
* **MD027** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol * **[MD027](doc/Rules.md#md027)** *no-multiple-space-blockquote* - Multiple spaces after blockquote symbol
* **MD028** *no-blanks-blockquote* - Blank line inside blockquote * **[MD028](doc/Rules.md#md028)** *no-blanks-blockquote* - Blank line inside blockquote
* **MD029** *ol-prefix* - Ordered list item prefix * **[MD029](doc/Rules.md#md029)** *ol-prefix* - Ordered list item prefix
* **MD030** *list-marker-space* - Spaces after list markers * **[MD030](doc/Rules.md#md030)** *list-marker-space* - Spaces after list markers
* **MD031** *blanks-around-fences* - Fenced code blocks should be surrounded by blank lines * **[MD031](doc/Rules.md#md031)** *blanks-around-fences* - Fenced code blocks should be surrounded by blank lines
* **MD032** *blanks-around-lists* - Lists should be surrounded by blank lines * **[MD032](doc/Rules.md#md032)** *blanks-around-lists* - Lists should be surrounded by blank lines
* **MD033** *no-inline-html* - Inline HTML * **[MD033](doc/Rules.md#md033)** *no-inline-html* - Inline HTML
* **MD034** *no-bare-urls* - Bare URL used * **[MD034](doc/Rules.md#md034)** *no-bare-urls* - Bare URL used
* **MD035** *hr-style* - Horizontal rule style * **[MD035](doc/Rules.md#md035)** *hr-style* - Horizontal rule style
* **MD036** *no-emphasis-as-header* - Emphasis used instead of a header * **[MD036](doc/Rules.md#md036)** *no-emphasis-as-header* - Emphasis used instead of a header
* **MD037** *no-space-in-emphasis* - Spaces inside emphasis markers * **[MD037](doc/Rules.md#md037)** *no-space-in-emphasis* - Spaces inside emphasis markers
* **MD038** *no-space-in-code* - Spaces inside code span elements * **[MD038](doc/Rules.md#md038)** *no-space-in-code* - Spaces inside code span elements
* **MD039** *no-space-in-links* - Spaces inside link text * **[MD039](doc/Rules.md#md039)** *no-space-in-links* - Spaces inside link text
* **MD040** *fenced-code-language* - Fenced code blocks should have a language specified * **[MD040](doc/Rules.md#md040)** *fenced-code-language* - Fenced code blocks should have a language specified
* **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 header
* **MD042** *no-empty-links* - No empty links * **[MD042](doc/Rules.md#md042)** *no-empty-links* - No empty links
* **MD043** *required-headers* - Required header structure * **[MD043](doc/Rules.md#md043)** *required-headers* - Required header structure
* **MD044** *proper-names* - Proper names should have the correct capitalization * **[MD044](doc/Rules.md#md044)** *proper-names* - Proper names should have the correct capitalization
See [Rules.md](doc/Rules.md) for more details. See [Rules.md](doc/Rules.md) for more details.

View file

@ -4,6 +4,8 @@ This document contains a description of all rules, what they are checking for,
as well as an examples of documents that break the rule and corrected as well as an examples of documents that break the rule and corrected
versions of the examples. versions of the examples.
<a name="md001"></a>
## MD001 - Header levels should only increment by one level at a time ## MD001 - Header levels should only increment by one level at a time
Tags: headers Tags: headers
@ -34,6 +36,8 @@ level at a time:
### Another Header 3 ### Another Header 3
<a name="md002"></a>
## MD002 - First header should be a top level header ## MD002 - First header should be a top level header
Tags: headers Tags: headers
@ -57,6 +61,8 @@ The first header in the document should be a h1 header:
Note: The `level` parameter can be used to change the top level (ex: to h2) in Note: The `level` parameter can be used to change the top level (ex: to h2) in
cases where an h1 is added externally. cases where an h1 is added externally.
<a name="md003"></a>
## MD003 - Header style ## MD003 - Header style
Tags: headers Tags: headers
@ -97,6 +103,8 @@ Note: the configured header style can be a specific style to use (atx,
atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
that the usage be consistent within the document. that the usage be consistent within the document.
<a name="md004"></a>
## MD004 - Unordered list style ## MD004 - Unordered list style
Tags: bullet, ul Tags: bullet, ul
@ -134,6 +142,8 @@ indent uses asterisk, the middle indent uses plus, and the inner-most indent use
* Item 4 * Item 4
+ Item 5 + Item 5
<a name="md005"></a>
## MD005 - Inconsistent indentation for list items at the same level ## MD005 - Inconsistent indentation for list items at the same level
Tags: bullet, ul, indentation Tags: bullet, ul, indentation
@ -156,6 +166,8 @@ for the list to fix it:
* Nested Item 2 * Nested Item 2
* Nested Item 3 * Nested Item 3
<a name="md006"></a>
## MD006 - Consider starting bulleted lists at the beginning of the line ## MD006 - Consider starting bulleted lists at the beginning of the line
Tags: bullet, ul, indentation Tags: bullet, ul, indentation
@ -193,6 +205,8 @@ instead.
- List item - List item
1. List item 1. List item
<a name="md007"></a>
## MD007 - Unordered list indentation ## MD007 - Unordered list indentation
Tags: bullet, ul, indentation Tags: bullet, ul, indentation
@ -232,6 +246,8 @@ 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 unordered (otherwise, extra indentation of ordered lists interferes with the
rule). rule).
<a name="md009"></a>
## MD009 - Trailing spaces ## MD009 - Trailing spaces
Tags: whitespace Tags: whitespace
@ -252,6 +268,8 @@ effect - you can't insert a br element with just a single trailing space, so
if you set br_spaces to 1, the exception will be disabled, just as if it was if you set br_spaces to 1, the exception will be disabled, just as if it was
set to the default of 0. set to the default of 0.
<a name="md010"></a>
## MD010 - Hard tabs ## MD010 - Hard tabs
Tags: whitespace, hard_tab Tags: whitespace, hard_tab
@ -280,6 +298,8 @@ 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 `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). handling of tabs by tools is often inconsistent (ex: using 4 vs. 8 spaces).
<a name="md011"></a>
## MD011 - Reversed link syntax ## MD011 - Reversed link syntax
Tags: links Tags: links
@ -300,6 +320,8 @@ Note: [Markdown Extra](https://en.wikipedia.org/wiki/Markdown_Extra)-style footn
For (example)[^1] For (example)[^1]
<a name="md012"></a>
## MD012 - Multiple consecutive blank lines ## MD012 - Multiple consecutive blank lines
Tags: whitespace, blank_lines Tags: whitespace, blank_lines
@ -328,6 +350,8 @@ lines inside code blocks.
Note: The `maximum` parameter can be used to configure the maximum number of Note: The `maximum` parameter can be used to configure the maximum number of
consecutive blank lines. consecutive blank lines.
<a name="md013"></a>
## MD013 - Line length ## MD013 - Line length
Tags: line_length Tags: line_length
@ -351,6 +375,8 @@ Code blocks are included in this rule by default since it is often a
requirement for document readability, and tentatively compatible with code requirement for document readability, and tentatively compatible with code
rules. Still, some languages do not lend themselves to short lines. rules. Still, some languages do not lend themselves to short lines.
<a name="md014"></a>
## MD014 - Dollar signs used before commands without showing output ## MD014 - Dollar signs used before commands without showing output
Tags: code Tags: code
@ -386,6 +412,8 @@ are omitted when they are not needed. See
<http://www.cirosantilli.com/markdown-styleguide/#dollar-signs-in-shell-code> <http://www.cirosantilli.com/markdown-styleguide/#dollar-signs-in-shell-code>
for more information. for more information.
<a name="md018"></a>
## MD018 - No space after hash on atx style header ## MD018 - No space after hash on atx style header
Tags: headers, atx, spaces Tags: headers, atx, spaces
@ -406,6 +434,8 @@ space:
## Header 2 ## Header 2
<a name="md019"></a>
## MD019 - Multiple spaces after hash on atx style header ## MD019 - Multiple spaces after hash on atx style header
Tags: headers, atx, spaces Tags: headers, atx, spaces
@ -426,6 +456,8 @@ space:
## Header 2 ## Header 2
<a name="md020"></a>
## MD020 - No space inside hashes on closed atx style header ## MD020 - No space inside hashes on closed atx style header
Tags: headers, atx_closed, spaces Tags: headers, atx_closed, spaces
@ -448,6 +480,8 @@ space:
Note: this rule will fire if either side of the header is missing spaces. Note: this rule will fire if either side of the header 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 header
Tags: headers, atx_closed, spaces Tags: headers, atx_closed, spaces
@ -471,6 +505,8 @@ space:
Note: this rule will fire if either side of the header contains multiple Note: this rule will fire if either side of the header contains multiple
spaces. spaces.
<a name="md022"></a>
## MD022 - Headers should be surrounded by blank lines ## MD022 - Headers should be surrounded by blank lines
Tags: headers, blank_lines Tags: headers, blank_lines
@ -501,6 +537,8 @@ 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 headers that don't have a blank line before, and will parse them as
regular text. regular text.
<a name="md023"></a>
## MD023 - Headers must start at the beginning of the line ## MD023 - Headers must start at the beginning of the line
Tags: headers, spaces Tags: headers, spaces
@ -522,6 +560,8 @@ To fix this, ensure that all headers start at the beginning of the line:
Rationale: Headers that don't start at the beginning of the line will not be 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. parsed as headers, and will instead appear as regular text.
<a name="md024"></a>
## MD024 - Multiple headers with the same content ## MD024 - Multiple headers with the same content
Tags: headers Tags: headers
@ -545,6 +585,8 @@ Rationale: Some markdown parses generate anchors for headers based on the
header name, and having headers with the same content can cause problems with header name, and having headers with the same content can cause problems with
this. this.
<a name="md025"></a>
## MD025 - Multiple top level headers in the same document ## MD025 - Multiple top level headers in the same document
Tags: headers Tags: headers
@ -579,6 +621,8 @@ should be contained within this header.
Note: The `level` parameter can be used to change the top level (ex: to h2) in Note: The `level` parameter can be used to change the top level (ex: to h2) in
cases where an h1 is added externally. cases where an h1 is added externally.
<a name="md026"></a>
## MD026 - Trailing punctuation in header ## MD026 - Trailing punctuation in header
Tags: headers Tags: headers
@ -601,6 +645,8 @@ 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 `".,;:!"` to allow headers with question marks in them, such as might be used
in an FAQ. in an FAQ.
<a name="md027"></a>
## MD027 - Multiple spaces after blockquote symbol ## MD027 - Multiple spaces after blockquote symbol
Tags: blockquote, whitespace, indentation Tags: blockquote, whitespace, indentation
@ -618,6 +664,8 @@ To fix, remove any extraneous space:
> This is a blockquote with correct > This is a blockquote with correct
> indentation. > indentation.
<a name="md028"></a>
## MD028 - Blank line inside blockquote ## MD028 - Blank line inside blockquote
Tags: blockquote, whitespace Tags: blockquote, whitespace
@ -653,6 +701,8 @@ 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 or more blank lines as the same blockquote, while others will treat them as
separate blockquotes. separate blockquotes.
<a name="md029"></a>
## MD029 - Ordered list item prefix ## MD029 - Ordered list item prefix
Tags: ol Tags: ol
@ -677,6 +727,8 @@ Example valid list if the style is configured as 'ordered':
2. Do that. 2. Do that.
3. Done. 3. Done.
<a name="md030"></a>
## MD030 - Spaces after list markers ## MD030 - Spaces after list markers
Tags: ol, ul, whitespace Tags: ol, ul, whitespace
@ -738,6 +790,8 @@ inside the list:
To fix this, ensure the correct number of spaces are used after list marker To fix this, ensure the correct number of spaces are used after list marker
for your selected document style. for your selected document style.
<a name="md031"></a>
## MD031 - Fenced code blocks should be surrounded by blank lines ## MD031 - Fenced code blocks should be surrounded by blank lines
Tags: code, blank_lines Tags: code, blank_lines
@ -775,6 +829,8 @@ and after (except where the block is at the beginning or end of the document):
Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will 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. not parse fenced code blocks that don't have blank lines before and after them.
<a name="md032"></a>
## MD032 - Lists should be surrounded by blank lines ## MD032 - Lists should be surrounded by blank lines
Tags: bullet, ul, ol, blank_lines Tags: bullet, ul, ol, blank_lines
@ -817,6 +873,8 @@ items with hanging indents are okay:
* This is * This is
okay okay
<a name="md033"></a>
## MD033 - Inline HTML ## MD033 - Inline HTML
Tags: html Tags: html
@ -839,6 +897,8 @@ who are rendering markdown documents in something other than HTML.
Note: To allow specific HTML elements, use the 'allowed_elements' parameter. Note: To allow specific HTML elements, use the 'allowed_elements' parameter.
<a name="md034"></a>
## MD034 - Bare URL used ## MD034 - Bare URL used
Tags: links, url Tags: links, url
@ -863,6 +923,8 @@ converted:
`http://www.example.com` `http://www.example.com`
<a name="md035"></a>
## MD035 - Horizontal rule style ## MD035 - Horizontal rule style
Tags: hr Tags: hr
@ -899,6 +961,8 @@ 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 the 'style' option is a string containing the exact horizontal rule text that
is allowed. is allowed.
<a name="md036"></a>
## MD036 - Emphasis used instead of a header ## MD036 - Emphasis used instead of a header
Tags: headers, emphasis Tags: headers, emphasis
@ -935,6 +999,8 @@ multi-line emphasized paragraphs, and paragraphs ending in punctuation.
Similarly to rule MD026, you can configure what characters are recognized as Similarly to rule MD026, you can configure what characters are recognized as
punctuation. punctuation.
<a name="md037"></a>
## MD037 - Spaces inside emphasis markers ## MD037 - Spaces inside emphasis markers
Tags: whitespace, emphasis Tags: whitespace, emphasis
@ -967,6 +1033,8 @@ aren't completely surrounded by spaces. This rule attempts to detect where
they were surrounded by spaces, but it appears that emphasized text was they were surrounded by spaces, but it appears that emphasized text was
intended by the author. intended by the author.
<a name="md038"></a>
## MD038 - Spaces inside code span elements ## MD038 - Spaces inside code span elements
Tags: whitespace, code Tags: whitespace, code
@ -991,6 +1059,8 @@ markers from an embedded backtick:
`` ` embedded backtick`` `` ` embedded backtick``
<a name="md039"></a>
## MD039 - Spaces inside link text ## MD039 - Spaces inside link text
Tags: whitespace, links Tags: whitespace, links
@ -1005,6 +1075,8 @@ To fix this, remove the spaces surrounding the link text:
[a link](http://www.example.com/) [a link](http://www.example.com/)
<a name="md040"></a>
## MD040 - Fenced code blocks should have a language specified ## MD040 - Fenced code blocks should have a language specified
Tags: code, language Tags: code, language
@ -1026,6 +1098,8 @@ To fix this, add a language specifier to the code block:
echo Hello world 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 header
Tags: headers Tags: headers
@ -1054,6 +1128,8 @@ violation. To use a different property name in front matter, specify the text
of a regular expression via the `front_matter_title` parameter. To disable the 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`. use of front matter by this rule, specify `""` for `front_matter_title`.
<a name="md042"></a>
## MD042 - No empty links ## MD042 - No empty links
Tags: links Tags: links
@ -1076,6 +1152,8 @@ But non-empty fragments will not:
[a valid fragment](#fragment) [a valid fragment](#fragment)
<a name="md043"></a>
## MD043 - Required header structure ## MD043 - Required header structure
Tags: headers Tags: headers
@ -1127,6 +1205,8 @@ problematic header (otherwise, it outputs the last line number of the file).
Note that while the `headers` parameter uses the "## Text" ATX header style for Note that while the `headers` parameter uses the "## Text" ATX header style for
simplicity, a file may use any supported header style. simplicity, a file may use any supported header style.
<a name="md044"></a>
## MD044 - Proper names should have the correct capitalization ## MD044 - Proper names should have the correct capitalization
Tags: spelling Tags: spelling

View file

@ -13,8 +13,9 @@ rules.forEach(function forRule(rule) {
allRuleNames.push(rule.name); allRuleNames.push(rule.name);
ruleNameToRule[rule.name] = rule; ruleNameToRule[rule.name] = rule;
// The following is useful for updating README.md // The following is useful for updating README.md
// console.log("* **" + rule.name + "** *" + // console.log(
// rule.aliases.join(", ") + "* - " + rule.desc); // "* **[" + rule.name + "](doc/Rules.md#" + rule.name.toLowerCase() +
// ")** *" + rule.aliases.join(", ") + "* - " + rule.desc);
rule.tags.forEach(function forTag(tag) { rule.tags.forEach(function forTag(tag) {
var tagUpper = tag.toUpperCase(); var tagUpper = tag.toUpperCase();
var ruleNames = idUpperToRuleNames[tagUpper] || []; var ruleNames = idUpperToRuleNames[tagUpper] || [];

View file

@ -968,7 +968,8 @@ module.exports.readme = function readme(test) {
test.ok(rule, test.ok(rule,
"Missing rule implementation for " + token.content + "."); "Missing rule implementation for " + token.content + ".");
if (rule) { if (rule) {
var expected = "**" + rule.name + "** *" + var expected = "**[" + rule.name + "](doc/Rules.md#" +
rule.name.toLowerCase() + ")** *" +
rule.aliases.join(", ") + "* - " + rule.desc; rule.aliases.join(", ") + "* - " + rule.desc;
test.equal(token.content, expected, "Rule mismatch."); test.equal(token.content, expected, "Rule mismatch.");
} }