markdownlint 0.34.0 → 0.36.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +97 -45
  3. package/demo/markdownlint-browser.js +2186 -2164
  4. package/doc/CustomRules.md +66 -255
  5. package/doc/Rules.md +102 -29
  6. package/doc/md003.md +2 -2
  7. package/doc/md004.md +4 -3
  8. package/doc/md034.md +5 -0
  9. package/doc/md035.md +3 -8
  10. package/doc/md044.md +10 -0
  11. package/doc/md046.md +2 -2
  12. package/doc/md048.md +3 -2
  13. package/doc/md049.md +4 -3
  14. package/doc/md050.md +4 -4
  15. package/doc/md051.md +11 -3
  16. package/doc/md055.md +3 -2
  17. package/doc/md058.md +48 -0
  18. package/helpers/README.md +2 -45
  19. package/helpers/helpers.js +115 -607
  20. package/helpers/micromark-helpers.cjs +296 -0
  21. package/helpers/micromark-parse.cjs +313 -0
  22. package/helpers/package.json +5 -2
  23. package/helpers/shared.js +6 -0
  24. package/helpers/test.cjs +28 -0
  25. package/lib/cache.js +62 -13
  26. package/lib/configuration-strict.d.ts +1199 -0
  27. package/lib/configuration.d.ts +3 -1173
  28. package/lib/constants.js +3 -2
  29. package/lib/markdownit.cjs +172 -0
  30. package/lib/markdownlint.d.ts +103 -56
  31. package/lib/markdownlint.js +180 -120
  32. package/lib/md001.js +15 -9
  33. package/lib/md003.js +14 -9
  34. package/lib/md004.js +55 -48
  35. package/lib/md005.js +4 -13
  36. package/lib/md007.js +7 -11
  37. package/lib/md009.js +50 -44
  38. package/lib/md010.js +52 -33
  39. package/lib/md011.js +32 -23
  40. package/lib/md012.js +17 -9
  41. package/lib/md013.js +44 -38
  42. package/lib/md014.js +31 -38
  43. package/lib/md018.js +17 -9
  44. package/lib/md019-md021.js +80 -0
  45. package/lib/md020.js +14 -8
  46. package/lib/md022.js +13 -29
  47. package/lib/md023.js +22 -23
  48. package/lib/md024.js +12 -9
  49. package/lib/md025.js +15 -10
  50. package/lib/md026.js +2 -7
  51. package/lib/md027.js +7 -12
  52. package/lib/md028.js +3 -8
  53. package/lib/md029.js +40 -34
  54. package/lib/md030.js +4 -10
  55. package/lib/md031.js +45 -23
  56. package/lib/md032.js +33 -31
  57. package/lib/md033.js +3 -8
  58. package/lib/md034.js +21 -34
  59. package/lib/md035.js +2 -7
  60. package/lib/md036.js +19 -24
  61. package/lib/md037.js +3 -8
  62. package/lib/md038.js +11 -22
  63. package/lib/md039.js +64 -54
  64. package/lib/md040.js +13 -20
  65. package/lib/md041.js +5 -5
  66. package/lib/md042.js +44 -38
  67. package/lib/md043.js +20 -14
  68. package/lib/md044.js +34 -36
  69. package/lib/md045.js +5 -10
  70. package/lib/md046.js +2 -8
  71. package/lib/md048.js +30 -23
  72. package/lib/md049-md050.js +22 -12
  73. package/lib/md051.js +20 -28
  74. package/lib/md052.js +2 -2
  75. package/lib/md053.js +7 -6
  76. package/lib/md054.js +16 -23
  77. package/lib/md055.js +41 -49
  78. package/lib/md056.js +32 -33
  79. package/lib/md058.js +58 -0
  80. package/lib/rules.js +11 -4
  81. package/package.json +23 -20
  82. package/schema/.markdownlint.jsonc +58 -52
  83. package/schema/.markdownlint.yaml +56 -51
  84. package/schema/ValidatingConfiguration.md +6 -8
  85. package/schema/markdownlint-config-schema-strict.json +1841 -0
  86. package/schema/markdownlint-config-schema.json +141 -109
  87. package/style/prettier.json +1 -0
  88. package/helpers/micromark.cjs +0 -445
  89. package/lib/md019.js +0 -42
  90. package/lib/md021.js +0 -65
