markdownlint 0.38.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +144 -75
  4. package/doc/Rules.md +174 -18
  5. package/doc/md001.md +14 -0
  6. package/doc/md009.md +8 -9
  7. package/doc/md010.md +6 -0
  8. package/doc/md029.md +2 -0
  9. package/doc/md033.md +7 -1
  10. package/doc/md051.md +10 -5
  11. package/doc/md055.md +1 -1
  12. package/doc/md056.md +1 -1
  13. package/doc/md059.md +4 -1
  14. package/doc/md060.md +118 -0
  15. package/helpers/README.md +2 -2
  16. package/helpers/helpers.cjs +171 -15
  17. package/helpers/micromark-helpers.cjs +11 -7
  18. package/helpers/package.json +1 -1
  19. package/lib/cache.mjs +6 -2
  20. package/lib/configuration-strict.d.ts +1351 -205
  21. package/lib/constants.mjs +6 -5
  22. package/lib/defer-require.cjs +2 -0
  23. package/lib/exports.d.mts +1 -2
  24. package/lib/exports.mjs +1 -2
  25. package/lib/markdownit.cjs +2 -1
  26. package/lib/markdownlint.d.mts +101 -51
  27. package/lib/markdownlint.mjs +217 -181
  28. package/lib/md001.mjs +6 -2
  29. package/lib/md004.mjs +7 -18
  30. package/lib/md007.mjs +2 -1
  31. package/lib/md009.mjs +9 -5
  32. package/lib/md010.mjs +1 -1
  33. package/lib/md011.mjs +8 -6
  34. package/lib/md013.mjs +14 -27
  35. package/lib/md022.mjs +5 -2
  36. package/lib/md029.mjs +25 -14
  37. package/lib/md031.mjs +0 -1
  38. package/lib/md032.mjs +3 -1
  39. package/lib/md033.mjs +28 -20
  40. package/lib/md034.mjs +2 -1
  41. package/lib/md036.mjs +5 -3
  42. package/lib/md037.mjs +10 -7
  43. package/lib/md042.mjs +4 -2
  44. package/lib/md043.mjs +2 -2
  45. package/lib/md044.mjs +1 -1
  46. package/lib/md046.mjs +6 -6
  47. package/lib/md053.mjs +1 -1
  48. package/lib/md054.mjs +7 -5
  49. package/lib/md055.mjs +7 -6
  50. package/lib/md056.mjs +1 -1
  51. package/lib/md060.mjs +170 -0
  52. package/lib/micromark-parse.mjs +5 -3
  53. package/lib/node-imports-browser.mjs +2 -0
  54. package/lib/parse-configuration.mjs +5 -4
  55. package/lib/rules.mjs +3 -1
  56. package/package.json +18 -18
  57. package/schema/.markdownlint.jsonc +69 -54
  58. package/schema/.markdownlint.yaml +66 -53
  59. package/schema/markdownlint-config-schema-strict.json +4709 -1537
  60. package/schema/markdownlint-config-schema.json +4709 -1537
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.40.0
4
+
5
+ - Improve MD011/MD013/MD051/MD060
6
+ - Update dependencies
7
+
8
+ ## 0.39.0
9
+
10
+ - Add MD060/table-column-style
11
+ - Improve MD001/MD007/MD009/MD010/MD029/MD033/MD037/MD059
12
+ - Add support for reporting violations as severity `warning`
13
+ - Deprecate `resultVersion` and `toString` (breaking change)
14
+ - Improve type definitions
15
+ - Improve demo web page
16
+ - Update dependencies
17
+
3
18
  ## 0.38.0
4
19
 
5
20
  - Add MD059/descriptive-link-text
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
@@ -149,6 +149,7 @@ playground for learning and exploring.
149
149
  - **[MD056](doc/md056.md)** *table-column-count* - Table column count
150
150
  - **[MD058](doc/md058.md)** *blanks-around-tables* - Tables should be surrounded by blank lines
151
151
  - **[MD059](doc/md059.md)** *descriptive-link-text* - Link text should be descriptive
152
+ - **[MD060](doc/md060.md)** *table-column-style* - Table column style
152
153
 
