markdownlint 0.32.1 → 0.34.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 (76) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CONTRIBUTING.md +4 -3
  3. package/README.md +6 -0
  4. package/demo/markdownlint-browser.js +3866 -3564
  5. package/doc/CustomRules.md +14 -7
  6. package/doc/Rules.md +139 -12
  7. package/doc/md013.md +8 -7
  8. package/doc/md024.md +2 -5
  9. package/doc/md049.md +3 -0
  10. package/doc/md050.md +3 -0
  11. package/doc/md051.md +26 -0
  12. package/doc/md055.md +54 -0
  13. package/doc/md056.md +37 -0
  14. package/helpers/README.md +5 -3
  15. package/helpers/helpers.js +5 -5
  16. package/helpers/micromark.cjs +46 -27
  17. package/helpers/package.json +2 -2
  18. package/lib/configuration.d.ts +136 -110
  19. package/lib/constants.js +1 -1
  20. package/lib/markdownlint.d.ts +79 -6
  21. package/lib/markdownlint.js +95 -21
  22. package/lib/md001.js +3 -0
  23. package/lib/md003.js +3 -0
  24. package/lib/md004.js +3 -0
  25. package/lib/md005.js +12 -4
  26. package/lib/md007.js +17 -11
  27. package/lib/md009.js +3 -0
  28. package/lib/md010.js +4 -1
  29. package/lib/md011.js +3 -0
  30. package/lib/md012.js +3 -0
  31. package/lib/md013.js +3 -0
  32. package/lib/md014.js +4 -0
  33. package/lib/md018.js +4 -0
  34. package/lib/md019.js +3 -0
  35. package/lib/md020.js +3 -0
  36. package/lib/md021.js +3 -0
  37. package/lib/md022.js +10 -2
  38. package/lib/md023.js +3 -0
  39. package/lib/md024.js +11 -4
  40. package/lib/md025.js +3 -0
  41. package/lib/md026.js +11 -7
  42. package/lib/md027.js +29 -43
  43. package/lib/md028.js +31 -14
  44. package/lib/md029.js +3 -0
  45. package/lib/md030.js +9 -4
  46. package/lib/md031.js +3 -0
  47. package/lib/md032.js +12 -14
  48. package/lib/md033.js +9 -2
  49. package/lib/md034.js +31 -5
  50. package/lib/md035.js +9 -2
  51. package/lib/md036.js +33 -39
  52. package/lib/md037.js +10 -2
  53. package/lib/md038.js +27 -18
  54. package/lib/md039.js +4 -0
  55. package/lib/md040.js +26 -21
  56. package/lib/md041.js +21 -26
  57. package/lib/md042.js +4 -0
  58. package/lib/md043.js +3 -0
  59. package/lib/md044.js +9 -1
  60. package/lib/md045.js +10 -3
  61. package/lib/md046.js +14 -7
  62. package/lib/md047.js +5 -2
  63. package/lib/md048.js +26 -13
  64. package/lib/md049-md050.js +26 -7
  65. package/lib/md051.js +20 -16
  66. package/lib/md052.js +3 -0
  67. package/lib/md053.js +3 -0
  68. package/lib/md054.js +10 -5
  69. package/lib/md055.js +80 -0
  70. package/lib/md056.js +52 -0
  71. package/lib/rules.js +5 -3
  72. package/package.json +26 -32
  73. package/schema/.markdownlint.jsonc +58 -51
  74. package/schema/.markdownlint.yaml +56 -50
  75. package/schema/ValidatingConfiguration.md +28 -0
  76. package/schema/markdownlint-config-schema.json +165 -113
@@ -28,11 +28,13 @@ the parsed input and a function to log any violations.
28
28
  A simple rule implementation looks like:
29
29
 
30
30
  ```javascript
31
+ /** @type import("markdownlint").Rule */
31
32
  module.exports = {
32
33
  "names": [ "any-blockquote" ],
33
34
  "description": "Rule that reports an error for any blockquote",
34
35
  "information": new URL("https://example.com/rules/any-blockquote"),
35
36
  "tags": [ "test" ],
37
+ "parser": "markdownit",
36
38
  "function": function rule(params, onError) {
37
39
  params.parsers.markdownit.tokens.filter(function filterToken(token) {
38
40
  return token.type === "blockquote_open";
@@ -48,8 +50,7 @@ module.exports = {
48
50
  };
49
51
  ```
50
52
 
51
- A rule is implemented as an `Object` with one optional and four required
52
- properties:
53
+ A rule is implemented as an `Object`:
53
54
 
