markdownlint 0.39.0 → 0.40.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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.40.0
4
+
5
+ - Improve MD011/MD013/MD051/MD060
6
+ - Update dependencies
7
+
3
8
  ## 0.39.0
4
9
 
5
10
  - Add MD060/table-column-style
package/CONTRIBUTING.md CHANGED
@@ -83,7 +83,7 @@ Thank you!
83
83
  [ava-snapshots]: https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md
84
84
  [closing-keywords]: https://help.github.com/articles/closing-issues-using-keywords/
85
85
  [custom-rules]: doc/CustomRules.md
86
- [dependencies]: https://docs.npmjs.com/files/package.json#dependencies
86
+ [dependencies]: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#dependencies
87
87
  [example-com]: https://en.wikipedia.org/wiki/Example.com
88
88
  [micromark]: https://www.npmjs.com/package/micromark
89
89
  [new-rule]: https://github.com/DavidAnson/markdownlint/labels/new%20rule
package/README.md CHANGED
@@ -206,11 +206,10 @@ issues reported. Two kinds of text are ignored by most rules:
206
206
  - [Front matter](https://jekyllrb.com/docs/frontmatter/) (see
207
207
  `options.frontMatter` below)
208
208
 
209
- Rules can be enabled, disabled, and configured via `options.config`
210
- (described below) to define the expected behavior for a set of inputs.
211
- To enable or disable rules at a particular location within a file, add
212
- one of these markers to the appropriate place (HTML comments don't
213
- appear in the final markup):
209
+ All rules are enabled by default. Rules can be enabled, disabled, and configured
210
+ for each call to the `lint` API by passing an `options.config` object (described
211
+ below). To enable or disable rules within a file, use one of the following HTML
212
+ comments (which are not rendered):
214
213
 
215
214
  - Disable all rules: `<!-- markdownlint-disable -->`
216
215
  - Enable all rules: `<!-- markdownlint-enable -->`