153
154
  <!-- markdownlint-restore -->
154
155
 
@@ -190,7 +191,7 @@ rules at once.
190
191
  - **`ol`** - `MD029`, `MD030`, `MD032`
191
192
  - **`spaces`** - `MD018`, `MD019`, `MD020`, `MD021`, `MD023`
192
193
  - **`spelling`** - `MD044`
193
- - **`table`** - `MD055`, `MD056`, `MD058`
194
+ - **`table`** - `MD055`, `MD056`, `MD058`, `MD060`
194
195
  - **`ul`** - `MD004`, `MD005`, `MD007`, `MD030`, `MD032`
195
196
  - **`url`** - `MD034`
196
197
  - **`whitespace`** - `MD009`, `MD010`, `MD012`, `MD027`, `MD028`, `MD030`,
@@ -205,11 +206,10 @@ issues reported. Two kinds of text are ignored by most rules:
205
206
  - [Front matter](https://jekyllrb.com/docs/frontmatter/) (see
206
207
  `options.frontMatter` below)
207
208
 
208
- Rules can be enabled, disabled, and configured via `options.config`
209
- (described below) to define the expected behavior for a set of inputs.
210
- To enable or disable rules at a particular location within a file, add
211
- one of these markers to the appropriate place (HTML comments don't
212
- 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):
213
213
 
214
214
  - Disable all rules: `<!-- markdownlint-disable -->`
215
215
  - Enable all rules: `<!-- markdownlint-enable -->`
@@ -361,22 +361,118 @@ of `files` or `strings` should be set to provide input.
361
361
 
362
362
  ##### options.config
363
363
 
364
- Type: `Object` mapping `String` to `Boolean | Object`
364
+ Type: `Object` mapping `String` to `Boolean | "error" | "warning" | Object`
365
365
 
366
366
  Configures the rules to use.
367
367
 
368
368
  Object keys are rule names/aliases; object values are the rule's configuration.
369
- The value `false` disables a rule, `true` enables its default configuration,
370
- and passing an object value customizes that rule. Setting the special `default`
371
- rule to `true` or `false` includes/excludes all rules by default. In the absence
372
- of a configuration object, all rules are enabled. Enabling or disabling a tag
373
- name (ex: `whitespace`) affects all rules having that tag.
369
+ The value `false` disables a rule. The values `true` or `"error"` enable a rule
370
+ in its default configuration and report violations as errors. The value
371
+ `"warning"` enables a rule in its default configuration and reports violations
372
+ as warnings. Passing an object enables *and* customizes the rule; the properties
373
+ `severity` (`"error" | "warning"`) and `enabled` (`false | true`) can be used in
374
+ this context. The special `default` rule assigns the default for all rules.
375
+ Using a tag name (e.g., `whitespace`) and a setting of `false`, `true`,
376
+ `"error"`, or `"warning"` applies that setting to all rules with that tag. When
377
+ no configuration object is passed or the optional `default` setting is not
378
+ present, all rules are enabled.
379
+
380
+ The following syntax disables the specified rule, tag, or `default`:
374
381
 
375
- The `default` rule is applied first, then keys are processed in order from top
376
- to bottom with later values overriding earlier ones. Keys (including rule names,
377
- aliases, tags, and `default`) are not case-sensitive.
382
+ ```javascript
383
+ {
384
+ "rule_tag_or_default": false
385
+ }
386
+ ```
378
387
 