54
55
  - `names` is a required `Array` of `String` values that identify the rule in
55
56
  output messages and config.
@@ -59,6 +60,9 @@ properties:
59
60
  about the rule.
60
61
  - `tags` is a required `Array` of `String` values that groups related rules for
61
62
  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.
62
66
  - `asynchronous` is an optional `Boolean` value that indicates whether the rule
63
67
  returns a `Promise` and runs asynchronously.
64
68
  - `function` is a required `Function` that implements the rule and is passed two
@@ -66,8 +70,13 @@ properties:
66
70
  - `params` is an `Object` with properties that describe the content being
67
71
  analyzed:
68
72
  - `name` is a `String` that identifies the input file/string.
69
- - `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token] with
70
- added `line` and `lineNumber` properties.
73
+ - `parsers` is an `Object` with properties corresponding to the value of
74
+ `parser` in the rule definition (see above).
75
+ - `markdownit` is an `Object` that provides access to output from the
76
+ [`markdown-it`][markdown-it] parser.
77
+ - `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token]
78
+ with added `line` and `lineNumber` properties. (This property was
79
+ previously on the `params` object.)
71
80
  - `lines` is an `Array` of `String` values corresponding to the lines of the
72
81
  input file/string.
73
82
  - `frontMatterLines` is an `Array` of `String` values corresponding to any
@@ -122,7 +131,6 @@ exception.
122
131
  - [Code for all `markdownlint` built-in rules][lib]
123
132
  - [Package configuration for publishing to npm][test-rules-npm]
124
133
  - Packages should export a single rule object or an `Array` of rule objects
125
- - [Custom rules from the axibase/docs-util repository][docs-util]
126
134
  - [Custom rules from the webhintio/hint repository][hint]
127
135
 
128
136
  ## References
@@ -145,7 +153,7 @@ Yields the `params` object:
145
153
  ```json
146
154
  {
147
155
  "name": "doc/example.md",
148
- "tokens": [
156
+ "parsers.markdownit.tokens": [
149
157
  {
150
158
  "type": "heading_open",
151
159
  "tag": "h1",
@@ -364,7 +372,6 @@ Yields the `params` object:
364
372
  ```
365
373
 
366
374
  [commonmark]: https://commonmark.org/