@@ -1,20 +1,21 @@
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 a list of custom rules using the [`options.customRules`
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]). Custom rules can be disabled,
8
- enabled, and customized using the same syntax as built-in rules.
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
 
12
14
  For simple requirements like disallowing certain characters or patterns,
13
15
  the community-developed
14
16
  [markdownlint-rule-search-replace][markdownlint-rule-search-replace]
15
- plug-in can be used.
16
- This plug-in allows anyone to create a set of simple text-replacement rules in
17
- JSON without needing to write any code.
17
+ plug-in can be used. This plug-in allows anyone to create a set of simple
18
+ text-replacement rules without needing to write code.
18
19
 
19
20
  [markdownlint-rule-search-replace]: https://www.npmjs.com/package/markdownlint-rule-search-replace
20
21
 
@@ -25,29 +26,62 @@ to more information, one or more tags, and a function that implements the rule's
25
26
  behavior. That function is called once for each file/string input and is passed
26
27
  the parsed input and a function to log any violations.
27
28
 
28
- A simple rule implementation looks like:
29
+ Custom rules can (should) operate on a structured set of tokens based on the
30
+ [`micromark`][micromark] `parser` (this is preferred). Alternatively, custom
31
+ rules can operate on a structured set of tokens based on the
32
+ [`markdown-it`][markdown-it] `parser` (legacy support). Finally, custom rules
33
+ can operate directly on text with the `none` `parser`.
34
+
35
+ A simple rule implementation using the `micromark` parser to report a violation
36
+ for any use of blockquotes might look like:
29
37
 
30
38
  ```javascript
31
39
  /** @type import("markdownlint").Rule */
32
40
  module.exports = {
33
- "names": [ "any-blockquote" ],
41
+ "names": [ "any-blockquote-micromark" ],
42
+ "description": "Rule that reports an error for any blockquote",
43
+ "information": new URL("https://example.com/rules/any-blockquote"),
44
+ "tags": [ "test" ],
45
+ "parser": "micromark",
46
+ "function": (params, onError) => {
47
+ const blockquotes = params.parsers.micromark.tokens
48
+ .filter((token) => token.type === "blockQuote");
49
+ for (const blockquote of blockquotes) {
50
+ const lines = blockquote.endLine - blockquote.startLine + 1;
51
+ onError({
52
+ "lineNumber": blockquote.startLine,
53
+ "detail": "Blockquote spans " + lines + " line(s).",
54
+ "context": params.lines[blockquote.startLine - 1]
55
+ });
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ That same rule implemented using the `markdown-it` parser might look like:
62
+
63
+ ```javascript
64
+ /** @type import("markdownlint").Rule */
65
+ module.exports = {
66
+ "names": [ "any-blockquote-markdown-it" ],
34
67
  "description": "Rule that reports an error for any blockquote",
35
68
  "information": new URL("https://example.com/rules/any-blockquote"),
36
69
  "tags": [ "test" ],
37
70
  "parser": "markdownit",
38
- "function": function rule(params, onError) {
39
- params.parsers.markdownit.tokens.filter(function filterToken(token) {
40
- return token.type === "blockquote_open";
41
- }).forEach(function forToken(blockquote) {
42
- var lines = blockquote.map[1] - blockquote.map[0];
71
+ "function": (params, onError) => {
72
+ const blockquotes = params.parsers.markdownit.tokens
73
+ .filter((token) => token.type === "blockquote_open");
74
+ for (const blockquote of blockquotes) {
75
+ const [ startIndex, endIndex ] = blockquote.map;
76
+ const lines = endIndex - startIndex;
43
77
  onError({
44
78
  "lineNumber": blockquote.lineNumber,
45
79
  "detail": "Blockquote spans " + lines + " line(s).",
46
- "context": blockquote.line.substr(0, 7)
80
+ "context": blockquote.line
47
81
  });
48
- });
82
+ }
49
83
  }
50
- };
84
+ }
51
85
  ```
52
86
 
53
87
  A rule is implemented as an `Object`:
@@ -60,9 +94,8 @@ A rule is implemented as an `Object`:
60
94
  about the rule.
61
95
  - `tags` is a required `Array` of `String` values that groups related rules for
62
96
  easier customization.
63
- - `parser` is a required `String` value `"markdownit" | "none"` that specifies
64
- the parser data used via `params.parsers` (see below).
65
- - Note: The value `"micromark"` is valid but is NOT currently supported.
97
+ - `parser` is a required `String` value `"markdownit" | "micromark" | "none"`
98
+ that specifies the parser data used via `params.parsers` (see below).
66
99
  - `asynchronous` is an optional `Boolean` value that indicates whether the rule
67
100
  returns a `Promise` and runs asynchronously.
68
101
  - `function` is a required `Function` that implements the rule and is passed two
@@ -77,12 +110,17 @@ A rule is implemented as an `Object`:
77
110
  - `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token]
