markdownlint 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/CONTRIBUTING.md +4 -3
- package/README.md +25 -10
- package/demo/markdownlint-browser.js +3286 -2119
- package/doc/CustomRules.md +25 -13
- package/doc/Rules.md +106 -7
- package/doc/md013.md +8 -7
- package/doc/md034.md +5 -0
- package/doc/md044.md +10 -0
- package/doc/md049.md +3 -0
- package/doc/md050.md +3 -0
- package/doc/md051.md +26 -0
- package/doc/md058.md +48 -0
- package/helpers/README.md +3 -27
- package/helpers/helpers.js +60 -292
- package/helpers/micromark.cjs +153 -36
- package/helpers/package.json +2 -2
- package/lib/cache.js +62 -13
- package/lib/configuration-strict.d.ts +1185 -0
- package/lib/configuration.d.ts +3 -1173
- package/lib/constants.js +3 -2
- package/lib/markdownlint.d.ts +143 -61
- package/lib/markdownlint.js +151 -54
- package/lib/md001.js +17 -8
- package/lib/md003.js +16 -8
- package/lib/md004.js +57 -47
- package/lib/md005.js +7 -8
- package/lib/md007.js +13 -12
- package/lib/md009.js +52 -43
- package/lib/md010.js +50 -32
- package/lib/md011.js +18 -7
- package/lib/md012.js +19 -8
- package/lib/md013.js +46 -37
- package/lib/md014.js +37 -36
- package/lib/md018.js +20 -8
- package/lib/md019-md021.js +80 -0
- package/lib/md020.js +15 -6
- package/lib/md022.js +10 -12
- package/lib/md023.js +24 -22
- package/lib/md024.js +14 -8
- package/lib/md025.js +17 -9
- package/lib/md026.js +5 -6
- package/lib/md027.js +24 -43
- package/lib/md028.js +26 -14
- package/lib/md029.js +42 -33
- package/lib/md030.js +7 -8
- package/lib/md031.js +45 -22
- package/lib/md032.js +18 -30
- package/lib/md033.js +6 -4
- package/lib/md034.js +30 -9
- package/lib/md035.js +5 -3
- package/lib/md036.js +34 -39
- package/lib/md037.js +3 -0
- package/lib/md038.js +6 -5
- package/lib/md039.js +68 -52
- package/lib/md040.js +21 -21
- package/lib/md041.js +21 -26
- package/lib/md042.js +50 -36
- package/lib/md043.js +22 -13
- package/lib/md044.js +5 -2
- package/lib/md045.js +6 -4
- package/lib/md046.js +9 -8
- package/lib/md047.js +5 -2
- package/lib/md048.js +22 -13
- package/lib/md049-md050.js +19 -5
- package/lib/md051.js +18 -20
- package/lib/md052.js +5 -2
- package/lib/md053.js +5 -2
- package/lib/md054.js +12 -12
- package/lib/md055.js +10 -3
- package/lib/md056.js +18 -6
- package/lib/md058.js +43 -0
- package/lib/rules.js +11 -4
- package/package.json +22 -25
- package/schema/.markdownlint.jsonc +54 -51
- package/schema/.markdownlint.yaml +53 -50
- package/schema/ValidatingConfiguration.md +6 -8
- package/schema/markdownlint-config-schema-strict.json +1819 -0
- package/schema/markdownlint-config-schema.json +115 -105
- package/style/prettier.json +1 -0
- package/lib/md019.js +0 -39
- package/lib/md021.js +0 -62
package/doc/CustomRules.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Custom Rules
|
|
2
2
|
|
|
3
3
|
In addition to its built-in rules, `markdownlint` lets you enhance the linting
|
|
4
|
-
experience by passing
|
|
4
|
+
experience by passing an array of custom rules using the [`options.customRules`
|
|
5
5
|
property][options-custom-rules]. Custom rules can do everything the built-in
|
|
6
6
|
rules can and are defined inline or imported from another package ([keyword
|
|
7
|
-
`markdownlint-rule` on npm][markdownlint-rule]).
|
|
8
|
-
|
|
7
|
+
`markdownlint-rule` on npm][markdownlint-rule]). When defined by a file or
|
|
8
|
+
package, the export can be a single rule object (see below) or an array of them.
|
|
9
|
+
Custom rules can be disabled, enabled, and customized using the same syntax as
|
|
10
|
+
built-in rules.
|
|
9
11
|
|
|
10
12
|
## Implementing Simple Rules
|
|
11
13
|
|
|
@@ -28,11 +30,13 @@ the parsed input and a function to log any violations.
|
|
|
28
30
|
A simple rule implementation looks like:
|
|
29
31
|
|
|
30
32
|
```javascript
|
|
33
|
+
/** @type import("markdownlint").Rule */
|
|
31
34
|
module.exports = {
|
|
32
35
|
"names": [ "any-blockquote" ],
|
|
33
36
|
"description": "Rule that reports an error for any blockquote",
|
|
34
37
|
"information": new URL("https://example.com/rules/any-blockquote"),
|
|
35
38
|
"tags": [ "test" ],
|
|
39
|
+
"parser": "markdownit",
|
|
36
40
|
"function": function rule(params, onError) {
|
|
37
41
|
params.parsers.markdownit.tokens.filter(function filterToken(token) {
|
|
38
42
|
return token.type === "blockquote_open";
|
|
@@ -48,8 +52,7 @@ module.exports = {
|
|
|
48
52
|
};
|
|
49
53
|
```
|
|
50
54
|
|
|
51
|
-
A rule is implemented as an `Object
|
|
52
|
-
properties:
|
|
55
|
+
A rule is implemented as an `Object`:
|
|
53
56
|
|
|
54
57
|
- `names` is a required `Array` of `String` values that identify the rule in
|
|
55
58
|
output messages and config.
|
|
@@ -59,6 +62,9 @@ properties:
|
|
|
59
62
|
about the rule.
|
|
60
63
|
- `tags` is a required `Array` of `String` values that groups related rules for
|
|
61
64
|
easier customization.
|
|
65
|
+
- `parser` is a required `String` value `"markdownit" | "none"` that specifies
|
|
66
|
+
the parser data used via `params.parsers` (see below).
|
|
67
|
+
- Note: The value `"micromark"` is valid but is NOT currently supported.
|
|
62
68
|
- `asynchronous` is an optional `Boolean` value that indicates whether the rule
|
|
63
69
|
returns a `Promise` and runs asynchronously.
|
|
64
70
|
- `function` is a required `Function` that implements the rule and is passed two
|
|
@@ -66,8 +72,13 @@ properties:
|
|
|
66
72
|
- `params` is an `Object` with properties that describe the content being
|
|
67
73
|
analyzed:
|
|
68
74
|
- `name` is a `String` that identifies the input file/string.
|
|
69
|
-
- `
|
|
70
|
-
|
|
75
|
+
- `parsers` is an `Object` with properties corresponding to the value of
|
|
76
|
+
`parser` in the rule definition (see above).
|
|
77
|
+
- `markdownit` is an `Object` that provides access to output from the
|
|
78
|
+
[`markdown-it`][markdown-it] parser.
|
|
79
|
+
- `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token]
|
|
80
|
+
with added `line` and `lineNumber` properties. (This property was
|
|
81
|
+
previously on the `params` object.)
|
|
71
82
|
- `lines` is an `Array` of `String` values corresponding to the lines of the
|
|
72
83
|
input file/string.
|
|
73
84
|
- `frontMatterLines` is an `Array` of `String` values corresponding to any
|
|
@@ -120,9 +131,9 @@ exception.
|
|
|
120
131
|
|
|
121
132
|
- [Simple rules used by the project's test cases][test-rules]
|
|
122
133
|
- [Code for all `markdownlint` built-in rules][lib]
|
|
123
|
-
- [
|
|
124
|
-
|
|
125
|
-
- [Custom rules from the
|
|
134
|
+
- [Complete example rule including npm configuration][extended-ascii]
|
|
135
|
+
- [Custom rules from the github/docs repository][github-docs]
|
|
136
|
+
- [Custom rules from the electron/lint-roller repository][electron]
|
|
126
137
|
- [Custom rules from the webhintio/hint repository][hint]
|
|
127
138
|
|
|
128
139
|
## References
|
|
@@ -145,7 +156,7 @@ Yields the `params` object:
|
|
|
145
156
|
```json
|
|
146
157
|
{
|
|
147
158
|
"name": "doc/example.md",
|
|
148
|
-
"tokens": [
|
|
159
|
+
"parsers.markdownit.tokens": [
|
|
149
160
|
{
|
|
150
161
|
"type": "heading_open",
|
|
151
162
|
"tag": "h1",
|
|
@@ -364,7 +375,9 @@ Yields the `params` object:
|
|
|
364
375
|
```
|
|
365
376
|
|
|
366
377
|
[commonmark]: https://commonmark.org/
|
|
367
|
-
[
|
|
378
|
+
[electron]: https://github.com/electron/lint-roller/tree/main/markdownlint-rules
|
|
379
|
+
[extended-ascii]: https://github.com/DavidAnson/markdownlint-rule-extended-ascii
|
|
380
|
+
[github-docs]: https://github.com/github/docs/tree/main/src/content-linter/lib/linting-rules
|
|
368
381
|
[hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
|
|
369
382
|
[lib]: ../lib
|
|
370
383
|
[markdown-it]: https://github.com/markdown-it/markdown-it
|
|
@@ -373,4 +386,3 @@ Yields the `params` object:
|
|
|
373
386
|
[rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
|
|
374
387
|
[options-custom-rules]: ../README.md#optionscustomrules
|
|
375
388
|
[test-rules]: ../test/rules
|
|
376
|
-
[test-rules-npm]: ../test/rules/npm
|
package/doc/Rules.md
CHANGED
|
@@ -495,12 +495,12 @@ For example (assuming normal behavior):
|
|
|
495
495
|
```markdown
|
|
496
496
|
IF THIS LINE IS THE MAXIMUM LENGTH
|
|
497
497
|
This line is okay because there are-no-spaces-beyond-that-length
|
|
498
|
-
|
|
499
|
-
This-line-is-
|
|
498
|
+
This line is a violation because there are spaces beyond that length
|
|
499
|
+
This-line-is-okay-because-there-are-no-spaces-anywhere-within
|
|
500
500
|
```
|
|
501
501
|
|
|
502
|
-
In `strict`
|
|
503
|
-
|
|
502
|
+
In `strict` mode, the last three lines above are all violations. In `stern`
|
|
503
|
+
mode, the middle two lines above are both violations, but the last is okay.
|
|
504
504
|
|
|
505
505
|
You have the option to exclude this rule for code blocks, tables, or headings.
|
|
506
506
|
To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
|
|
@@ -509,9 +509,10 @@ Code blocks are included in this rule by default since it is often a
|
|
|
509
509
|
requirement for document readability, and tentatively compatible with code
|
|
510
510
|
rules. Still, some languages do not lend themselves to short lines.
|
|
511
511
|
|
|
512
|
-
Lines with link/image reference definitions
|
|
513
|
-
|
|
514
|
-
|
|
512
|
+
Lines with link/image reference definitions and standalone lines (i.e., not part
|
|
513
|
+
of a paragraph) with only a link/image (possibly using (strong) emphasis) are
|
|
514
|
+
always exempted from this rule (even in `strict` mode) because there is often no
|
|
515
|
+
way to split such lines without breaking the URL.
|
|
515
516
|
|
|
516
517
|
Rationale: Extremely long lines can be difficult to work with in some editors.
|
|
517
518
|
More information: <https://cirosantilli.com/markdown-style-guide#line-wrapping>.
|
|
@@ -1353,6 +1354,11 @@ To fix this, add angle brackets around the URL or email address:
|
|
|
1353
1354
|
For more info, visit <https://www.example.com/> or email <user@example.com>.
|
|
1354
1355
|
```
|
|
1355
1356
|
|
|
1357
|
+
If a URL or email address contains non-ASCII characters, it may be not be
|
|
1358
|
+
handled as intended even when angle brackets are present. In such cases,
|
|
1359
|
+
[percent-encoding](https://en.m.wikipedia.org/wiki/Percent-encoding) can be used
|
|
1360
|
+
to comply with the required syntax for URL and email.
|
|
1361
|
+
|
|
1356
1362
|
Note: To include a bare URL or email without it being converted into a link,
|
|
1357
1363
|
wrap it in a code span:
|
|
1358
1364
|
|
|
@@ -1828,6 +1834,16 @@ enforce the proper capitalization, specify the desired letter case in the
|
|
|
1828
1834
|
]
|
|
1829
1835
|
```
|
|
1830
1836
|
|
|
1837
|
+
Sometimes a proper name is capitalized differently in certain contexts. In such
|
|
1838
|
+
cases, add both forms to the `names` array:
|
|
1839
|
+
|
|
1840
|
+
```json
|
|
1841
|
+
[
|
|
1842
|
+
"GitHub",
|
|
1843
|
+
"github.com"
|
|
1844
|
+
]
|
|
1845
|
+
```
|
|
1846
|
+
|
|
1831
1847
|
Set the `code_blocks` parameter to `false` to disable this rule for code blocks
|
|
1832
1848
|
and spans. Set the `html_elements` parameter to `false` to disable this rule
|
|
1833
1849
|
for HTML elements and attributes (such as when using a proper name as part of
|
|
@@ -2035,6 +2051,9 @@ To fix this issue, use the configured emphasis style throughout the document:
|
|
|
2035
2051
|
The configured emphasis style can be a specific symbol to use ("asterisk",
|
|
2036
2052
|
"underscore"), or can require that usage be consistent within the document.
|
|
2037
2053
|
|
|
2054
|
+
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
2055
|
+
unwanted emphasis for words containing internal underscores like_this_one.
|
|
2056
|
+
|
|
2038
2057
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
2039
2058
|
|
|
2040
2059
|
<a name="md050"></a>
|
|
@@ -2070,6 +2089,9 @@ To fix this issue, use the configured strong style throughout the document:
|
|
|
2070
2089
|
The configured strong style can be a specific symbol to use ("asterisk",
|
|
2071
2090
|
"underscore"), or can require that usage be consistent within the document.
|
|
2072
2091
|
|
|
2092
|
+
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
2093
|
+
unwanted emphasis for words containing internal underscores like_this_one.
|
|
2094
|
+
|
|
2073
2095
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
2074
2096
|
|
|
2075
2097
|
<a name="md051"></a>
|
|
@@ -2100,6 +2122,16 @@ generated name (see below):
|
|
|
2100
2122
|
[Link](#heading-name)
|
|
2101
2123
|
```
|
|
2102
2124
|
|
|
2125
|
+
Link fragments may be handled case-sensitively, so this rule requires fragments
|
|
2126
|
+
to exactly match the [GitHub heading algorithm][github-heading-algorithm].
|
|
2127
|
+
Therefore, the following example is reported as a violation:
|
|
2128
|
+
|
|
2129
|
+
```markdown
|
|
2130
|
+
# Heading Name
|
|
2131
|
+
|
|
2132
|
+
[Link](#Heading-Name)
|
|
2133
|
+
```
|
|
2134
|
+
|
|
2103
2135
|
Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
|
|
2104
2136
|
within a heading to provide a specific name (consisting of only lower-case
|
|
2105
2137
|
letters, numbers, `-`, and `_`):
|
|
@@ -2122,6 +2154,21 @@ attribute can be used to define a fragment:
|
|
|
2122
2154
|
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
|
2123
2155
|
control over the text of the fragment identifier.
|
|
2124
2156
|
|
|
2157
|
+
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
|
2158
|
+
[specific content in a document][github-linking-to-content].
|
|
2159
|
+
|
|
2160
|
+
For example, this link to line 20:
|
|
2161
|
+
|
|
2162
|
+
```markdown
|
|
2163
|
+
[Link](#L20)
|
|
2164
|
+
```
|
|
2165
|
+
|
|
2166
|
+
And this link to content starting within line 19 running into line 21:
|
|
2167
|
+
|
|
2168
|
+
```markdown
|
|
2169
|
+
[Link](#L19C5-L21C11)
|
|
2170
|
+
```
|
|
2171
|
+
|
|
2125
2172
|
Rationale: [GitHub section links][github-section-links] are created
|
|
2126
2173
|
automatically for every heading when Markdown content is displayed on GitHub.
|
|
2127
2174
|
This makes it easy to link directly to different sections within a document.
|
|
@@ -2135,6 +2182,7 @@ append an incrementing integer as needed for uniqueness.
|
|
|
2135
2182
|
|
|
2136
2183
|
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
|
2137
2184
|
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
|
2185
|
+
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
|
2138
2186
|
|
|
2139
2187
|
<a name="md052"></a>
|
|
2140
2188
|
|
|
@@ -2420,6 +2468,57 @@ Missing cells in a row create holes in the table and suggest an omission.
|
|
|
2420
2468
|
|
|
2421
2469
|
[gfm-table-056]: https://github.github.com/gfm/#tables-extension-
|
|
2422
2470
|
|
|
2471
|
+
<a name="md058"></a>
|
|
2472
|
+
|
|
2473
|
+
## `MD058` - Tables should be surrounded by blank lines
|
|
2474
|
+
|
|
2475
|
+
Tags: `table`
|
|
2476
|
+
|
|
2477
|
+
Aliases: `blanks-around-tables`
|
|
2478
|
+
|
|
2479
|
+
Fixable: Some violations can be fixed by tooling
|
|
2480
|
+
|
|
2481
|
+
This rule is triggered when tables are either not preceded or not followed by a
|
|
2482
|
+
blank line:
|
|
2483
|
+
|
|
2484
|
+
```markdown
|
|
2485
|
+
Some text
|
|
2486
|
+
| Header | Header |
|
|
2487
|
+
| ------ | ------ |
|
|
2488
|
+
| Cell | Cell |
|
|
2489
|
+
> Blockquote
|
|
2490
|
+
```
|
|
2491
|
+
|
|
2492
|
+
To fix violations of this rule, ensure that all tables have a blank line both
|
|
2493
|
+
before and after (except when the table is at the very beginning or end of the
|
|
2494
|
+
document):
|
|
2495
|
+
|
|
2496
|
+
```markdown
|
|
2497
|
+
Some text
|
|
2498
|
+
|
|
2499
|
+
| Header | Header |
|
|
2500
|
+
| ------ | ------ |
|
|
2501
|
+
| Cell | Cell |
|
|
2502
|
+
|
|
2503
|
+
> Blockquote
|
|
2504
|
+
```
|
|
2505
|
+
|
|
2506
|
+
Note that text immediately following a table (i.e., not separated by an empty
|
|
2507
|
+
line) is treated as part of the table (per the specification) and will not
|
|
2508
|
+
trigger this rule:
|
|
2509
|
+
|
|
2510
|
+
```markdown
|
|
2511
|
+
| Header | Header |
|
|
2512
|
+
| ------ | ------ |
|
|
2513
|
+
| Cell | Cell |
|
|
2514
|
+
This text is part of the table and the next line is blank
|
|
2515
|
+
|
|
2516
|
+
Some text
|
|
2517
|
+
```
|
|
2518
|
+
|
|
2519
|
+
Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
|
|
2520
|
+
tables that don't have blank lines before and after them.
|
|
2521
|
+
|
|
2423
2522
|
<!-- markdownlint-configure-file {
|
|
2424
2523
|
"no-inline-html": {
|
|
2425
2524
|
"allowed_elements": [
|
package/doc/md013.md
CHANGED
|
@@ -35,12 +35,12 @@ For example (assuming normal behavior):
|
|
|
35
35
|
```markdown
|
|
36
36
|
IF THIS LINE IS THE MAXIMUM LENGTH
|
|
37
37
|
This line is okay because there are-no-spaces-beyond-that-length
|
|
38
|
-
|
|
39
|
-
This-line-is-
|
|
38
|
+
This line is a violation because there are spaces beyond that length
|
|
39
|
+
This-line-is-okay-because-there-are-no-spaces-anywhere-within
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
In `strict`
|
|
43
|
-
|
|
42
|
+
In `strict` mode, the last three lines above are all violations. In `stern`
|
|
43
|
+
mode, the middle two lines above are both violations, but the last is okay.
|
|
44
44
|
|
|
45
45
|
You have the option to exclude this rule for code blocks, tables, or headings.
|
|
46
46
|
To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
|
|
@@ -49,9 +49,10 @@ Code blocks are included in this rule by default since it is often a
|
|
|
49
49
|
requirement for document readability, and tentatively compatible with code
|
|
50
50
|
rules. Still, some languages do not lend themselves to short lines.
|
|
51
51
|
|
|
52
|
-
Lines with link/image reference definitions
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
Lines with link/image reference definitions and standalone lines (i.e., not part
|
|
53
|
+
of a paragraph) with only a link/image (possibly using (strong) emphasis) are
|
|
54
|
+
always exempted from this rule (even in `strict` mode) because there is often no
|
|
55
|
+
way to split such lines without breaking the URL.
|
|
55
56
|
|
|
56
57
|
Rationale: Extremely long lines can be difficult to work with in some editors.
|
|
57
58
|
More information: <https://cirosantilli.com/markdown-style-guide#line-wrapping>.
|
package/doc/md034.md
CHANGED
|
@@ -19,6 +19,11 @@ To fix this, add angle brackets around the URL or email address:
|
|
|
19
19
|
For more info, visit <https://www.example.com/> or email <user@example.com>.
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
If a URL or email address contains non-ASCII characters, it may be not be
|
|
23
|
+
handled as intended even when angle brackets are present. In such cases,
|
|
24
|
+
[percent-encoding](https://en.m.wikipedia.org/wiki/Percent-encoding) can be used
|
|
25
|
+
to comply with the required syntax for URL and email.
|
|
26
|
+
|
|
22
27
|
Note: To include a bare URL or email without it being converted into a link,
|
|
23
28
|
wrap it in a code span:
|
|
24
29
|
|
package/doc/md044.md
CHANGED
|
@@ -27,6 +27,16 @@ enforce the proper capitalization, specify the desired letter case in the
|
|
|
27
27
|
]
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
Sometimes a proper name is capitalized differently in certain contexts. In such
|
|
31
|
+
cases, add both forms to the `names` array:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
[
|
|
35
|
+
"GitHub",
|
|
36
|
+
"github.com"
|
|
37
|
+
]
|
|
38
|
+
```
|
|
39
|
+
|
|
30
40
|
Set the `code_blocks` parameter to `false` to disable this rule for code blocks
|
|
31
41
|
and spans. Set the `html_elements` parameter to `false` to disable this rule
|
|
32
42
|
for HTML elements and attributes (such as when using a proper name as part of
|
package/doc/md049.md
CHANGED
|
@@ -29,4 +29,7 @@ To fix this issue, use the configured emphasis style throughout the document:
|
|
|
29
29
|
The configured emphasis style can be a specific symbol to use ("asterisk",
|
|
30
30
|
"underscore"), or can require that usage be consistent within the document.
|
|
31
31
|
|
|
32
|
+
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
33
|
+
unwanted emphasis for words containing internal underscores like_this_one.
|
|
34
|
+
|
|
32
35
|
Rationale: Consistent formatting makes it easier to understand a document.
|
package/doc/md050.md
CHANGED
|
@@ -29,4 +29,7 @@ To fix this issue, use the configured strong style throughout the document:
|
|
|
29
29
|
The configured strong style can be a specific symbol to use ("asterisk",
|
|
30
30
|
"underscore"), or can require that usage be consistent within the document.
|
|
31
31
|
|
|
32
|
+
Note: Emphasis within a word is restricted to "asterisk" in order to avoid
|
|
33
|
+
unwanted emphasis for words containing internal underscores like_this_one.
|
|
34
|
+
|
|
32
35
|
Rationale: Consistent formatting makes it easier to understand a document.
|
package/doc/md051.md
CHANGED
|
@@ -24,6 +24,16 @@ generated name (see below):
|
|
|
24
24
|
[Link](#heading-name)
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Link fragments may be handled case-sensitively, so this rule requires fragments
|
|
28
|
+
to exactly match the [GitHub heading algorithm][github-heading-algorithm].
|
|
29
|
+
Therefore, the following example is reported as a violation:
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
# Heading Name
|
|
33
|
+
|
|
34
|
+
[Link](#Heading-Name)
|
|
35
|
+
```
|
|
36
|
+
|
|
27
37
|
Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
|
|
28
38
|
within a heading to provide a specific name (consisting of only lower-case
|
|
29
39
|
letters, numbers, `-`, and `_`):
|
|
@@ -46,6 +56,21 @@ attribute can be used to define a fragment:
|
|
|
46
56
|
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
|
47
57
|
control over the text of the fragment identifier.
|
|
48
58
|
|
|
59
|
+
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
|
60
|
+
[specific content in a document][github-linking-to-content].
|
|
61
|
+
|
|
62
|
+
For example, this link to line 20:
|
|
63
|
+
|
|
64
|
+
```markdown
|
|
65
|
+
[Link](#L20)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
And this link to content starting within line 19 running into line 21:
|
|
69
|
+
|
|
70
|
+
```markdown
|
|
71
|
+
[Link](#L19C5-L21C11)
|
|
72
|
+
```
|
|
73
|
+
|
|
49
74
|
Rationale: [GitHub section links][github-section-links] are created
|
|
50
75
|
automatically for every heading when Markdown content is displayed on GitHub.
|
|
51
76
|
This makes it easy to link directly to different sections within a document.
|
|
@@ -59,3 +84,4 @@ append an incrementing integer as needed for uniqueness.
|
|
|
59
84
|
|
|
60
85
|
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
|
61
86
|
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
|
87
|
+
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
package/doc/md058.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# `MD058` - Tables should be surrounded by blank lines
|
|
2
|
+
|
|
3
|
+
Tags: `table`
|
|
4
|
+
|
|
5
|
+
Aliases: `blanks-around-tables`
|
|
6
|
+
|
|
7
|
+
Fixable: Some violations can be fixed by tooling
|
|
8
|
+
|
|
9
|
+
This rule is triggered when tables are either not preceded or not followed by a
|
|
10
|
+
blank line:
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
Some text
|
|
14
|
+
| Header | Header |
|
|
15
|
+
| ------ | ------ |
|
|
16
|
+
| Cell | Cell |
|
|
17
|
+
> Blockquote
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
To fix violations of this rule, ensure that all tables have a blank line both
|
|
21
|
+
before and after (except when the table is at the very beginning or end of the
|
|
22
|
+
document):
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
Some text
|
|
26
|
+
|
|
27
|
+
| Header | Header |
|
|
28
|
+
| ------ | ------ |
|
|
29
|
+
| Cell | Cell |
|
|
30
|
+
|
|
31
|
+
> Blockquote
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Note that text immediately following a table (i.e., not separated by an empty
|
|
35
|
+
line) is treated as part of the table (per the specification) and will not
|
|
36
|
+
trigger this rule:
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
| Header | Header |
|
|
40
|
+
| ------ | ------ |
|
|
41
|
+
| Cell | Cell |
|
|
42
|
+
This text is part of the table and the next line is blank
|
|
43
|
+
|
|
44
|
+
Some text
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
|
|
48
|
+
tables that don't have blank lines before and after them.
|
package/helpers/README.md
CHANGED
|
@@ -19,30 +19,6 @@ be useful to custom rule authors and may avoid duplicating code.
|
|
|
19
19
|
|
|
20
20
|
## Examples
|
|
21
21
|
|
|
22
|
-
### Using Helpers from a Custom Rule
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
"names": [ "every-n-lines" ],
|
|
29
|
-
"description": "Rule that reports an error every N lines",
|
|
30
|
-
"tags": [ "test" ],
|
|
31
|
-
"function": (params, onError) => {
|
|
32
|
-
const n = params.config.n || 2;
|
|
33
|
-
forEachLine(getLineMetadata(params), (line, lineIndex) => {
|
|
34
|
-
const lineNumber = lineIndex + 1;
|
|
35
|
-
if ((lineNumber % n) === 0) {
|
|
36
|
-
onError({
|
|
37
|
-
"lineNumber": lineNumber,
|
|
38
|
-
"detail": "Line number " + lineNumber
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
```
|
|
45
|
-
|
|
46
22
|
### Applying Recommended Fixes
|
|
47
23
|
|
|
48
24
|
```javascript
|
|
@@ -62,9 +38,9 @@ See also: [`markdownlint` built-in rule implementations][lib].
|
|
|
62
38
|
*None* - The entire body of code is tested to 100% coverage by the core
|
|
63
39
|
`markdownlint` project, so there are no additional tests here.
|
|
64
40
|
|
|
65
|
-
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
41
|
+
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/CustomRules.md
|
|
66
42
|
[jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
|
|
67
|
-
[lib]: https://github.com/DavidAnson/markdownlint/tree/v0.
|
|
43
|
+
[lib]: https://github.com/DavidAnson/markdownlint/tree/v0.35.0/lib
|
|
68
44
|
[markdown]: https://en.wikipedia.org/wiki/Markdown
|
|
69
45
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
|
70
|
-
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
46
|
+
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/Rules.md
|