367
- [docs-util]: https://github.com/axibase/docs-util/tree/master/linting-rules
368
375
  [hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
369
376
  [lib]: ../lib
370
377
  [markdown-it]: https://github.com/markdown-it/markdown-it
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
- And this line is a violation because there are
499
- This-line-is-also-okay-because-there-are-no-spaces
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` or `stern` modes, the two middle lines above are a violation. The
503
- third line is a violation in `strict` mode but allowed in `stern` mode.
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 are always exempted from this rule
513
- (even in `strict` mode) because there is generally no way to split such lines
514
- without breaking the URL.
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>.
@@ -801,8 +802,6 @@ Aliases: `no-duplicate-heading`
801
802
 
802
803
  Parameters:
803
804
 
804
- - `allow_different_nesting`: Only check sibling headings (`boolean`, default
805
- `false`)
806
805
  - `siblings_only`: Only check sibling headings (`boolean`, default `false`)
807
806
 
808
807
  This rule is triggered if there are multiple headings in the document that have
@@ -822,9 +821,8 @@ To fix this, ensure that the content of each heading is different:
822
821
  ## Some more text
823
822
  ```
824
823
 
825
- If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
826
- set to `true`, heading duplication is allowed for non-sibling headings (common
827
- in changelogs):
824
+ If the parameter `siblings_only` is set to `true`, duplication is allowed for
825
+ headings with different parents (as is common in changelogs):
828
826
 
829
827
  ```markdown
830
828
  # Change log
@@ -2038,6 +2036,9 @@ To fix this issue, use the configured emphasis style throughout the document:
2038
2036
  The configured emphasis style can be a specific symbol to use ("asterisk",
2039
2037
  "underscore"), or can require that usage be consistent within the document.
2040
2038
 
2039
+ Note: Emphasis within a word is restricted to "asterisk" in order to avoid
2040
+ unwanted emphasis for words containing internal underscores like_this_one.
2041
+
2041
2042
  Rationale: Consistent formatting makes it easier to understand a document.
2042
2043
 
2043
2044
  <a name="md050"></a>
@@ -2073,6 +2074,9 @@ To fix this issue, use the configured strong style throughout the document:
2073
2074
  The configured strong style can be a specific symbol to use ("asterisk",
2074
2075
  "underscore"), or can require that usage be consistent within the document.
2075
2076
 
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.
2079
+
2076
2080
  Rationale: Consistent formatting makes it easier to understand a document.
2077
2081
 
2078
2082
  <a name="md051"></a>
@@ -2103,6 +2107,16 @@ generated name (see below):
2103
2107
  [Link](#heading-name)
2104
2108
  ```
2105
2109
 
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:
2113
+
2114
+ ```markdown
2115
+ # Heading Name
2116
+
2117
+ [Link](#Heading-Name)
2118
+ ```
2119
+
2106
2120
  Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
2107
2121
  within a heading to provide a specific name (consisting of only lower-case
2108
2122
  letters, numbers, `-`, and `_`):
@@ -2125,6 +2139,21 @@ attribute can be used to define a fragment:
2125
2139
  An `a` tag can be useful in scenarios where a heading is not appropriate or for
2126
2140
  control over the text of the fragment identifier.
2127
2141
 
2142
+ This rule also recognizes the custom fragment syntax used by GitHub to highlight
2143
+ [specific content in a document][github-linking-to-content].
2144
+
2145
+ For example, this link to line 20:
2146
+
2147
+ ```markdown
2148
+ [Link](#L20)
2149
+ ```
2150
+
2151
+ And this link to content starting within line 19 running into line 21:
2152
+
2153
+ ```markdown
2154
+ [Link](#L19C5-L21C11)
2155
+ ```
2156
+
2128
2157
  Rationale: [GitHub section links][github-section-links] are created
2129
2158
  automatically for every heading when Markdown content is displayed on GitHub.
2130
2159
  This makes it easy to link directly to different sections within a document.
@@ -2138,6 +2167,7 @@ append an incrementing integer as needed for uniqueness.
2138
2167
 
2139
2168
  [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
2140
2169
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
2170
+ [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
2141
2171
 
2142
2172
  <a name="md052"></a>
2143
2173
 
@@ -2326,6 +2356,103 @@ Inline links and images can include descriptive text, but take up more space in
2326
2356
  Markdown form. Reference links and images can be easier to read and manipulate
2327
2357
  in Markdown form, but require a separate link reference definition.
2328
2358
 
2359
+ <a name="md055"></a>
2360
+
2361
+ ## `MD055` - Table pipe style
2362
+
2363
+ Tags: `table`
2364
+
2365
+ Aliases: `table-pipe-style`
2366
+
2367
+ Parameters:
2368
+
2369
+ - `style`: Table pipe style (`string`, default `consistent`, values
2370
+ `consistent` / `leading_and_trailing` / `leading_only` /
2371
+ `no_leading_or_trailing` / `trailing_only`)
2372
+
2373
+ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
2374
+ is inconsistent about its use of leading and trailing pipe characters (`|`).
2375
+
2376
+ 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.
2379
+
2380
+ This table's header row has leading and trailing pipes, but its delimiter row is
2381
+ missing the trailing pipe and its first row of cells is missing the leading
2382
+ pipe:
2383
+
2384
+ ```markdown
2385
+ | Header | Header |
2386
+ | ------ | ------
2387
+ Cell | Cell |
2388
+ ```
2389
+
2390
+ To fix these issues, make sure there is a pipe character at the beginning and
2391
+ end of every row:
2392
+
2393
+ ```markdown
2394
+ | Header | Header |
2395
+ | ------ | ------ |
2396
+ | Cell | Cell |
2397
+ ```
2398
+
2399
+ Note that text immediately following a table (i.e., not separated by an empty
2400
+ line) is treated as part of the table (per the specification) and may also
2401
+ trigger this rule:
2402
+
2403
+ ```markdown
2404
+ | Header | Header |
2405
+ | ------ | ------ |
2406
+ | Cell | Cell |
2407
+ This text is part of the table
2408
+ ```
2409
+
2410
+ Rationale: Some parsers have difficulty with tables that are missing their
2411
+ leading or trailing pipe characters. The use of leading/trailing pipes can also
2412
+ help provide visual clarity.
2413
+
2414
+ [gfm-table-055]: https://github.github.com/gfm/#tables-extension-
2415
+
2416
+ <a name="md056"></a>
2417
+
2418
+ ## `MD056` - Table column count
2419
+
2420
+ Tags: `table`
2421
+
2422
+ Aliases: `table-column-count`
2423
+
2424
+ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-056]
2425
+ does not have the same number of cells in every row.
2426
+
2427
+ This table's second data row has too few cells and its third data row has too
2428
+ many cells:
2429
+
2430
+ ```markdown
2431
+ | Header | Header |
2432
+ | ------ | ------ |
2433
+ | Cell | Cell |
2434
+ | Cell |
2435
+ | Cell | Cell | Cell |
2436
+ ```
2437
+
2438
+ To fix these issues, ensure every row has the same number of cells:
2439
+
2440
+ ```markdown
2441
+ | Header | Header |
2442
+ | ------ | ------ |
2443
+ | Cell | Cell |
2444
+ | Cell | Cell |
2445
+ | Cell | Cell |
2446
+ ```
2447
+
2448
+ Note that a table's header row and its delimiter row must have the same number
2449
+ of cells or it will not be recognized as a table (per specification).
2450
+
2451
+ Rationale: Extra cells in a row are usually not shown, so their data is lost.
2452
+ Missing cells in a row create holes in the table and suggest an omission.
2453
+
2454
+ [gfm-table-056]: https://github.github.com/gfm/#tables-extension-
2455
+
2329
2456
  <!-- markdownlint-configure-file {
2330
2457
  "no-inline-html": {
2331
2458
  "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
- And this line is a violation because there are
39
- This-line-is-also-okay-because-there-are-no-spaces
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` or `stern` modes, the two middle lines above are a violation. The
43
- third line is a violation in `strict` mode but allowed in `stern` mode.
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 are always exempted from this rule
53
- (even in `strict` mode) because there is generally no way to split such lines
54
- without breaking the URL.
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/md024.md CHANGED
@@ -6,8 +6,6 @@ Aliases: `no-duplicate-heading`
6
6
 
7
7
  Parameters:
8
8
 
9
- - `allow_different_nesting`: Only check sibling headings (`boolean`, default
10
- `false`)
11
9
  - `siblings_only`: Only check sibling headings (`boolean`, default `false`)
12
10
 
13
11
  This rule is triggered if there are multiple headings in the document that have
@@ -27,9 +25,8 @@ To fix this, ensure that the content of each heading is different:
27
25
  ## Some more text
28
26
  ```
29
27
 
30
- If the parameter `siblings_only` (alternatively `allow_different_nesting`) is
31
- set to `true`, heading duplication is allowed for non-sibling headings (common
32
- in changelogs):
28
+ If the parameter `siblings_only` is set to `true`, duplication is allowed for
29
+ headings with different parents (as is common in changelogs):
33
30
 
34
31
  ```markdown
35
32
  # Change log
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/md055.md ADDED
@@ -0,0 +1,54 @@
1
+ # `MD055` - Table pipe style
2
+
3
+ Tags: `table`
4
+
5
+ Aliases: `table-pipe-style`
6
+
7
+ Parameters:
8
+
9
+ - `style`: Table pipe style (`string`, default `consistent`, values
10
+ `consistent` / `leading_and_trailing` / `leading_only` /
11
+ `no_leading_or_trailing` / `trailing_only`)
12
+
13
+ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
14
+ is inconsistent about its use of leading and trailing pipe characters (`|`).
15
+
16
+ By default (`consistent` style), the header row of the first table in a document
17
+ is used to determine the style that is enforced for all tables in that document.
18
+ A specific style can be required by setting the `style` parameter accordingly.
19
+
20
+ This table's header row has leading and trailing pipes, but its delimiter row is
21
+ missing the trailing pipe and its first row of cells is missing the leading
22
+ pipe:
23
+
24
+ ```markdown
25
+ | Header | Header |
26
+ | ------ | ------
27
+ Cell | Cell |
28
+ ```
29
+
30
+ To fix these issues, make sure there is a pipe character at the beginning and
31
+ end of every row:
32
+
33
+ ```markdown
34
+ | Header | Header |
35
+ | ------ | ------ |
36
+ | Cell | Cell |
37
+ ```
38
+
39
+ Note that text immediately following a table (i.e., not separated by an empty
40
+ line) is treated as part of the table (per the specification) and may also
41
+ trigger this rule:
42
+
43
+ ```markdown
44
+ | Header | Header |
45
+ | ------ | ------ |
46
+ | Cell | Cell |
47
+ This text is part of the table
48
+ ```
49
+
50
+ Rationale: Some parsers have difficulty with tables that are missing their
51
+ leading or trailing pipe characters. The use of leading/trailing pipes can also
52
+ help provide visual clarity.
53
+
54
+ [gfm-table-055]: https://github.github.com/gfm/#tables-extension-
package/doc/md056.md ADDED
@@ -0,0 +1,37 @@
1
+ # `MD056` - Table column count
2
+
3
+ Tags: `table`
4
+
5
+ Aliases: `table-column-count`
6
+
7
+ This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-056]
8
+ does not have the same number of cells in every row.
9
+
10
+ This table's second data row has too few cells and its third data row has too
11
+ many cells:
12
+
13
+ ```markdown
14
+ | Header | Header |
15
+ | ------ | ------ |
16
+ | Cell | Cell |
17
+ | Cell |
18
+ | Cell | Cell | Cell |
19
+ ```
20
+
21
+ To fix these issues, ensure every row has the same number of cells:
22
+
23
+ ```markdown
24
+ | Header | Header |
25
+ | ------ | ------ |
26
+ | Cell | Cell |
27
+ | Cell | Cell |
28
+ | Cell | Cell |
29
+ ```
30
+
31
+ Note that a table's header row and its delimiter row must have the same number
32
+ of cells or it will not be recognized as a table (per specification).
33
+
34
+ Rationale: Extra cells in a row are usually not shown, so their data is lost.
35
+ Missing cells in a row create holes in the table and suggest an omission.
36
+
37
+ [gfm-table-056]: https://github.github.com/gfm/#tables-extension-
package/helpers/README.md CHANGED
@@ -24,10 +24,12 @@ be useful to custom rule authors and may avoid duplicating code.
24
24
  ```javascript
25
25
  const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
26
26
 
27
+ /** @type import("markdownlint").Rule */
27
28
  module.exports = {
28
29
  "names": [ "every-n-lines" ],
29
30
  "description": "Rule that reports an error every N lines",
30
31
  "tags": [ "test" ],
32
+ "parser": "none",
31
33
  "function": (params, onError) => {
32
34
  const n = params.config.n || 2;
33
35
  forEachLine(getLineMetadata(params), (line, lineIndex) => {
@@ -62,9 +64,9 @@ See also: [`markdownlint` built-in rule implementations][lib].
62
64
  *None* - The entire body of code is tested to 100% coverage by the core
63
65
  `markdownlint` project, so there are no additional tests here.
64
66
 
65
- [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md
67
+ [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/CustomRules.md
66
68
  [jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
67
- [lib]: https://github.com/DavidAnson/markdownlint/tree/main/lib
69
+ [lib]: https://github.com/DavidAnson/markdownlint/tree/v0.34.0/lib
68
70
  [markdown]: https://en.wikipedia.org/wiki/Markdown
69
71
  [markdownlint]: https://github.com/DavidAnson/markdownlint
70
- [rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
72
+ [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/Rules.md
@@ -277,7 +277,7 @@ module.exports.fencedCodeBlockStyleFor =
277
277
  * Return the string representation of a emphasis or strong markup character.
278
278
  *
279
279
  * @param {string} markup Emphasis or strong string.
280
- * @returns {string} String representation.
280
+ * @returns {"asterisk" | "underscore"} String representation.
281
281
  */
282
282
  module.exports.emphasisOrStrongStyleFor =
283
283
  function emphasisOrStrongStyleFor(markup) {
@@ -316,7 +316,7 @@ module.exports.headingStyleFor = function headingStyleFor(token) {
316
316
  * Return the string representation of an unordered list marker.
317
317
  *
318
318
  * @param {Object} token MarkdownItToken instance.
319
- * @returns {string} String representation.
319
+ * @returns {"asterisk" | "dash" | "plus"} String representation.
320
320
  */
321
321
  module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
322
322
  switch (token.markup) {
@@ -702,10 +702,10 @@ module.exports.frontMatterHasTitle =
702
702
  /**
703
703
  * Returns an object with information about reference links and images.
704
704
  *
705
- * @param {Object} params RuleParams instance.
705
+ * @param {import("../helpers/micromark.cjs").Token[]} tokens Micromark tokens.
706
706
  * @returns {Object} Reference link/image data.
707
707
  */
708
- function getReferenceLinkImageData(params) {
708
+ function getReferenceLinkImageData(tokens) {
709
709
  const normalizeReference = (s) => s.toLowerCase().trim().replace(/\s+/g, " ");
710
710
  const definitions = new Map();
711
711
  const definitionLineIndices = [];
@@ -714,7 +714,7 @@ function getReferenceLinkImageData(params) {
714
714
  const shortcuts = new Map();
715
715
  const filteredTokens =
716
716
  micromark.filterByTypes(
717
- params.parsers.micromark.tokens,
717
+ tokens,
718
718
  [
719
719
  // definitionLineIndices
720
720
  "definition", "gfmFootnoteDefinition",