@@ -980,7 +979,7 @@ All of which return an object like:
980
979
  { "lineNumber": 3,
981
980
  "ruleNames": [ "MD010", "no-hard-tabs" ],
982
981
  "ruleDescription": "Hard tabs",
983
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md010.md",
982
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md",
984
983
  "errorDetail": "Column: 17",
985
984
  "errorContext": null,
986
985
  "errorRange": [ 17, 1 ],
@@ -989,7 +988,7 @@ All of which return an object like:
989
988
  { "lineNumber": 1,
990
989
  "ruleNames": [ "MD018", "no-missing-space-atx" ],
991
990
  "ruleDescription": "No space after hash on atx style heading",
992
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md018.md",
991
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md018.md",
993
992
  "errorDetail": null,
994
993
  "errorContext": "#bad.md",
995
994
  "errorRange": [ 1, 2 ],
@@ -998,7 +997,7 @@ All of which return an object like:
998
997
  { "lineNumber": 3,
999
998
  "ruleNames": [ "MD018", "no-missing-space-atx" ],
1000
999
  "ruleDescription": "No space after hash on atx style heading",
1001
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md018.md",
1000
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md018.md",
1002
1001
  "errorDetail": null,
1003
1002
  "errorContext": "#This file fails\tsome rules.",
1004
1003
  "errorRange": [ 1, 2 ],
@@ -1007,7 +1006,7 @@ All of which return an object like:
1007
1006
  { "lineNumber": 1,
1008
1007
  "ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
1009
1008
  "ruleDescription": "First line in a file should be a top-level heading",
1010
- "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md041.md",
1009
+ "ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md041.md",
1011
1010
  "errorDetail": null,
1012
1011
  "errorContext": "#bad.md",
1013
1012
  "errorRange": null,
package/doc/Rules.md CHANGED
@@ -2284,14 +2284,19 @@ This makes it easy to link directly to different sections within a document.
2284
2284
  However, section links change if headings are renamed or removed. This rule
2285
2285
  helps identify broken section links within a document.
2286
2286
 
2287
- Section links are **not** part of the CommonMark specification. This rule
2288
- enforces the [GitHub heading algorithm][github-heading-algorithm] which is:
2289
- convert heading to lowercase, remove punctuation, convert spaces to dashes,
2290
- append an incrementing integer as needed for uniqueness.
2287
+ Note: Section links are **not** part of the CommonMark specification; this rule
2288
+ enforces the [GitHub heading algorithm][github-heading-algorithm]:
2291
2289
 
2290
+ 1. Convert text to lowercase
2291
+ 2. Remove punctuation characters
2292
+ 3. Convert spaces to dashes
2293
+ 4. Append an incrementing integer (as needed for uniqueness)
2294
+ 5. [URI-encode][encodeURIComponent] the result
2295
+
2296
+ [encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
2292
2297
  [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
2293
2298
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
2294
- [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
2299
+ [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
2295
2300
  [html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
2296
2301
  [RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
2297
2302
 
@@ -2689,15 +2694,16 @@ Aliases: `table-column-style`
2689
2694
 
2690
2695
  Parameters:
2691
2696
 
2697
+ - `aligned_delimiter`: Aligned delimiter columns (`boolean`, default `false`)
2692
2698
  - `style`: Table column style (`string`, default `any`, values `aligned` /
2693
2699
  `any` / `compact` / `tight`)
2694
2700
 
2695
- This rule is triggered when the column separators of a
2701
+ This rule is triggered when the column separator pipe characters (`|`) of a
2696
2702
  [GitHub Flavored Markdown table][gfm-table-060] are used inconsistently.
2697
2703
 
2698
- This rule recognizes three table column styles based on popular use:
2704
+ This rule recognizes three table column styles based on popular use.
2699
2705
 
2700
- Style `aligned` looks the most like a table:
2706
+ Style `aligned` ensures pipe characters are vertically aligned:
2701
2707
 
2702
2708
  ```markdown
2703
2709
  | Character | Meaning |
@@ -2706,7 +2712,16 @@ Style `aligned` looks the most like a table:
2706
2712
  | N | No |
2707
2713
  ```
2708
2714
 
2709
- Style `compact` uses a single space to pad cell content:
2715
+ The `aligned` style ignores cell content, so the following is also valid:
2716
+
2717
+ ```markdown
2718
+ | Character | Meaning |
2719
+ |-----------|---------|
2720
+ | Y | Yes |
2721
+ | N | No |
2722
+ ```
2723
+
2724
+ Style `compact` avoids extra padding with a single space around cell content:
2710
2725
 
2711
2726
  ```markdown
2712
2727
  | Character | Meaning |
@@ -2715,7 +2730,7 @@ Style `compact` uses a single space to pad cell content:
2715
2730
  | N | No |
2716
2731
  ```
2717
2732
 
2718
- Style `tight` uses no padding for cell content:
2733
+ Style `tight` uses no padding at all for cell content:
2719
2734
 
2720
2735
  ```markdown
2721
2736
  |Character|Meaning|
@@ -2725,16 +2740,51 @@ Style `tight` uses no padding for cell content:
2725
2740
  ```
2726
2741
 
2727
2742
  When this rule's `style` parameter is set to `aligned`, `compact`, or `tight`,
2728
- every table must match the corresponding pattern and errors will be reported for
2729
- any violations. By default, or when the `any` style is used, each table is
2730
- analyzed to see if it satisfies any supported style. If so, no errors are
2731
- reported. If not, errors are be reported for whichever style would produce the
2732
- *fewest* errors (i.e., whichever style is the closest match).
2743
+ every table must match the corresponding pattern and any violations will be
2744
+ reported. By default, or when the `any` style is used, each table is analyzed to
2745
+ see if it satisfies any supported style. If so, no violations are reported. If
2746
+ not, violations are be reported for whichever style would produce the *fewest*
2747
+ issues (i.e., whichever style is the closest match).
2748
+
2749
+ Setting the `aligned_delimiter` parameter to `true` requires pipe characters in
2750
+ the delimiter row to align with those in the header row. This can be used with
2751
+ `compact` and `tight` tables to make the header text more obvious. (It's already
2752
+ required for tables with style `aligned`.)
2753
+
2754
+ Style `compact` with `aligned_delimiter`:
2755
+
2756
+ ```markdown
2757
+ | Character | Meaning |
2758
+ | --------- | ------- |
2759
+ | Y | Yes |
2760
+ | N | No |
2761
+ ```
2762
+
2763
+ Style `tight` with `aligned_delimiter`:
2764
+
2765
+ ```markdown
2766
+ |Character|Meaning|
2767
+ |---------|-------|
2768
+ |Y|Yes|
2769
+ |N|No|
2770
+ ```
2771
+
2772
+ **Note**: This rule does not require leading/trailing pipe characters, so this
2773
+ is also a valid table for style `compact`:
2774
+
2775
+ ```markdown
2776
+ Character | Meaning
2777
+ --- | ---
2778
+ Y | Yes
2779
+ N | No
2780
+ ```
2733
2781
 
2734
- Note: Pipe alignment for the `aligned` style is based on character count, so
2735
- wide characters and multi-character encodings can produce unexpected results.
2736
- The following table is correctly aligned based on character count, though some
2737
- editors render the emoji wider:
2782
+ **Note**: Pipe alignment for the `aligned` style is based on visual appearance
2783
+ and not character count. Because editors typically render [emoji][emoji] and
2784
+ [CJK characters][cjk-characters] at *twice* the width of
2785
+ [Latin characters][latin-script], this rule takes that into account for tables
2786
+ using the `aligned` style. The following table is correctly formatted and will
2787
+ appear aligned in most editors and monospaced fonts:
2738
2788
 
2739
2789
  <!-- markdownlint-capture -->
2740
2790
  <!-- markdownlint-disable extended-ascii -->
@@ -2742,15 +2792,18 @@ editors render the emoji wider:
2742
2792
  ```markdown
2743
2793
  | Response | Emoji |
2744
2794
  | -------- | ----- |
2745
- | Yes | ✅ |
2746
- | No | ❎ |
2795
+ | Yes | ✅ |
2796
+ | No | ❎ |
2747
2797
  ```
2748
2798
 
2749
2799
  <!-- markdownlint-restore -->
2750
2800
 
2751
2801
  Rationale: Consistent formatting makes it easier to understand a document.
2752
2802
 
2803
+ [cjk-characters]: https://en.wikipedia.org/wiki/CJK_characters
2804
+ [emoji]: https://en.wikipedia.org/wiki/Emoji
2753
2805
  [gfm-table-060]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
2806
+ [latin-script]: https://en.wikipedia.org/wiki/Latin_script
2754
2807
 
2755
2808
  <!-- markdownlint-configure-file {
2756
2809
  "no-inline-html": {
package/doc/md051.md CHANGED
@@ -100,13 +100,18 @@ This makes it easy to link directly to different sections within a document.
100
100
  However, section links change if headings are renamed or removed. This rule
101
101
  helps identify broken section links within a document.
102
102
 
103
- Section links are **not** part of the CommonMark specification. This rule
104
- enforces the [GitHub heading algorithm][github-heading-algorithm] which is:
105
- convert heading to lowercase, remove punctuation, convert spaces to dashes,
106
- append an incrementing integer as needed for uniqueness.
103
+ Note: Section links are **not** part of the CommonMark specification; this rule
104
+ enforces the [GitHub heading algorithm][github-heading-algorithm]:
107
105
 
106
+ 1. Convert text to lowercase
107
+ 2. Remove punctuation characters
108
+ 3. Convert spaces to dashes
109
+ 4. Append an incrementing integer (as needed for uniqueness)
110
+ 5. [URI-encode][encodeURIComponent] the result
111
+
112
+ [encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
108
113
  [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
109
114
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
110
- [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
115
+ [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
111
116
  [html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
112
117
  [RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
package/doc/md060.md CHANGED
@@ -6,15 +6,16 @@ Aliases: `table-column-style`
6
6
 
7
7
  Parameters:
8
8
 
9
+ - `aligned_delimiter`: Aligned delimiter columns (`boolean`, default `false`)
9
10
  - `style`: Table column style (`string`, default `any`, values `aligned` /
10
11
  `any` / `compact` / `tight`)
11
12
 
12
- This rule is triggered when the column separators of a
13
+ This rule is triggered when the column separator pipe characters (`|`) of a
13
14
  [GitHub Flavored Markdown table][gfm-table-060] are used inconsistently.
14
15
 
15
- This rule recognizes three table column styles based on popular use:
16
+ This rule recognizes three table column styles based on popular use.
16
17
 
17
- Style `aligned` looks the most like a table:
18
+ Style `aligned` ensures pipe characters are vertically aligned:
18
19
 
19
20
  ```markdown
20
21
  | Character | Meaning |
@@ -23,7 +24,16 @@ Style `aligned` looks the most like a table:
23
24
  | N | No |
24
25
  ```
25
26
 
26
- Style `compact` uses a single space to pad cell content:
27
+ The `aligned` style ignores cell content, so the following is also valid:
28
+
29
+ ```markdown
30
+ | Character | Meaning |
31
+ |-----------|---------|
32
+ | Y | Yes |
33
+ | N | No |
34
+ ```
35
+
36
+ Style `compact` avoids extra padding with a single space around cell content:
27
37
 
28
38
  ```markdown
29
39
  | Character | Meaning |
@@ -32,7 +42,7 @@ Style `compact` uses a single space to pad cell content:
32
42
  | N | No |
33
43
  ```
34
44
 
35
- Style `tight` uses no padding for cell content:
45
+ Style `tight` uses no padding at all for cell content:
36
46
 
37
47
  ```markdown
38
48
  |Character|Meaning|
@@ -42,16 +52,51 @@ Style `tight` uses no padding for cell content:
42
52
  ```
43
53
 
44
54
  When this rule's `style` parameter is set to `aligned`, `compact`, or `tight`,
45
- every table must match the corresponding pattern and errors will be reported for
46
- any violations. By default, or when the `any` style is used, each table is
47
- analyzed to see if it satisfies any supported style. If so, no errors are
48
- reported. If not, errors are be reported for whichever style would produce the
49
- *fewest* errors (i.e., whichever style is the closest match).
55
+ every table must match the corresponding pattern and any violations will be
56
+ reported. By default, or when the `any` style is used, each table is analyzed to
57
+ see if it satisfies any supported style. If so, no violations are reported. If
58
+ not, violations are be reported for whichever style would produce the *fewest*
59
+ issues (i.e., whichever style is the closest match).
60
+
61
+ Setting the `aligned_delimiter` parameter to `true` requires pipe characters in
62
+ the delimiter row to align with those in the header row. This can be used with
63
+ `compact` and `tight` tables to make the header text more obvious. (It's already
64
+ required for tables with style `aligned`.)
65
+
66
+ Style `compact` with `aligned_delimiter`:
67
+
68
+ ```markdown
69
+ | Character | Meaning |
70
+ | --------- | ------- |
71
+ | Y | Yes |
72
+ | N | No |
73
+ ```
74
+
75
+ Style `tight` with `aligned_delimiter`:
76
+
77
+ ```markdown
78
+ |Character|Meaning|
79
+ |---------|-------|
80
+ |Y|Yes|
81
+ |N|No|
82
+ ```
83
+
84
+ **Note**: This rule does not require leading/trailing pipe characters, so this
85
+ is also a valid table for style `compact`:
86
+
87
+ ```markdown
88
+ Character | Meaning
89
+ --- | ---
90
+ Y | Yes
91
+ N | No
92
+ ```
50
93
 
51
- Note: Pipe alignment for the `aligned` style is based on character count, so
52
- wide characters and multi-character encodings can produce unexpected results.
53
- The following table is correctly aligned based on character count, though some
54
- editors render the emoji wider:
94
+ **Note**: Pipe alignment for the `aligned` style is based on visual appearance
95
+ and not character count. Because editors typically render [emoji][emoji] and
96
+ [CJK characters][cjk-characters] at *twice* the width of
97
+ [Latin characters][latin-script], this rule takes that into account for tables
98
+ using the `aligned` style. The following table is correctly formatted and will
99
+ appear aligned in most editors and monospaced fonts:
55
100
 
56
101
  <!-- markdownlint-capture -->
57
102
  <!-- markdownlint-disable extended-ascii -->
@@ -59,12 +104,15 @@ editors render the emoji wider:
59
104
  ```markdown
60
105
  | Response | Emoji |
61
106
  | -------- | ----- |
62
- | Yes | ✅ |
63
- | No | ❎ |
107
+ | Yes | ✅ |
108
+ | No | ❎ |
64
109
  ```
65
110
 
66
111
  <!-- markdownlint-restore -->
67
112
 
68
113
  Rationale: Consistent formatting makes it easier to understand a document.
69
114
 
115
+ [cjk-characters]: https://en.wikipedia.org/wiki/CJK_characters
116
+ [emoji]: https://en.wikipedia.org/wiki/Emoji
70
117
  [gfm-table-060]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
118
+ [latin-script]: https://en.wikipedia.org/wiki/Latin_script
package/helpers/README.md CHANGED
@@ -22,8 +22,8 @@ be useful to custom rule authors and may avoid duplicating code.
22
22
  *None* - The entire body of code is tested to 100% coverage by the core
23
23
  `markdownlint` project, so there are no additional tests here.
24
24
 
25
- [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/doc/CustomRules.md
25
+ [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/CustomRules.md
26
26
  [jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
27
27
  [markdown]: https://en.wikipedia.org/wiki/Markdown
28
28
  [markdownlint]: https://github.com/DavidAnson/markdownlint
29
- [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/doc/Rules.md
29
+ [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/Rules.md