379
- Example:
388
+ The following syntax enables the specified rule, tag, or `default` to report
389
+ violations as errors:
390
+
391
+ ```javascript
392
+ {
393
+ "rule_tag_or_default": true
394
+ // OR
395
+ "rule_tag_or_default": "error"
396
+ }
397
+ ```
398
+
399
+ The following syntax enables the specified rule, tag, or `default` to report
400
+ violations as warnings:
401
+
402
+ ```javascript
403
+ {
404
+ "rule_tag_or_default": "warning"
405
+ }
406
+ ```
407
+
408
+ The following syntax enables and configures the specified rule to report
409
+ violations as errors:
410
+
411
+ ```javascript
412
+ {
413
+ "rule": {
414
+ "severity": "error"
415
+ }
416
+ // OR
417
+ "rule": {
418
+ "rule_parameter": "value"
419
+ }
420
+ // OR
421
+ "rule": {
422
+ "severity": "error",
423
+ "rule_parameter": "value"
424
+ }
425
+ }
426
+ ```
427
+
428
+ The following syntax enables and configures the specified rule to report
429
+ violations as warnings:
430
+
431
+ ```javascript
432
+ {
433
+ "rule": {
434
+ "severity": "warning"
435
+ }
436
+ // OR
437
+ "rule": {
438
+ "severity": "warning",
439
+ "rule_parameter": "value"
440
+ }
441
+ }
442
+ ```
443
+
444
+ > Note that values `"error"` and `"warning"` and the property `severity` are not
445
+ > supported by library versions earlier than `0.39.0`. However, the examples
446
+ > above behave the same there, with warnings being reported as errors.
447
+
448
+ The following syntax disables and configures the specified rule:
449
+
450
+ ```javascript
451
+ {
452
+ "rule": {
453
+ "enabled": false,
454
+ "rule_parameter": "value"
455
+ }
456
+ // OR
457
+ "rule": {
458
+ "enabled": false,
459
+ "severity": "warning",
460
+ "rule_parameter": "value"
461
+ }
462
+ }
463
+ ```
464
+
465
+ > Note that this example behaves **differently** with library versions earlier
466
+ > than `0.39.0` because the property `enabled` is not supported: it **enables**
467
+ > the rule instead of **disabling** it. As such, this syntax is discouraged when
468
+ > interoperability is important.
469
+
470
+ To evaluate a configuration object, the `default` setting is applied first, then
471
+ keys are processed in order from top to bottom. If multiple values apply to a
472
+ rule (because of tag names or duplication), later values override earlier ones.
473
+ Keys (including rule names, aliases, tags, or `default`) are not case-sensitive.
474
+
475
+ Example using `default`, rule names, and tag names together:
380
476
 
381
477
  ```json
382
478
  {
@@ -619,28 +715,15 @@ By default, properly-formatted inline comments can be used to create exceptions
619
715
  for parts of a document. Setting `noInlineConfig` to `true` ignores all such
620
716
  comments.
621
717
 
622
- ##### options.resultVersion
718
+ ##### ~~options.resultVersion~~
623
719
 
624
- Type: `Number`
720
+ This property is *deprecated* and should be removed. The default format of the
721
+ `result` object remains the same as setting `resultVersion` to `3`. For
722
+ continued access to other (previously *deprecated*) formats:
625
723
 
626
- Specifies which version of the `result` object to return (see the "Usage"
627
- section below for examples).
628
-
629
- Passing a `resultVersion` of `0` corresponds to the original, simple format
630
- where each error is identified by rule name and line number. *Deprecated*
631
-
632
- Passing a `resultVersion` of `1` corresponds to a detailed format where each
633
- error includes information about the line number, rule name, alias, description,
634
- as well as any additional detail or context that is available. *Deprecated*
635
-
636
- Passing a `resultVersion` of `2` corresponds to a detailed format where each
637
- error includes information about the line number, rule names, description, as
638
- well as any additional detail or context that is available. *Deprecated*
639
-
640
- Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
641
- with additional information about how to fix automatically-fixable errors. In
642
- this mode, all errors that occur on each line are reported (other versions
643
- report only the first error for each rule). This is the default behavior.
724
+ ```javascript
725
+ import { convertToResultVersion0, convertToResultVersion1, convertToResultVersion2 } from "markdownlint/helpers";
726
+ ```
644
727
 
645
728
  ##### options.strings
646
729
 
@@ -671,9 +754,9 @@ Standard completion callback.
671
754
 
672
755
  Type: `Object`
673
756
 
674
- Call `result.toString()` for convenience or see below for an example of the
675
- structure of the `result` object. Passing the value `true` to `toString()`
676
- uses rule aliases (ex: `no-hard-tabs`) instead of names (ex: `MD010`).
757
+ Map of input file names and string identifiers to issues within.
758
+
759
+ See the [Usage section](#usage) for an example of the structure of this object.
677
760
 
678
761
  ### Config
679
762
 
@@ -849,7 +932,7 @@ console.log(getVersion());
849
932
 
850
933
  ## Usage
851
934
 
852
- Invoke `lint` and use the `result` object's `toString` method:
935
+ Invoke `lint` as an asynchronous call:
853
936
 
854
937
  ```javascript