78
111
  with added `line` and `lineNumber` properties. (This property was
79
112
  previously on the `params` object.)
113
+ - `micromark` is an `Object` that provides access to output from the
114
+ [`micromark`][micromark] parser.
115
+ - `tokens` is an `Array` of [`MicromarkToken`][micromark-token] objects.
116
+ - Samples for both `tokens` are available via [test snapshots][tokens].
80
117
  - `lines` is an `Array` of `String` values corresponding to the lines of the
81
118
  input file/string.
82
119
  - `frontMatterLines` is an `Array` of `String` values corresponding to any
83
120
  front matter (not present in `lines`).
84
121
  - `config` is an `Object` corresponding to the rule's entry in
85
122
  `options.config` (if present).
123
+ - `version` is a `String` that corresponds to the version of `markdownlint`
86
124
  - `onError` is a function that takes a single `Object` parameter with one
87
125
  required and four optional properties:
88
126
  - `lineNumber` is a required `Number` specifying the 1-based line number of
@@ -129,8 +167,9 @@ exception.
129
167
 
130
168
  - [Simple rules used by the project's test cases][test-rules]
131
169
  - [Code for all `markdownlint` built-in rules][lib]
132
- - [Package configuration for publishing to npm][test-rules-npm]
133
- - Packages should export a single rule object or an `Array` of rule objects
170
+ - [Complete example rule including npm configuration][extended-ascii]
171
+ - [Custom rules from the github/docs repository][github-docs]
172
+ - [Custom rules from the electron/lint-roller repository][electron]
134
173
  - [Custom rules from the webhintio/hint repository][hint]
135
174
 
136
175
  ## References
@@ -138,246 +177,18 @@ exception.
138
177
  - [CommonMark documentation and specification][commonmark]
139
178
  - [`markdown-it` Markdown parser project page][markdown-it]
140
179
 
141
- ## Params
142
-
143
- The Markdown document:
144
-
145
- ```markdown
146
- # Title
147
-
148
- Text *text* text.
149
- ```
150
-
151
- Yields the `params` object:
152
-
153
- ```json
154
- {
155
- "name": "doc/example.md",
156
- "parsers.markdownit.tokens": [
157
- {
158
- "type": "heading_open",
159
- "tag": "h1",
160
- "attrs": null,
161
- "map": [ 0, 1 ],
162
- "nesting": 1,
163
- "level": 0,
164
- "children": null,
165
- "content": "",
166
- "markup": "#",
167
- "info": "",
168
- "meta": null,
169
- "block": true,
170
- "hidden": false,
171
- "line": "# Title",
172
- "lineNumber": 1
173
- },
174
- {
175
- "type": "inline",
176
- "tag": "",
177
- "attrs": null,
178
- "map": [ 0, 1 ],
179
- "nesting": 0,
180
- "level": 1,
181
- "children": [
182
- {
183
- "type": "text",
184
- "tag": "",
185
- "attrs": null,
186
- "map": null,
187
- "nesting": 0,
188
- "level": 0,
189
- "children": null,
190
- "content": "Title",
191
- "markup": "",
192
- "info": "",
193
- "meta": null,
194
- "block": false,
195
- "hidden": false,
196
- "lineNumber": 1,
197
- "line": "# Title"
198
- }
199
- ],
200
- "content": "Title",
201
- "markup": "",
202
- "info": "",
203
- "meta": null,
204
- "block": true,
205
- "hidden": false,
206
- "line": "# Title",
207
- "lineNumber": 1
208
- },
209
- {
210
- "type": "heading_close",
211
- "tag": "h1",
212
- "attrs": null,
213
- "map": null,
214
- "nesting": -1,
215
- "level": 0,
216
- "children": null,
217
- "content": "",
218
- "markup": "#",
219
- "info": "",
220
- "meta": null,
221
- "block": true,
222
- "hidden": false
223
- },
224
- {
225
- "type": "paragraph_open",
226
- "tag": "p",
227
- "attrs": null,
228
- "map": [ 2, 3 ],
229
- "nesting": 1,
230
- "level": 0,
231
- "children": null,
232
- "content": "",
233
- "markup": "",
234
- "info": "",
235
- "meta": null,
236
- "block": true,
237
- "hidden": false,
238
- "line": "Text *text* text.",
239
- "lineNumber": 3
240
- },
241
- {
242
- "type": "inline",
243
- "tag": "",
244
- "attrs": null,
245
- "map": [ 2, 3 ],
246
- "nesting": 0,
247
- "level": 1,
248
- "children": [
249
- {
250
- "type": "text",
251
- "tag": "",
252
- "attrs": null,
253
- "map": null,
254
- "nesting": 0,
255
- "level": 0,
256
- "children": null,
257
- "content": "Text ",
258
- "markup": "",
259
- "info": "",
260
- "meta": null,
261
- "block": false,
262
- "hidden": false,
263
- "lineNumber": 3,
264
- "line": "Text *text* text."
265
- },
266
- {
267
- "type": "em_open",
268
- "tag": "em",
269
- "attrs": null,
270
- "map": null,
271
- "nesting": 1,
272
- "level": 1,
273
- "children": null,
274
- "content": "",
275
- "markup": "*",
276
- "info": "",
277
- "meta": null,
278
- "block": false,
279
- "hidden": false,
280
- "lineNumber": 3,
281
- "line": "Text *text* text."
282
- },
283
- {
284
- "type": "text",
285
- "tag": "",
286
- "attrs": null,
287
- "map": null,
288
- "nesting": 0,
289
- "level": 1,
290
- "children": null,
291
- "content": "text",
292
- "markup": "",
293
- "info": "",
294
- "meta": null,
295
- "block": false,
296
- "hidden": false,
297
- "lineNumber": 3,
298
- "line": "Text *text* text."
299
- },
300
- {
301
- "type": "em_close",
302
- "tag": "em",
303
- "attrs": null,
304
- "map": null,
305
- "nesting": -1,
306
- "level": 0,
307
- "children": null,
308
- "content": "",
309
- "markup": "*",
310
- "info": "",
311
- "meta": null,
312
- "block": false,
313
- "hidden": false,
314
- "lineNumber": 3,
315
- "line": "Text *text* text."
316
- },
317
- {
318
- "type": "text",
319
- "tag": "",
320
- "attrs": null,
321
- "map": null,
322
- "nesting": 0,
323
- "level": 0,
324
- "children": null,
325
- "content": " text.",
326
- "markup": "",
327
- "info": "",
328
- "meta": null,
329
- "block": false,
330
- "hidden": false,
331
- "lineNumber": 3,
332
- "line": "Text *text* text."
333
- }
334
- ],
335
- "content": "Text *text* text.",
336
- "markup": "",
337
- "info": "",
338
- "meta": null,
339
- "block": true,
340
- "hidden": false,
341
- "line": "Text *text* text.",
342
- "lineNumber": 3
343
- },
344
- {
345
- "type": "paragraph_close",
346
- "tag": "p",
347
- "attrs": null,
348
- "map": null,
349
- "nesting": -1,
350
- "level": 0,
351
- "children": null,
352
- "content": "",
353
- "markup": "",
354
- "info": "",
355
- "meta": null,
356
- "block": true,
357
- "hidden": false
358
- }
359
- ],
360
- "lines": [
361
- "# Title",
362
- "",
363
- "Text *text* text.",
364
- ""
365
- ],
366
- "frontMatterLines": [],
367
- "config": {
368
- "customValue1": "abc",
369
- "customValue2": 123
370
- }
371
- }
372
- ```
373
-
374
180
  [commonmark]: https://commonmark.org/
181
+ [electron]: https://github.com/electron/lint-roller/tree/main/markdownlint-rules
182
+ [extended-ascii]: https://github.com/DavidAnson/markdownlint-rule-extended-ascii
183
+ [github-docs]: https://github.com/github/docs/tree/main/src/content-linter/lib/linting-rules
375
184
  [hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
376
185
  [lib]: ../lib
377
186
  [markdown-it]: https://github.com/markdown-it/markdown-it
378
187
  [markdown-it-token]: https://markdown-it.github.io/markdown-it/#Token
379
188
  [markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
189
+ [micromark]: https://github.com/micromark/micromark
190
+ [micromark-token]: ../lib/markdownlint.d.ts
380
191
  [rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
381
192
  [options-custom-rules]: ../README.md#optionscustomrules
382
193
  [test-rules]: ../test/rules
383
- [test-rules-npm]: ../test/rules/npm
194
+ [tokens]: ../test/snapshots/markdownlint-test-custom-rules.js.md
package/doc/Rules.md CHANGED
@@ -93,8 +93,8 @@ Setext style H2
93
93
  ```
94
94
 
95
95
  Note: The configured heading style can be a specific style to require (`atx`,
96
- `atx_closed`, `setext`, `setext_with_atx`, `setext_with_atx_closed`), or may
97
- just require that usage is consistent within the document via `consistent`.
96
+ `atx_closed`, `setext`, `setext_with_atx`, `setext_with_atx_closed`), or can
97
+ require that all heading styles match the first heading style via `consistent`.
98
98
 
99
99
  Note: The placement of a horizontal rule directly below a line of text can
100
100
  trigger this rule by turning that text into a level 2 setext-style heading:
@@ -139,9 +139,10 @@ document:
139
139
  * Item 3
140
140
  ```
141
141
 
142
- The configured list style can be a specific symbol to use (asterisk, plus,
143
- dash), to ensure that all list styling is consistent, or to ensure that each
144
- sublist has a consistent symbol that differs from its parent list.
142
+ The configured list style can ensure all list styling is a specific symbol
143
+ (`asterisk`, `plus`, `dash`), ensure each sublist has a consistent symbol that
144
+ differs from its parent list (`sublist`), or ensure all list styles match the
145
+ first list style (`consistent`).
145
146
 
146
147
  For example, the following is valid for the `sublist` style because the
147
148
  outer-most indent uses asterisk, the middle indent uses plus, and the inner-most
@@ -1354,6 +1355,11 @@ To fix this, add angle brackets around the URL or email address:
1354
1355
  For more info, visit <https://www.example.com/> or email <user@example.com>.
1355
1356
  ```
1356
1357
 
1358
+ If a URL or email address contains non-ASCII characters, it may be not be
1359
+ handled as intended even when angle brackets are present. In such cases,
1360
+ [percent-encoding](https://en.m.wikipedia.org/wiki/Percent-encoding) can be used
1361
+ to comply with the required syntax for URL and email.
1362
+
1357
1363
  Note: To include a bare URL or email without it being converted into a link,
1358
1364
  wrap it in a code span:
1359
1365
 
@@ -1411,8 +1417,7 @@ in the document:
1411
1417
  ****
1412
1418
  ```
1413
1419
 
1414
- To fix this, ensure any horizontal rules used in the document are consistent,
1415
- or match the given style if the rule is so configured:
1420
+ To fix this, use the same horizontal rule everywhere:
1416
1421
 
1417
1422
  ```markdown
1418
1423
  ---
@@ -1420,12 +1425,8 @@ or match the given style if the rule is so configured:
1420
1425
  ---
1421
1426
  ```
1422
1427
 
1423
- Note: by default, this rule is configured to just require that all horizontal
1424
- rules in the document are the same and will trigger if any of the horizontal
1425
- rules are different than the first one encountered in the document. If you
1426
- want to configure the rule to match a specific style, the parameter given to
1427
- the 'style' option is a string containing the exact horizontal rule text that
1428
- is allowed.
1428
+ The configured style can ensure all horizontal rules use a specific string or it
1429
+ can ensure all horizontal rules match the first horizontal rule (`consistent`).
1429
1430
 
1430
1431
  Rationale: Consistent formatting makes it easier to understand a document.
1431
1432
 
@@ -1829,6 +1830,16 @@ enforce the proper capitalization, specify the desired letter case in the
1829
1830
  ]
1830
1831
  ```
1831
1832
 
1833
+ Sometimes a proper name is capitalized differently in certain contexts. In such
1834
+ cases, add both forms to the `names` array:
1835
+
1836
+ ```json
1837
+ [
1838
+ "GitHub",
1839
+ "github.com"
1840
+ ]
1841
+ ```
1842
+
1832
1843
  Set the `code_blocks` parameter to `false` to disable this rule for code blocks
1833
1844
  and spans. Set the `html_elements` parameter to `false` to disable this rule
1834
1845
  for HTML elements and attributes (such as when using a proper name as part of
@@ -1917,8 +1928,8 @@ document:
1917
1928
  To fix violations of this rule, use a consistent style (either indenting or code
1918
1929
  fences).
1919
1930
 
1920
- The specified style can be specific (`fenced`, `indented`) or simply require
1921
- that usage be consistent within the document (`consistent`).
1931
+ The configured code block style can be specific (`fenced`, `indented`) or can
1932
+ require all code blocks match the first code block (`consistent`).
1922
1933
 
1923
1934
  Rationale: Consistent formatting makes it easier to understand a document.
1924
1935
 
@@ -1998,8 +2009,9 @@ document:
1998
2009
  ```
1999
2010
  ````
2000
2011
 
2001
- The configured list style can be a specific symbol to use (backtick, tilde), or
2002
- can require that usage be consistent within the document.
2012
+ The configured code fence style can be a specific symbol to use (`backtick`,
2013
+ `tilde`) or it can require all code fences match the first code fence
2014
+ (`consistent`).
2003
2015
 
2004
2016
  Rationale: Consistent formatting makes it easier to understand a document.
2005
2017
 
@@ -2033,10 +2045,11 @@ To fix this issue, use the configured emphasis style throughout the document:
2033
2045
  *Text*
2034
2046
  ```
2035
2047
 
2036
- The configured emphasis style can be a specific symbol to use ("asterisk",
2037
- "underscore"), or can require that usage be consistent within the document.
2048
+ The configured emphasis style can be a specific symbol to use (`asterisk`,
2049
+ `underscore`) or can require all emphasis matches the first emphasis
2050
+ (`consistent`).
2038
2051
 
2039
- Note: Emphasis within a word is restricted to "asterisk" in order to avoid
2052
+ Note: Emphasis within a word is restricted to `asterisk` in order to avoid
2040
2053
  unwanted emphasis for words containing internal underscores like_this_one.
2041
2054
 
2042
2055
  Rationale: Consistent formatting makes it easier to understand a document.
@@ -2071,11 +2084,11 @@ To fix this issue, use the configured strong style throughout the document:
2071
2084
  **Text**
2072
2085
  ```
2073
2086
 
2074
- The configured strong style can be a specific symbol to use ("asterisk",
2075
- "underscore"), or can require that usage be consistent within the document.
2087
+ The configured strong style can be a specific symbol to use (`asterisk`,
2088
+ `underscore`) or can require all strong matches the first strong (`consistent`).
2076
2089
 
2077
- Note: Emphasis within a word is restricted to "asterisk" in order to avoid
2078
- unwanted emphasis for words containing internal underscores like_this_one.
2090
+ Note: Emphasis within a word is restricted to `asterisk` in order to avoid
2091
+ unwanted emphasis for words containing internal underscores like__this__one.
2079
2092
 
2080
2093
  Rationale: Consistent formatting makes it easier to understand a document.
2081
2094
 
@@ -2087,6 +2100,10 @@ Tags: `links`
2087
2100
 
2088
2101
  Aliases: `link-fragments`
2089
2102
 
2103
+ Parameters:
2104
+
2105
+ - `ignore_case`: Ignore case of fragments (`boolean`, default `false`)
2106
+
2090
2107
  Fixable: Some violations can be fixed by tooling
2091
2108
 
2092
2109
  This rule is triggered when a link fragment does not match any of the fragments
@@ -2107,9 +2124,9 @@ generated name (see below):
2107
2124
  [Link](#heading-name)
2108
2125
  ```
2109
2126
 
2110
- Link fragments may be handled case-sensitively, so this rule requires fragments
2111
- to exactly match the [GitHub heading algorithm][github-heading-algorithm].
2112
- Therefore, the following example is reported as a violation:
2127
+ For consistency, this rule requires fragments to exactly match the [GitHub
2128
+ heading algorithm][github-heading-algorithm] which converts letters to
2129
+ lowercase. Therefore, the following example is reported as a violation:
2113
2130
 
2114
2131
  ```markdown
2115
2132
  # Heading Name
@@ -2117,6 +2134,10 @@ Therefore, the following example is reported as a violation:
2117
2134
  [Link](#Heading-Name)
2118
2135
  ```
2119
2136
 
2137
+ To ignore case when comparing fragments with heading names, the `ignore_case`
2138
+ parameter can be set to `true`. In this configuration, the previous example is
2139
+ not reported as a violation.
2140
+
2120
2141
  Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
2121
2142
  within a heading to provide a specific name (consisting of only lower-case
2122
2143
  letters, numbers, `-`, and `_`):
@@ -2374,8 +2395,9 @@ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
2374
2395
  is inconsistent about its use of leading and trailing pipe characters (`|`).
2375
2396
 
2376
2397
  By default (`consistent` style), the header row of the first table in a document
2377
- is used to determine the style that is enforced for all tables in that document.
2378
- A specific style can be required by setting the `style` parameter accordingly.
2398
+ is used to determine the style that is enforced for every table in the document.
2399
+ A specific style can be used instead (`leading_and_trailing`, `leading_only`,
2400
+ `no_leading_or_trailing`, `trailing_only`).
2379
2401
 
2380
2402
  This table's header row has leading and trailing pipes, but its delimiter row is
2381
2403
  missing the trailing pipe and its first row of cells is missing the leading
@@ -2453,6 +2475,57 @@ Missing cells in a row create holes in the table and suggest an omission.
2453
2475
 
2454
2476
  [gfm-table-056]: https://github.github.com/gfm/#tables-extension-
2455
2477
 
2478
+ <a name="md058"></a>
2479
+
2480
+ ## `MD058` - Tables should be surrounded by blank lines
2481
+
2482
+ Tags: `table`
2483
+
2484
+ Aliases: `blanks-around-tables`
2485
+
2486
+ Fixable: Some violations can be fixed by tooling
2487
+
2488
+ This rule is triggered when tables are either not preceded or not followed by a
2489
+ blank line:
2490
+
2491
+ ```markdown
2492
+ Some text
2493
+ | Header | Header |
2494
+ | ------ | ------ |
2495
+ | Cell | Cell |
2496
+ > Blockquote
2497
+ ```
2498
+
2499
+ To fix violations of this rule, ensure that all tables have a blank line both
2500
+ before and after (except when the table is at the very beginning or end of the
2501
+ document):
2502
+
2503
+ ```markdown
2504
+ Some text
2505
+
2506
+ | Header | Header |
2507
+ | ------ | ------ |
2508
+ | Cell | Cell |
2509
+
2510
+ > Blockquote
2511
+ ```
2512
+
2513
+ Note that text immediately following a table (i.e., not separated by an empty
2514
+ line) is treated as part of the table (per the specification) and will not
2515
+ trigger this rule:
2516
+
2517
+ ```markdown
2518
+ | Header | Header |
2519
+ | ------ | ------ |
2520
+ | Cell | Cell |
2521
+ This text is part of the table and the next line is blank
2522
+
2523
+ Some text
2524
+ ```
2525
+
2526
+ Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
2527
+ tables that don't have blank lines before and after them.
2528
+
2456
2529
  <!-- markdownlint-configure-file {
2457
2530
  "no-inline-html": {
2458
2531
  "allowed_elements": [
package/doc/md003.md CHANGED
@@ -45,8 +45,8 @@ Setext style H2
45
45
  ```
46
46
 
47
47
  Note: The configured heading style can be a specific style to require (`atx`,
48
- `atx_closed`, `setext`, `setext_with_atx`, `setext_with_atx_closed`), or may
49
- just require that usage is consistent within the document via `consistent`.
48
+ `atx_closed`, `setext`, `setext_with_atx`, `setext_with_atx_closed`), or can
49
+ require that all heading styles match the first heading style via `consistent`.
50
50
 
51
51
  Note: The placement of a horizontal rule directly below a line of text can
52
52
  trigger this rule by turning that text into a level 2 setext-style heading:
package/doc/md004.md CHANGED
@@ -29,9 +29,10 @@ document:
29
29
  * Item 3
30
30
  ```
31
31
 
32
- The configured list style can be a specific symbol to use (asterisk, plus,
33
- dash), to ensure that all list styling is consistent, or to ensure that each
34
- sublist has a consistent symbol that differs from its parent list.
32
+ The configured list style can ensure all list styling is a specific symbol
33
+ (`asterisk`, `plus`, `dash`), ensure each sublist has a consistent symbol that
34
+ differs from its parent list (`sublist`), or ensure all list styles match the
35
+ first list style (`consistent`).
35
36
 
36
37
  For example, the following is valid for the `sublist` style because the
37
38
  outer-most indent uses asterisk, the middle indent uses plus, and the inner-most
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