markdownlint 0.41.0 → 0.42.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 +24 -0
- package/CONTRIBUTING.md +62 -77
- package/README.md +7 -7
- package/doc/CustomRules.md +6 -4
- package/doc/Rules.md +87 -36
- package/doc/md010.md +0 -1
- package/doc/md024.md +1 -1
- package/doc/md029.md +11 -1
- package/doc/md043.md +47 -9
- package/doc/md051.md +19 -19
- package/doc/md055.md +6 -3
- package/doc/md060.md +3 -2
- package/helpers/README.md +2 -2
- package/helpers/helpers.cjs +23 -7
- package/helpers/micromark-helpers.cjs +8 -12
- package/helpers/package.json +1 -5
- package/helpers/shared.cjs +1 -1
- package/lib/cache.mjs +1 -0
- package/lib/configuration-strict.d.ts +124 -112
- package/lib/constants.mjs +1 -1
- package/lib/defer-require.cjs +1 -0
- package/lib/exports.d.mts +29 -1
- package/lib/markdownit.cjs +8 -1
- package/lib/markdownlint.d.mts +337 -195
- package/lib/markdownlint.mjs +83 -87
- package/lib/md004.mjs +1 -0
- package/lib/md005.mjs +1 -1
- package/lib/md007.mjs +2 -2
- package/lib/md009.mjs +2 -3
- package/lib/md010.mjs +1 -1
- package/lib/md011.mjs +10 -7
- package/lib/md012.mjs +1 -1
- package/lib/md013.mjs +13 -9
- package/lib/md018.mjs +1 -1
- package/lib/md019-md021.mjs +1 -0
- package/lib/md020.mjs +1 -1
- package/lib/md022.mjs +6 -6
- package/lib/md024.mjs +1 -1
- package/lib/md025.mjs +1 -1
- package/lib/md027.mjs +1 -1
- package/lib/md028.mjs +1 -2
- package/lib/md029.mjs +34 -23
- package/lib/md030.mjs +4 -4
- package/lib/md031.mjs +1 -1
- package/lib/md032.mjs +5 -4
- package/lib/md033.mjs +1 -1
- package/lib/md034.mjs +1 -1
- package/lib/md037.mjs +1 -2
- package/lib/md039.mjs +5 -1
- package/lib/md041.mjs +1 -1
- package/lib/md043.mjs +98 -44
- package/lib/md044.mjs +2 -2
- package/lib/md048.mjs +1 -3
- package/lib/md051.mjs +3 -3
- package/lib/md055.mjs +11 -1
- package/lib/md056.mjs +1 -1
- package/lib/md058.mjs +1 -1
- package/lib/md060.mjs +24 -4
- package/lib/micromark-parse.mjs +3 -2
- package/lib/resolve-module.cjs +3 -2
- package/lib/resolve-module.d.cts +15 -10
- package/package.json +33 -34
- package/schema/.markdownlint.jsonc +54 -54
- package/schema/.markdownlint.yaml +76 -76
- package/schema/markdownlint-config-schema-strict.json +126 -118
- package/schema/markdownlint-config-schema.json +126 -118
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.42.0
|
|
4
|
+
|
|
5
|
+
- Improve MD011/MD018/MD020/MD043/MD051/MD055/MD060
|
|
6
|
+
- Add regular expression denial of service protection
|
|
7
|
+
- Add support for reporting issues with front matter
|
|
8
|
+
- Update dependencies
|
|
9
|
+
|
|
10
|
+
## 0.41.1
|
|
11
|
+
|
|
12
|
+
- Improve MD029
|
|
13
|
+
- Fix module resolution under webpack
|
|
14
|
+
- Update dependencies
|
|
15
|
+
|
|
3
16
|
## 0.41.0
|
|
4
17
|
|
|
5
18
|
- Improve MD022/MD028/MD035/MD042/MD051/MD060
|
|
@@ -527,3 +540,14 @@
|
|
|
527
540
|
|
|
528
541
|
- Initial release
|
|
529
542
|
- Includes tests MD001-MD032
|
|
543
|
+
|
|
544
|
+
<!-- markdownlint-configure-file {
|
|
545
|
+
"required-headings": {
|
|
546
|
+
"headings": [
|
|
547
|
+
"# Changelog",
|
|
548
|
+
"^",
|
|
549
|
+
"%% ^\\d+\\.\\d+\\.\\d+$",
|
|
550
|
+
"^"
|
|
551
|
+
]
|
|
552
|
+
}
|
|
553
|
+
} -->
|
package/CONTRIBUTING.md
CHANGED
|
@@ -3,90 +3,75 @@
|
|
|
3
3
|
Interested in contributing? Great! Here are some suggestions to make it a good
|
|
4
4
|
experience:
|
|
5
5
|
|
|
6
|
-
Start by [opening an issue]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
time and effort writing code that may not get used.
|
|
6
|
+
Start by [opening an issue][issues], whether to identify a problem or outline a
|
|
7
|
+
change. That issue should be used to discuss the situation and agree on a plan
|
|
8
|
+
of action before writing code or sending a pull request. Maybe the problem isn't
|
|
9
|
+
really a problem, or maybe there are more things to consider. If so, it's best
|
|
10
|
+
to realize that before spending time and effort writing code that gets rejected.
|
|
12
11
|
|
|
13
12
|
Match the coding style of the files you edit. Although everyone has their own
|
|
14
13
|
preferences and opinions, a pull request is not the right forum to debate them.
|
|
15
14
|
|
|
16
|
-
Do not add new [`dependencies` to `package.json`][
|
|
17
|
-
parser [`micromark`][micromark] (and its extensions) is this project's only
|
|
18
|
-
dependency.
|
|
15
|
+
Do not add new [`dependencies` to `package.json`][deps].
|
|
19
16
|
|
|
20
17
|
Package versions for `dependencies` and `devDependencies` should be specified
|
|
21
|
-
exactly (also known as "pinning").
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for that scenario. Tests run by `markdownlint-test-scenarios.js` use [AVA's
|
|
44
|
-
snapshot feature][ava-snapshots]. To update snapshots (for example, after
|
|
45
|
-
modifying a test file), run `npm run update-snapshots` and include the updated
|
|
46
|
-
files with the pull request.
|
|
47
|
-
|
|
48
|
-
Lint before sending a pull request by running `npm run lint`. There should be no
|
|
49
|
-
issues.
|
|
50
|
-
|
|
51
|
-
Run a full continuous integration pass before sending a pull request via `npm
|
|
52
|
-
run ci`. Code coverage should always be 100%. As part of a continuous
|
|
53
|
-
integration run, generated files may get updated and fail the run - commit them
|
|
54
|
-
to the repository and rerun continuous integration.
|
|
55
|
-
|
|
56
|
-
Pull requests should contain a single commit. If necessary, squash multiple
|
|
57
|
-
commits before creating the pull request and when making changes. (See [Git
|
|
58
|
-
Tools - Rewriting History][rewriting-history] for details.)
|
|
59
|
-
|
|
60
|
-
Open pull requests against the `next` branch. That's where the latest changes
|
|
61
|
-
are staged for the next release. Include the text "(fixes #??)" at the end of
|
|
18
|
+
exactly (also known as "pinning"). Doing otherwise causes inconsistent behavior
|
|
19
|
+
and broken functionality. (See [Why I pin dependency versions in Node.js
|
|
20
|
+
packages][pinning] for a longer explanation.)
|
|
21
|
+
|
|
22
|
+
Add tests for all new/changed functionality. Test both positive and negative
|
|
23
|
+
scenarios. Try to break the new code now, or it will get broken later. This
|
|
24
|
+
project maintains 100% code coverage.
|
|
25
|
+
|
|
26
|
+
Run tests before sending a pull request via `npm test`. Tests need to pass on
|
|
27
|
+
all platforms. Test cases are implemented in `test/*.mjs`. As part of testing,
|
|
28
|
+
`test/*.md` files are enumerated, linted, and fail if any violations are missing
|
|
29
|
+
a corresponding `{MD###}` marker in the test file. For cases where a marker can
|
|
30
|
+
not be present on the corresponding line, the syntax `{MD###:#}`can be used. To
|
|
31
|
+
update test snapshots (for example, after modifying a test file), use `npm run
|
|
32
|
+
update-snapshots` and include the updated snapshot files with the pull request.
|
|
33
|
+
|
|
34
|
+
Run a full continuous integration pass before opening a pull request via `npm
|
|
35
|
+
run ci`. As part of the continuous integration run, generated files may get
|
|
36
|
+
updated and fail the run - commit those changes and rerun.
|
|
37
|
+
|
|
38
|
+
Pull requests should contain a single commit with a commit message that is a
|
|
39
|
+
brief sentence with punctuation. Include the text "(fixes #??)" at the end of
|
|
62
40
|
the commit message so the pull request will be associated with the relevant
|
|
63
|
-
issue.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
41
|
+
issue. Squash multiple commits before creating the pull request or when making
|
|
42
|
+
updates. (See [Git Tools - Rewriting History][rewriting] for details.)
|
|
43
|
+
|
|
44
|
+
Create all pull requests for the `next` branch which contains the latest changes
|
|
45
|
+
ready for release. Once accepted, the tag `fixed in next` will be added to the
|
|
46
|
+
issue. When that commit is merged to the `main` branch during the release
|
|
47
|
+
process, the issue will be closed automatically.
|
|
48
|
+
|
|
49
|
+
Refrain from using slang or meaningless placeholder text in code, documentation,
|
|
50
|
+
or tests. Sample content can be "text", "code", "heading", etc.. URLs should use
|
|
51
|
+
[example.com][example]. Profanity is not allowed.
|
|
52
|
+
|
|
53
|
+
When considering a new rule, start by creating a [custom rule][custom] in a
|
|
54
|
+
dedicated repository. Once it has been written, published, and tested in real-
|
|
55
|
+
world scenarios, open an issue to discuss adding it to this project. For rule
|
|
56
|
+
ideas, see [issues tagged with the `new rule` label][new]. Not all rules make
|
|
57
|
+
sense to include.
|
|
58
|
+
|
|
59
|
+
In order to maintain the permissive [MIT license][mit] this project has, all
|
|
60
|
+
contributions must be your own and released under the MIT license. Code you add
|
|
61
|
+
should be an original work and should not be copied from elsewhere. Reusing code
|
|
62
|
+
from a different project, Stack Overflow, etc. is not allowed. The use of tools
|
|
63
|
+
such as Copilot, ChatGPT, Claude, etc. that produce output from a [large
|
|
64
|
+
language model (LLM)][llm] is not allowed because LLMs reuse code from other
|
|
65
|
+
projects.
|
|
79
66
|
|
|
80
67
|
Thank you!
|
|
81
68
|
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[rewriting-history]: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
|
|
92
|
-
[version-pinning]: https://dlaa.me/blog/post/versionpinning
|
|
69
|
+
[custom]: doc/CustomRules.md
|
|
70
|
+
[deps]: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#dependencies
|
|
71
|
+
[example]: https://wikipedia.org/wiki/Example.com
|
|
72
|
+
[issues]: https://github.com/DavidAnson/markdownlint/issues
|
|
73
|
+
[llm]: https://wikipedia.org/wiki/Large_language_model
|
|
74
|
+
[mit]: https://choosealicense.com/licenses/mit/
|
|
75
|
+
[new]: https://github.com/DavidAnson/markdownlint/labels/new%20rule
|
|
76
|
+
[rewriting]: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
|
|
77
|
+
[pinning]: https://dlaa.me/blog/post/versionpinning
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# markdownlint
|
|
2
2
|
|
|
3
|
-
> A Node.js style checker and lint tool for Markdown/CommonMark files
|
|
3
|
+
> A Node.js style checker and lint tool for Markdown/CommonMark files
|
|
4
4
|
|
|
5
5
|
[![npm version][npm-image]][npm-url]
|
|
6
6
|
[![License][license-image]][license-url]
|
|
@@ -574,7 +574,7 @@ ones.
|
|
|
574
574
|
For example:
|
|
575
575
|
|
|
576
576
|
```javascript
|
|
577
|
-
[ JSON.parse, require("toml").parse, require("js-yaml").load ]
|
|
577
|
+
[ JSON.parse, require("smol-toml").parse, require("js-yaml").load ]
|
|
578
578
|
```
|
|
579
579
|
|
|
580
580
|
##### options.customRules
|
|
@@ -830,7 +830,7 @@ parsers should come before flexible parsers.
|
|
|
830
830
|
For example:
|
|
831
831
|
|
|
832
832
|
```javascript
|
|
833
|
-
[ JSON.parse, require("toml").parse, require("js-yaml").load ]
|
|
833
|
+
[ JSON.parse, require("smol-toml").parse, require("js-yaml").load ]
|
|
834
834
|
```
|
|
835
835
|
|
|
836
836
|
#### fs
|
|
@@ -970,7 +970,7 @@ All of which return an object like:
|
|
|
970
970
|
{ "lineNumber": 3,
|
|
971
971
|
"ruleNames": [ "MD010", "no-hard-tabs" ],
|
|
972
972
|
"ruleDescription": "Hard tabs",
|
|
973
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
973
|
+
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/md010.md",
|
|
974
974
|
"errorDetail": "Column: 17",
|
|
975
975
|
"errorContext": null,
|
|
976
976
|
"errorRange": [ 17, 1 ],
|
|
@@ -979,7 +979,7 @@ All of which return an object like:
|
|
|
979
979
|
{ "lineNumber": 1,
|
|
980
980
|
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
|
981
981
|
"ruleDescription": "No space after hash on atx style heading",
|
|
982
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
982
|
+
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/md018.md",
|
|
983
983
|
"errorDetail": null,
|
|
984
984
|
"errorContext": "#bad.md",
|
|
985
985
|
"errorRange": [ 1, 2 ],
|
|
@@ -988,7 +988,7 @@ All of which return an object like:
|
|
|
988
988
|
{ "lineNumber": 3,
|
|
989
989
|
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
|
990
990
|
"ruleDescription": "No space after hash on atx style heading",
|
|
991
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
991
|
+
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/md018.md",
|
|
992
992
|
"errorDetail": null,
|
|
993
993
|
"errorContext": "#This file fails\tsome rules.",
|
|
994
994
|
"errorRange": [ 1, 2 ],
|
|
@@ -997,7 +997,7 @@ All of which return an object like:
|
|
|
997
997
|
{ "lineNumber": 1,
|
|
998
998
|
"ruleNames": [ "MD041", "first-line-heading", "first-line-h1" ],
|
|
999
999
|
"ruleDescription": "First line in a file should be a top-level heading",
|
|
1000
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
1000
|
+
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.42.0/doc/md041.md",
|
|
1001
1001
|
"errorDetail": null,
|
|
1002
1002
|
"errorContext": "#bad.md",
|
|
1003
1003
|
"errorRange": null,
|
package/doc/CustomRules.md
CHANGED
|
@@ -117,12 +117,14 @@ A rule is implemented as an `Object`:
|
|
|
117
117
|
- `lines` is an `Array` of `String` values corresponding to the lines of the
|
|
118
118
|
input file/string.
|
|
119
119
|
- `frontMatterLines` is an `Array` of `String` values corresponding to any
|
|
120
|
-
front matter (not present in `lines`).
|
|
120
|
+
lines of front matter (not present in the `lines` `Array`).
|
|
121
121
|
- `config` is an `Object` corresponding to the rule's entry in
|
|
122
122
|
`options.config` (if present).
|
|
123
123
|
- `version` is a `String` that corresponds to the version of `markdownlint`
|
|
124
124
|
- `onError` is a function that takes a single `Object` parameter with one
|
|
125
|
-
required and
|
|
125
|
+
required and various optional properties:
|
|
126
|
+
- `frontMatter` is an optional `Boolean` value specifying whether the error
|
|
127
|
+
refers to `frontMatterLines` (instead of `lines` which is the default)
|
|
126
128
|
- `lineNumber` is a required `Number` specifying the 1-based line number of
|
|
127
129
|
the error.
|
|
128
130
|
- `detail` is an optional `String` with information about what caused the
|
|
@@ -147,8 +149,8 @@ A rule is implemented as an `Object`:
|
|
|
147
149
|
is the platform-independent way to add a line break; line breaks should
|
|
148
150
|
be added at the beginning of a line instead of at the end.
|
|
149
151
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
A collection of helper functions (formerly) used by built-in rules is available
|
|
153
|
+
for custom rules in the [markdownlint-rule-helpers package][rule-helpers].
|
|
152
154
|
|
|
153
155
|
### Asynchronous Rules
|
|
154
156
|
|
package/doc/Rules.md
CHANGED
|
@@ -400,7 +400,6 @@ More information:
|
|
|
400
400
|
|
|
401
401
|
- <https://agiletribe.wordpress.com/2011/10/27/18-dont-use-tab-characters/>
|
|
402
402
|
- <https://www.jwz.org/doc/tabs-vs-spaces.html>
|
|
403
|
-
- <https://adamspiers.org/computing/why_no_tabs.html>
|
|
404
403
|
|
|
405
404
|
<a name="md011"></a>
|
|
406
405
|
|
|
@@ -860,7 +859,7 @@ If the parameter `siblings_only` is set to `true`, duplication is allowed for
|
|
|
860
859
|
headings with different parents (as is common in changelogs):
|
|
861
860
|
|
|
862
861
|
```markdown
|
|
863
|
-
#
|
|
862
|
+
# Changelog
|
|
864
863
|
|
|
865
864
|
## 1.0.0
|
|
866
865
|
|
|
@@ -1110,7 +1109,8 @@ Example invalid list for all styles:
|
|
|
1110
1109
|
3. Done.
|
|
1111
1110
|
```
|
|
1112
1111
|
|
|
1113
|
-
This rule supports 0-prefixing
|
|
1112
|
+
This rule supports 0-prefixing list items for uniform indentation and will
|
|
1113
|
+
preserve that when fixing:
|
|
1114
1114
|
|
|
1115
1115
|
```markdown
|
|
1116
1116
|
...
|
|
@@ -1118,7 +1118,16 @@ This rule supports 0-prefixing ordered list items for uniform indentation:
|
|
|
1118
1118
|
09. Item
|
|
1119
1119
|
10. Item
|
|
1120
1120
|
11. Item
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
When list items appear to be right-aligned, fixes will maintain that alignment:
|
|
1124
|
+
|
|
1125
|
+
```markdown
|
|
1121
1126
|
...
|
|
1127
|
+
8. Item
|
|
1128
|
+
9. Item
|
|
1129
|
+
10. Item
|
|
1130
|
+
11. Item
|
|
1122
1131
|
```
|
|
1123
1132
|
|
|
1124
1133
|
Note: This rule will report violations for cases like the following where an
|
|
@@ -1831,7 +1840,7 @@ Aliases: `required-headings`
|
|
|
1831
1840
|
|
|
1832
1841
|
Parameters:
|
|
1833
1842
|
|
|
1834
|
-
- `headings`: List of headings (`string[]`, default `
|
|
1843
|
+
- `headings`: List of headings (`string[]|null`, default `null`)
|
|
1835
1844
|
- `match_case`: Match case of headings (`boolean`, default `false`)
|
|
1836
1845
|
|
|
1837
1846
|
This rule is triggered when the headings in a file do not match the array of
|
|
@@ -1862,13 +1871,15 @@ To allow optional headings as with the following structure:
|
|
|
1862
1871
|
# Heading
|
|
1863
1872
|
## Item
|
|
1864
1873
|
### Detail (optional)
|
|
1874
|
+
### Example (optional)
|
|
1865
1875
|
## Foot
|
|
1866
1876
|
### Notes (optional)
|
|
1867
1877
|
```
|
|
1868
1878
|
|
|
1869
|
-
Use the special value
|
|
1870
|
-
special value
|
|
1871
|
-
`headings`
|
|
1879
|
+
Use the special value `*` meaning "zero or more unspecified headings", the
|
|
1880
|
+
special value `+` meaning "one or more unspecified headings", or the special
|
|
1881
|
+
value `?` meaning "exactly one unspecified heading" and set the `headings`
|
|
1882
|
+
parameter to something like:
|
|
1872
1883
|
|
|
1873
1884
|
```json
|
|
1874
1885
|
[
|
|
@@ -1876,28 +1887,64 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|
|
1876
1887
|
"## Item",
|
|
1877
1888
|
"*",
|
|
1878
1889
|
"## Foot",
|
|
1879
|
-
"
|
|
1890
|
+
"+"
|
|
1880
1891
|
]
|
|
1881
1892
|
```
|
|
1882
1893
|
|
|
1883
|
-
To
|
|
1894
|
+
To require a heading with a specific level and text matching a specific pattern
|
|
1895
|
+
(for example, a one-word project name):
|
|
1884
1896
|
|
|
1885
1897
|
```markdown
|
|
1886
|
-
# Project
|
|
1898
|
+
# Project
|
|
1887
1899
|
## Description
|
|
1888
1900
|
## Examples
|
|
1889
1901
|
```
|
|
1890
1902
|
|
|
1891
|
-
|
|
1903
|
+
Replace the `#` prefix character(s) with `%` and specify a regular expression;
|
|
1904
|
+
the following example requires a level 1 heading with a single word made up of
|
|
1905
|
+
at least 4 letters:
|
|
1892
1906
|
|
|
1893
1907
|
```json
|
|
1894
1908
|
[
|
|
1895
|
-
"
|
|
1909
|
+
"% [a-zA-Z]{4,}",
|
|
1896
1910
|
"## Description",
|
|
1897
1911
|
"## Examples"
|
|
1898
1912
|
]
|
|
1899
1913
|
```
|
|
1900
1914
|
|
|
1915
|
+
To handle repeating heading sections (common in `CHANGELOG` files) such as the
|
|
1916
|
+
following:
|
|
1917
|
+
|
|
1918
|
+
```markdown
|
|
1919
|
+
# Changelog
|
|
1920
|
+
## 1.0.0
|
|
1921
|
+
### Fixes
|
|
1922
|
+
### Features
|
|
1923
|
+
## 2.0.0
|
|
1924
|
+
### Fixes
|
|
1925
|
+
### Features
|
|
1926
|
+
```
|
|
1927
|
+
|
|
1928
|
+
Use the special value `^` meaning "if the next heading does not match, loop
|
|
1929
|
+
back to the previous matching marker":
|
|
1930
|
+
|
|
1931
|
+
```json
|
|
1932
|
+
[
|
|
1933
|
+
"# Changelog",
|
|
1934
|
+
"^",
|
|
1935
|
+
"%% ^\\d+\\.\\d+\\.\\d+$",
|
|
1936
|
+
"### Fixes",
|
|
1937
|
+
"### Features",
|
|
1938
|
+
"^"
|
|
1939
|
+
]
|
|
1940
|
+
```
|
|
1941
|
+
|
|
1942
|
+
The simple form shown above is enough for most scenarios; if multiple loops are
|
|
1943
|
+
needed, matching pairs of `^^`, `^^^`, etc. can be used in conjunction. The
|
|
1944
|
+
prefix `%` and the special value `?` are supported with loops, but `*` and `+`
|
|
1945
|
+
are not and will result in undefined behavior. To avoid infinite looping, a
|
|
1946
|
+
violation is reported if the rule loops more than 1,000 times.
|
|
1947
|
+
|
|
1901
1948
|
When an error is detected, this rule outputs the line number of the first
|
|
1902
1949
|
problematic heading (otherwise, it outputs the last line number of the file).
|
|
1903
1950
|
|
|
@@ -2229,7 +2276,7 @@ Parameters:
|
|
|
2229
2276
|
Fixable: Some violations can be fixed by tooling
|
|
2230
2277
|
|
|
2231
2278
|
This rule is triggered when a link fragment does not match any of the fragments
|
|
2232
|
-
that are automatically generated for headings in
|
|
2279
|
+
that are automatically generated by GitHub for headings in the document:
|
|
2233
2280
|
|
|
2234
2281
|
```markdown
|
|
2235
2282
|
# Heading Name
|
|
@@ -2247,8 +2294,9 @@ generated name (see below):
|
|
|
2247
2294
|
```
|
|
2248
2295
|
|
|
2249
2296
|
For consistency, this rule requires fragments to exactly match the [GitHub
|
|
2250
|
-
|
|
2251
|
-
lowercase. Therefore, the following
|
|
2297
|
+
algorithm for section links][github-section-links] which (among other things)
|
|
2298
|
+
converts letters to lowercase. Therefore, the following is reported as a
|
|
2299
|
+
violation:
|
|
2252
2300
|
|
|
2253
2301
|
```markdown
|
|
2254
2302
|
# Heading Name
|
|
@@ -2260,9 +2308,9 @@ To ignore case when comparing fragments with heading names, the `ignore_case`
|
|
|
2260
2308
|
parameter can be set to `true`. In this configuration, the previous example is
|
|
2261
2309
|
not reported as a violation.
|
|
2262
2310
|
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2311
|
+
Some platforms allow the syntax `{#named-anchor}` to be used within a heading to
|
|
2312
|
+
provide a specific name (consisting of only lower-case letters, numbers, `-`,
|
|
2313
|
+
and `_`); that is allowed by this rule:
|
|
2266
2314
|
|
|
2267
2315
|
```markdown
|
|
2268
2316
|
# Heading Name {#custom-name}
|
|
@@ -2279,8 +2327,8 @@ attribute can be used to define a fragment:
|
|
|
2279
2327
|
[Link](#bookmark)
|
|
2280
2328
|
```
|
|
2281
2329
|
|
|
2282
|
-
|
|
2283
|
-
control over the text of the fragment identifier.
|
|
2330
|
+
Using an `a` tag can be useful in scenarios where a heading is not appropriate
|
|
2331
|
+
or for control over the text of the fragment identifier.
|
|
2284
2332
|
|
|
2285
2333
|
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
|
|
2286
2334
|
rule allows that syntax (using lower-case for consistency):
|
|
@@ -2289,16 +2337,15 @@ rule allows that syntax (using lower-case for consistency):
|
|
|
2289
2337
|
[Link](#top)
|
|
2290
2338
|
```
|
|
2291
2339
|
|
|
2292
|
-
This rule
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
For example, this link to line 20:
|
|
2340
|
+
This rule supports the fragment syntax used by GitHub to highlight [specific
|
|
2341
|
+
lines/sections of a document][github-linking-to-content]. For example, this link
|
|
2342
|
+
to line 20:
|
|
2296
2343
|
|
|
2297
2344
|
```markdown
|
|
2298
2345
|
[Link](#L20)
|
|
2299
2346
|
```
|
|
2300
2347
|
|
|
2301
|
-
And this link to content starting within line 19 running
|
|
2348
|
+
And this link to content starting within line 19 running partly through line 21:
|
|
2302
2349
|
|
|
2303
2350
|
```markdown
|
|
2304
2351
|
[Link](#L19C5-L21C11)
|
|
@@ -2307,8 +2354,8 @@ And this link to content starting within line 19 running into line 21:
|
|
|
2307
2354
|
Some Markdown generators dynamically create and insert headings when building
|
|
2308
2355
|
documents, for example by combining a fixed prefix like `figure-` and an
|
|
2309
2356
|
incrementing numeric counter. To ignore such generated fragments, set the
|
|
2310
|
-
`ignored_pattern` [regular expression][RegEx] parameter to a pattern
|
|
2311
|
-
|
|
2357
|
+
`ignored_pattern` [regular expression][RegEx] parameter to a suitable pattern
|
|
2358
|
+
(e.g., `^figure-`).
|
|
2312
2359
|
|
|
2313
2360
|
Rationale: [GitHub section links][github-section-links] are created
|
|
2314
2361
|
automatically for every heading when Markdown content is displayed on GitHub.
|
|
@@ -2317,17 +2364,17 @@ However, section links change if headings are renamed or removed. This rule
|
|
|
2317
2364
|
helps identify broken section links within a document.
|
|
2318
2365
|
|
|
2319
2366
|
Note: Section links are **not** part of the CommonMark specification; this rule
|
|
2320
|
-
enforces the
|
|
2367
|
+
enforces the GitHub algorithm. Basically:
|
|
2321
2368
|
|
|
2322
2369
|
1. Convert text to lowercase
|
|
2323
2370
|
2. Remove punctuation characters
|
|
2324
2371
|
3. Convert spaces to dashes
|
|
2325
|
-
4.
|
|
2326
|
-
5.
|
|
2372
|
+
4. Remove HTML comments
|
|
2373
|
+
5. Append dash+incrementing integer if needed for uniqueness
|
|
2374
|
+
6. [URI-encode][encodeURIComponent] the result
|
|
2327
2375
|
|
|
2328
2376
|
[encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
|
|
2329
2377
|
[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
|
|
2330
|
-
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
|
2331
2378
|
[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
|
|
2332
2379
|
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
|
2333
2380
|
[RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
|
@@ -2543,15 +2590,18 @@ Parameters:
|
|
|
2543
2590
|
|
|
2544
2591
|
- `style`: Table pipe style (`string`, default `consistent`, values
|
|
2545
2592
|
`consistent` / `leading_and_trailing` / `leading_only` /
|
|
2546
|
-
`no_leading_or_trailing` / `trailing_only`)
|
|
2593
|
+
`no_leading_or_trailing` / `per_table` / `trailing_only`)
|
|
2547
2594
|
|
|
2548
2595
|
This rule is triggered when a [GitHub Flavored Markdown table][gfm-table-055]
|
|
2549
|
-
is inconsistent
|
|
2596
|
+
is inconsistent with its use of leading and trailing pipe characters (`|`).
|
|
2550
2597
|
|
|
2551
2598
|
By default (`consistent` style), the header row of the first table in a document
|
|
2552
2599
|
is used to determine the style that is enforced for every table in the document.
|
|
2553
2600
|
A specific style can be used instead (`leading_and_trailing`, `leading_only`,
|
|
2554
|
-
`no_leading_or_trailing`, `trailing_only`)
|
|
2601
|
+
`no_leading_or_trailing`, `trailing_only`) to require all tables in a document
|
|
2602
|
+
have the same approach. The style `per_table` can be used to require the rows of
|
|
2603
|
+
each table use the same approach (based on its header row) while allowing tables
|
|
2604
|
+
in a document to differ from each other.
|
|
2555
2605
|
|
|
2556
2606
|
This table's header row has leading and trailing pipes, but its delimiter row is
|
|
2557
2607
|
missing the trailing pipe and its first row of cells is missing the leading
|
|
@@ -2755,7 +2805,8 @@ The `aligned` style ignores cell content, so the following is also valid:
|
|
|
2755
2805
|
| N | No |
|
|
2756
2806
|
```
|
|
2757
2807
|
|
|
2758
|
-
Style `compact` avoids extra padding with a single space
|
|
2808
|
+
Style `compact` avoids extra padding with a single space before and after cell
|
|
2809
|
+
content (or just a single space for cells without content):
|
|
2759
2810
|
|
|
2760
2811
|
```markdown
|
|
2761
2812
|
| Character | Meaning |
|
|
@@ -2764,7 +2815,7 @@ Style `compact` avoids extra padding with a single space around cell content:
|
|
|
2764
2815
|
| N | No |
|
|
2765
2816
|
```
|
|
2766
2817
|
|
|
2767
|
-
Style `tight` uses no padding at all for
|
|
2818
|
+
Style `tight` uses no padding at all (for cells with or without content):
|
|
2768
2819
|
|
|
2769
2820
|
```markdown
|
|
2770
2821
|
|Character|Meaning|
|
package/doc/md010.md
CHANGED
package/doc/md024.md
CHANGED
package/doc/md029.md
CHANGED
|
@@ -55,7 +55,8 @@ Example invalid list for all styles:
|
|
|
55
55
|
3. Done.
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
This rule supports 0-prefixing
|
|
58
|
+
This rule supports 0-prefixing list items for uniform indentation and will
|
|
59
|
+
preserve that when fixing:
|
|
59
60
|
|
|
60
61
|
```markdown
|
|
61
62
|
...
|
|
@@ -63,7 +64,16 @@ This rule supports 0-prefixing ordered list items for uniform indentation:
|
|
|
63
64
|
09. Item
|
|
64
65
|
10. Item
|
|
65
66
|
11. Item
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
When list items appear to be right-aligned, fixes will maintain that alignment:
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
66
72
|
...
|
|
73
|
+
8. Item
|
|
74
|
+
9. Item
|
|
75
|
+
10. Item
|
|
76
|
+
11. Item
|
|
67
77
|
```
|
|
68
78
|
|
|
69
79
|
Note: This rule will report violations for cases like the following where an
|