855
938
  import { lint as lintAsync } from "markdownlint/async";
@@ -864,34 +947,21 @@ const options = {
864
947
 
865
948
  lintAsync(options, function callback(error, results) {
866
949
  if (!error && results) {
867
- console.log(results.toString());
950
+ console.dir(results, { "colors": true, "depth": null });
868
951
  }
869
952
  });
870
953
  ```
871
954
 
872
- Output:
873
-
874
- ```text
875
- bad.string: 3: MD010/no-hard-tabs Hard tabs [Column: 19]
876
- bad.string: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.string"]
877
- bad.string: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This string fails some rules."]
878
- bad.string: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.string"]
879
- bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
880
- bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
881
- bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
882
- bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
883
- ```
884
-
885
955
  Or as a synchronous call:
886
956
 
887
957
  ```javascript
888
958
  import { lint as lintSync } from "markdownlint/sync";
889
959
 
890
960
  const results = lintSync(options);
891
- console.log(results.toString());
961
+ console.dir(results, { "colors": true, "depth": null });
892
962
  ```
893
963
 
894
- To examine the `result` object directly via a `Promise`-based call:
964
+ Or as a `Promise`-based call:
895
965
 
896
966
  ```javascript
897
967
  import { lint as lintPromise } from "markdownlint/promise";
@@ -900,7 +970,7 @@ const results = await lintPromise(options);
900
970
  console.dir(results, { "colors": true, "depth": null });
901
971
  ```
902
972
 
903
- Output:
973
+ All of which return an object like:
904
974
 
905
975
  ```json
906
976
  {
@@ -909,41 +979,43 @@ Output:
909
979
  { "lineNumber": 3,
910
980
  "ruleNames": [ "MD010", "no-hard-tabs" ],
911
981
  "ruleDescription": "Hard tabs",
912
- "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",
913
983
  "errorDetail": "Column: 17",
914
984
  "errorContext": null,
915
- "errorRange": [ 17, 1 ] },
985
+ "errorRange": [ 17, 1 ],
986
+ "fixInfo": { "editColumn": 17, "deleteCount": 1, "insertText": " " },
987
+ "severity": "error" },
916
988
  { "lineNumber": 1,
917
989
  "ruleNames": [ "MD018", "no-missing-space-atx" ],
918
990
  "ruleDescription": "No space after hash on atx style heading",
919
- "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",
920
992
  "errorDetail": null,
921
993
  "errorContext": "#bad.md",
922
- "errorRange": [ 1, 2 ] },
994
+ "errorRange": [ 1, 2 ],
995
+ "fixInfo": { "editColumn": 2, "insertText": " " },
996
+ "severity": "error" },
923
997
  { "lineNumber": 3,
924
998
  "ruleNames": [ "MD018", "no-missing-space-atx" ],
925
999
  "ruleDescription": "No space after hash on atx style heading",
926
- "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",
927
1001
  "errorDetail": null,
928
1002
  "errorContext": "#This file fails\tsome rules.",
929
- "errorRange": [ 1, 2 ] },
1003
+ "errorRange": [ 1, 2 ],
1004
+ "fixInfo": { "editColumn": 2, "insertText": " " },
1005
+ "severity": "error" },
930
1006
  { "lineNumber": 1,
931
1007
  "ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
932
1008
  "ruleDescription": "First line in a file should be a top-level heading",
933
- "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",
934
1010
  "errorDetail": null,
935
1011
  "errorContext": "#bad.md",
936
- "errorRange": null }
1012
+ "errorRange": null,
1013
+ "fixInfo": null,
1014
+ "severity": "error" }
937
1015
  ]
938
1016
  }
939
1017
  ```
940
1018
 
941
- Integration with the [gulp](https://gulpjs.com/) build system is
942
- straightforward: [`gulpfile.cjs`](example/gulpfile.cjs).
943
-
944
- Integration with the [Grunt](https://gruntjs.com/) build system is similar:
945
- [`Gruntfile.cjs`](example/Gruntfile.cjs).
946
-
947
1019
  ## Browser
948
1020
 
949
1021
  `markdownlint` also works in the browser.
@@ -969,7 +1041,7 @@ const options = {
969
1041
  }
970
1042
  };
971
1043
 
972
- const results = globalThis.markdownlint.lintSync(options).toString();
1044
+ const results = globalThis.markdownlint.lintSync(options);
973
1045
  ```
974
1046
 
975
1047
  ## Examples
@@ -980,7 +1052,6 @@ following projects or one of the tools in the [Related section](#related):
980
1052
  - [.NET Documentation][dot-net-doc] ([Search repository][dot-net-doc-search])
981
1053
  - [ally.js][ally-js] ([Search repository][ally-js-search])
982
1054
  - [Apache Airflow][airflow] ([Search repository][airflow-search])
983
- - [Boostnote][boostnote] ([Search repository][boostnote-search])
984
1055
  - [CodiMD][codimd] ([Search repository][codimd-search])
985
1056
  - [Electron][electron] ([Search repository][electron-search])
986
1057
  - [ESLint][eslint] ([Search repository][eslint-search])
@@ -1004,8 +1075,6 @@ For more advanced integration scenarios:
1004
1075
  [ally-js-search]: https://github.com/medialize/ally.js/search?q=markdownlint
1005
1076
  [airflow]: https://airflow.apache.org
1006
1077
  [airflow-search]: https://github.com/apache/airflow/search?q=markdownlint
1007
- [boostnote]: https://boostnote.io/
1008
- [boostnote-search]: https://github.com/BoostIO/Boostnote/search?q=markdownlint
1009
1078
  [codimd]: https://github.com/hackmdio/codimd
1010
1079
  [codimd-search]: https://github.com/hackmdio/codimd/search?q=markdownlint
1011
1080
  [content-linter]: https://docs.github.com/en/contributing/collaborating-on-github-docs/using-the-content-linter
package/doc/Rules.md CHANGED
@@ -12,6 +12,11 @@ Tags: `headings`
12
12
 
13
13
  Aliases: `heading-increment`
14
14
 
15
+ Parameters:
16
+
17
+ - `front_matter_title`: RegExp for matching title in front matter (`string`,
18
+ default `^\s*title\s*[:=]`)
19
+
15
20
  This rule is triggered when you skip heading levels in a Markdown document, for
16
21
  example:
17
22
 
@@ -40,6 +45,15 @@ level at a time:
40
45
  ### Another Heading 3
41
46
  ```
42
47
 
48
+ If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
49
+ contains a `title` property (commonly used with blog posts), this rule treats
50
+ that as a top level heading and will report a violation if the actual first
51
+ heading is not a level 2 heading. To use a different property name in the
52
+ front matter, specify the text of a regular expression via the
53
+ `front_matter_title` parameter. To disable the use of front matter by this
54
+ rule, specify `""` for `front_matter_title`. When front matter is not present,
55
+ the first heading can be any level.
56
+
43
57
  Rationale: Headings represent the structure of a document and can be confusing
44
58
  when skipped - especially for accessibility scenarios. More information:
45
59
  <https://www.w3.org/WAI/tutorials/page-structure/headings/>.
@@ -281,6 +295,7 @@ Aliases: `no-trailing-spaces`
281
295
  Parameters:
282
296
 
283
297
  - `br_spaces`: Spaces for line break (`integer`, default `2`)
298
+ - `code_blocks`: Include code blocks (`boolean`, default `false`)
284
299
  - `list_item_empty_lines`: Allow spaces for empty lines in list items
285
300
  (`boolean`, default `false`)
286
301
  - `strict`: Include unnecessary breaks (`boolean`, default `false`)
@@ -290,21 +305,19 @@ Fixable: Some violations can be fixed by tooling
290
305
  This rule is triggered on any lines that end with unexpected whitespace. To fix
291
306
  this, remove the trailing space from the end of the line.
292
307
 
293
- Note: Trailing space is allowed in indented and fenced code blocks because some
294
- languages require it.
295
-
296
308
  The `br_spaces` parameter allows an exception to this rule for a specific number
297
309
  of trailing spaces, typically used to insert an explicit line break. The default
298
- value allows 2 spaces to indicate a hard break (\<br> element).
310
+ value allows 2 spaces to indicate a hard break (\<br> element). (You must set
311
+ `br_spaces` to a value >= 2 for this parameter to take effect. Setting
312
+ `br_spaces` to 1 behaves the same as 0, disallowing any trailing spaces.)
299
313
 
300
- Note: You must set `br_spaces` to a value >= 2 for this parameter to take
301
- effect. Setting `br_spaces` to 1 behaves the same as 0, disallowing any trailing
302
- spaces.
314
+ By default, trailing space is allowed in indented and fenced code blocks because
315
+ some programming languages require that. To report such instances, set the
316
+ `code_blocks` parameter to `true`.
303
317
 
304
318
  By default, this rule will not trigger when the allowed number of spaces is
305
319
  used, even when it doesn't create a hard break (for example, at the end of a
306
- paragraph). To report such instances as well, set the `strict` parameter to
307
- `true`.
320
+ paragraph). To report such instances, set the `strict` parameter to `true`.
308
321
 
309
322
  ```markdown
310
323
  Text text text
@@ -383,6 +396,12 @@ parameter to the desired value.
383
396
  Rationale: Hard tabs are often rendered inconsistently by different editors and
384
397
  can be harder to work with than spaces.
385
398
 
399
+ More information:
400
+
401
+ - <https://agiletribe.wordpress.com/2011/10/27/18-dont-use-tab-characters/>
402
+ - <https://www.jwz.org/doc/tabs-vs-spaces.html>
403
+ - <https://adamspiers.org/computing/why_no_tabs.html>
404
+
386
405
  <a name="md011"></a>
387
406
 
388
407
  ## `MD011` - Reversed link syntax
@@ -1026,6 +1045,8 @@ Parameters:
1026
1045
  - `style`: List style (`string`, default `one_or_ordered`, values `one` /
1027
1046
  `one_or_ordered` / `ordered` / `zero`)
1028
1047
 
1048
+ Fixable: Some violations can be fixed by tooling
1049
+
1029
1050
  This rule is triggered for ordered lists that do not either start with '1.' or
1030
1051
  do not have a prefix that increases in numerical order (depending on the
1031
1052
  configured style). The less-common pattern of using '0.' as a first prefix or
@@ -1321,6 +1342,8 @@ Aliases: `no-inline-html`
1321
1342
  Parameters:
1322
1343
 
1323
1344
  - `allowed_elements`: Allowed elements (`string[]`, default `[]`)
1345
+ - `table_allowed_elements`: Allowed elements in tables (`string[]`, default
1346
+ `[]`)
1324
1347
 
1325
1348
  This rule is triggered whenever raw HTML is used in a Markdown document:
1326
1349
 
@@ -1334,7 +1357,11 @@ To fix this, use 'pure' Markdown instead of including raw HTML:
1334
1357
  # Markdown heading
1335
1358
  ```
1336
1359
 
1337
- Note: To allow specific HTML elements, use the `allowed_elements` parameter.
1360
+ To allow specific HTML elements anywhere in Markdown content, set the
1361
+ `allowed_elements` parameter to a list of HTML element names. To allow a
1362
+ specific set of HTML elements within Markdown tables, set the
1363
+ `table_allowed_elements` parameter to a list of HTML element names. This can be
1364
+ used to permit the use of `<br>`-style line breaks only within Markdown tables.
1338
1365
 
1339
1366
  Rationale: Raw HTML is allowed in Markdown, but this rule is included for
1340
1367
  those who want their documents to only include "pure" Markdown, or for those
@@ -2257,14 +2284,19 @@ This makes it easy to link directly to different sections within a document.
2257
2284
  However, section links change if headings are renamed or removed. This rule
2258
2285
  helps identify broken section links within a document.
2259
2286
 
2260
- Section links are **not** part of the CommonMark specification. This rule
2261
- enforces the [GitHub heading algorithm][github-heading-algorithm] which is:
2262
- convert heading to lowercase, remove punctuation, convert spaces to dashes,
2263
- 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]:
2264
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
2265
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
2266
2298
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
2267
- [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
2268
2300
  [html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
2269
2301
  [RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
2270
2302
 
@@ -2523,7 +2555,7 @@ Rationale: Some parsers have difficulty with tables that are missing their
2523
2555
  leading or trailing pipe characters. The use of leading/trailing pipes can also
2524
2556
  help provide visual clarity.
2525
2557
 
2526
- [gfm-table-055]: https://github.github.com/gfm/#tables-extension-
2558
+ [gfm-table-055]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
2527
2559
 
2528
2560
  <a name="md056"></a>
2529
2561
 
@@ -2563,7 +2595,7 @@ of cells or it will not be recognized as a table (per specification).
2563
2595
  Rationale: Extra cells in a row are usually not shown, so their data is lost.
2564
2596
  Missing cells in a row create holes in the table and suggest an omission.
2565
2597
 
2566
- [gfm-table-056]: https://github.github.com/gfm/#tables-extension-
2598
+ [gfm-table-056]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
2567
2599
 
2568
2600
  <a name="md058"></a>
2569
2601
 
@@ -2647,7 +2679,131 @@ translations for every language.
2647
2679
 
2648
2680
  Note: This rule checks Markdown links; HTML links are ignored.
2649
2681
 
2650
- More information: <https://webaim.org/techniques/hypertext/>
2682
+ More information:
2683
+
2684
+ - <https://webaim.org/techniques/hypertext/>
2685
+ - <https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-link-only.html>
2686
+
2687
+ <a name="md060"></a>
2688
+
2689
+ ## `MD060` - Table column style
2690
+
2691
+ Tags: `table`
2692
+
2693
+ Aliases: `table-column-style`
2694
+
2695
+ Parameters:
2696
+
2697
+ - `aligned_delimiter`: Aligned delimiter columns (`boolean`, default `false`)
2698
+ - `style`: Table column style (`string`, default `any`, values `aligned` /
2699
+ `any` / `compact` / `tight`)
2700
+
2701
+ This rule is triggered when the column separator pipe characters (`|`) of a
2702
+ [GitHub Flavored Markdown table][gfm-table-060] are used inconsistently.
2703
+
2704
+ This rule recognizes three table column styles based on popular use.
2705
+
2706
+ Style `aligned` ensures pipe characters are vertically aligned:
2707
+
2708
+ ```markdown
2709
+ | Character | Meaning |
2710
+ | --------- | ------- |
2711
+ | Y | Yes |
2712
+ | N | No |
2713
+ ```
2714
+
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:
2725
+
2726
+ ```markdown
2727
+ | Character | Meaning |
2728
+ | --- | --- |
2729
+ | Y | Yes |
2730
+ | N | No |
2731
+ ```
2732
+
2733
+ Style `tight` uses no padding at all for cell content:
2734
+
2735
+ ```markdown
2736
+ |Character|Meaning|
2737
+ |---|---|
2738
+ |Y|Yes|
2739
+ |N|No|
2740
+ ```
2741
+
2742
+ When this rule's `style` parameter is set to `aligned`, `compact`, or `tight`,
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
+ ```
2781
+
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:
2788
+
2789
+ <!-- markdownlint-capture -->
2790
+ <!-- markdownlint-disable extended-ascii -->
2791
+
2792
+ ```markdown
2793
+ | Response | Emoji |
2794
+ | -------- | ----- |
2795
+ | Yes | ✅ |
2796
+ | No | ❎ |
2797
+ ```
2798
+
2799
+ <!-- markdownlint-restore -->
2800
+
2801
+ Rationale: Consistent formatting makes it easier to understand a document.
2802
+
2803
+ [cjk-characters]: https://en.wikipedia.org/wiki/CJK_characters
2804
+ [emoji]: https://en.wikipedia.org/wiki/Emoji
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
2651
2807
 
2652
2808
  <!-- markdownlint-configure-file {
2653
2809
  "no-inline-html": {