markdownlint 0.39.0 → 0.41.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 +14 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +17 -30
- package/doc/CustomRules.md +1 -1
- package/doc/Rules.md +140 -43
- package/doc/md001.md +1 -1
- package/doc/md011.md +1 -1
- package/doc/md022.md +15 -0
- package/doc/md025.md +1 -1
- package/doc/md026.md +1 -1
- package/doc/md028.md +13 -9
- package/doc/md034.md +1 -1
- package/doc/md035.md +12 -5
- package/doc/md041.md +2 -2
- package/doc/md042.md +6 -0
- package/doc/md045.md +1 -1
- package/doc/md051.md +10 -5
- package/doc/md060.md +76 -16
- package/helpers/README.md +4 -4
- package/helpers/helpers.cjs +45 -46
- package/helpers/micromark-helpers.cjs +4 -3
- package/helpers/package.json +2 -2
- package/helpers/shared.cjs +1 -1
- package/lib/configuration-strict.d.ts +124 -108
- package/lib/constants.mjs +2 -2
- package/lib/exports.d.mts +1 -0
- package/lib/exports.mjs +1 -0
- package/lib/markdownit.cjs +8 -7
- package/lib/markdownlint.d.mts +56 -41
- package/lib/markdownlint.mjs +35 -103
- package/lib/md011.mjs +8 -6
- package/lib/md013.mjs +14 -27
- package/lib/md022.mjs +14 -11
- package/lib/md029.mjs +3 -3
- package/lib/md036.mjs +1 -0
- package/lib/md051.mjs +2 -1
- package/lib/md060.mjs +107 -19
- package/lib/micromark-parse.mjs +21 -7
- package/lib/resolve-module.cjs +3 -3
- package/lib/resolve-module.d.cts +1 -1
- package/package.json +36 -38
- package/schema/.markdownlint.jsonc +58 -54
- package/schema/.markdownlint.yaml +57 -53
- package/schema/markdownlint-config-schema-strict.json +130 -110
- package/schema/markdownlint-config-schema.json +130 -110
package/doc/md035.md
CHANGED
|
@@ -8,8 +8,8 @@ Parameters:
|
|
|
8
8
|
|
|
9
9
|
- `style`: Horizontal rule style (`string`, default `consistent`)
|
|
10
10
|
|
|
11
|
-
This rule is triggered when inconsistent styles of horizontal rules
|
|
12
|
-
in
|
|
11
|
+
This rule is triggered when inconsistent styles of horizontal rules (also known
|
|
12
|
+
as "thematic breaks") are used in a document:
|
|
13
13
|
|
|
14
14
|
```markdown
|
|
15
15
|
---
|
|
@@ -23,15 +23,22 @@ in the document:
|
|
|
23
23
|
****
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
To fix this, use the same horizontal rule everywhere:
|
|
26
|
+
To fix this, use the same horizontal rule syntax everywhere:
|
|
27
27
|
|
|
28
28
|
```markdown
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
+
---
|
|
32
|
+
|
|
31
33
|
---
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
The
|
|
35
|
-
|
|
36
|
+
The `style` parameter's default value `consistent` ensures all horizontal rules
|
|
37
|
+
in a document match the first horizontal rule in that document. To enforce a
|
|
38
|
+
specific pattern of characters, set the `style` parameter to that string (e.g.,
|
|
39
|
+
`"* * *"`).
|
|
40
|
+
|
|
41
|
+
Note: In order to be recognized as a horizontal rule, a line must contain three
|
|
42
|
+
or more matching `-`, `_`, or `*` characters with optional space between.
|
|
36
43
|
|
|
37
44
|
Rationale: Consistent formatting makes it easier to understand a document.
|
package/doc/md041.md
CHANGED
|
@@ -59,6 +59,6 @@ in cases where an `h1` is added externally.
|
|
|
59
59
|
Rationale: The top-level heading often acts as the title of a document. More
|
|
60
60
|
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
|
61
61
|
|
|
62
|
-
[HTML]: https://
|
|
62
|
+
[HTML]: https://wikipedia.org/wiki/HTML
|
|
63
63
|
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
|
64
|
-
[YAML]: https://
|
|
64
|
+
[YAML]: https://wikipedia.org/wiki/YAML
|
package/doc/md042.md
CHANGED
|
@@ -20,6 +20,10 @@ Empty fragments will trigger this rule:
|
|
|
20
20
|
|
|
21
21
|
```markdown
|
|
22
22
|
[an empty fragment](#)
|
|
23
|
+
|
|
24
|
+
[an empty link definition][empty]
|
|
25
|
+
|
|
26
|
+
[empty]: #
|
|
23
27
|
```
|
|
24
28
|
|
|
25
29
|
But non-empty fragments will not:
|
|
@@ -28,5 +32,7 @@ But non-empty fragments will not:
|
|
|
28
32
|
[a valid fragment](#fragment)
|
|
29
33
|
```
|
|
30
34
|
|
|
35
|
+
Empty link definitions
|
|
36
|
+
|
|
31
37
|
Rationale: Empty links do not lead anywhere and therefore don't function as
|
|
32
38
|
links.
|
package/doc/md045.md
CHANGED
|
@@ -45,4 +45,4 @@ content of an image for people who may not be able to see it.
|
|
|
45
45
|
[aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden
|
|
46
46
|
[phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
|
|
47
47
|
[w3c]: https://www.w3.org/WAI/alt/
|
|
48
|
-
[wikipedia]: https://
|
|
48
|
+
[wikipedia]: https://wikipedia.org/wiki/Alt_attribute
|
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
|
|
104
|
-
enforces the [GitHub heading algorithm][github-heading-algorithm]
|
|
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
|
|
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,18 @@ 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
|
-
|
|
13
|
+
Fixable: Some violations can be fixed by tooling
|
|
14
|
+
|
|
15
|
+
This rule is triggered when the column separator pipe characters (`|`) of a
|
|
13
16
|
[GitHub Flavored Markdown table][gfm-table-060] are used inconsistently.
|
|
14
17
|
|
|
15
|
-
This rule recognizes three table column styles based on popular use
|
|
18
|
+
This rule recognizes three table column styles based on popular use.
|
|
16
19
|
|
|
17
|
-
Style `aligned`
|
|
20
|
+
Style `aligned` ensures pipe characters are vertically aligned:
|
|
18
21
|
|
|
19
22
|
```markdown
|
|
20
23
|
| Character | Meaning |
|
|
@@ -23,7 +26,16 @@ Style `aligned` looks the most like a table:
|
|
|
23
26
|
| N | No |
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
The `aligned` style ignores cell content, so the following is also valid:
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
| Character | Meaning |
|
|
33
|
+
|-----------|---------|
|
|
34
|
+
| Y | Yes |
|
|
35
|
+
| N | No |
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Style `compact` avoids extra padding with a single space around cell content:
|
|
27
39
|
|
|
28
40
|
```markdown
|
|
29
41
|
| Character | Meaning |
|
|
@@ -32,7 +44,7 @@ Style `compact` uses a single space to pad cell content:
|
|
|
32
44
|
| N | No |
|
|
33
45
|
```
|
|
34
46
|
|
|
35
|
-
Style `tight` uses no padding for cell content:
|
|
47
|
+
Style `tight` uses no padding at all for cell content:
|
|
36
48
|
|
|
37
49
|
```markdown
|
|
38
50
|
|Character|Meaning|
|
|
@@ -42,16 +54,61 @@ Style `tight` uses no padding for cell content:
|
|
|
42
54
|
```
|
|
43
55
|
|
|
44
56
|
When this rule's `style` parameter is set to `aligned`, `compact`, or `tight`,
|
|
45
|
-
every table must match the corresponding pattern and
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
every table must match the corresponding pattern and any violations will be
|
|
58
|
+
reported. By default, or when the `any` style is used, each table is analyzed to
|
|
59
|
+
see if it satisfies any supported style. If so, no violations are reported. If
|
|
60
|
+
not, violations are be reported for whichever style would produce the *fewest*
|
|
61
|
+
issues (i.e., whichever style is the closest match).
|
|
62
|
+
|
|
63
|
+
Setting the `aligned_delimiter` parameter to `true` requires pipe characters in
|
|
64
|
+
the delimiter row to align with those in the header row. This can be used with
|
|
65
|
+
`compact` and `tight` tables to make the header text more obvious. (It's already
|
|
66
|
+
required for tables with style `aligned`.)
|
|
67
|
+
|
|
68
|
+
Style `compact` with `aligned_delimiter`:
|
|
69
|
+
|
|
70
|
+
```markdown
|
|
71
|
+
| Character | Meaning |
|
|
72
|
+
| --------- | ------- |
|
|
73
|
+
| Y | Yes |
|
|
74
|
+
| N | No |
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Style `tight` with `aligned_delimiter`:
|
|
78
|
+
|
|
79
|
+
```markdown
|
|
80
|
+
|Character|Meaning|
|
|
81
|
+
|---------|-------|
|
|
82
|
+
|Y|Yes|
|
|
83
|
+
|N|No|
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Violations for styles `compact` and `tight` are simple/independent and can be
|
|
87
|
+
fixed automatically. However, fixing even single violations for style `aligned`
|
|
88
|
+
may require modifying the entire table, and therefore are not automatic:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
|Alpha |Delta|
|
|
92
|
+
|------|-----|
|
|
93
|
+
|Charlie|Beta|
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Note**: This rule does not require leading/trailing pipe characters, so this
|
|
97
|
+
is also a valid table for style `compact`:
|
|
98
|
+
|
|
99
|
+
```markdown
|
|
100
|
+
Character | Meaning
|
|
101
|
+
--- | ---
|
|
102
|
+
Y | Yes
|
|
103
|
+
N | No
|
|
104
|
+
```
|
|
50
105
|
|
|
51
|
-
Note
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
106
|
+
**Note**: Pipe alignment for the `aligned` style is based on visual appearance
|
|
107
|
+
and not character count. Because editors typically render [emoji][emoji] and
|
|
108
|
+
[CJK characters][cjk-characters] at *twice* the width of
|
|
109
|
+
[Latin characters][latin-script], this rule takes that into account for tables
|
|
110
|
+
using the `aligned` style. The following table is correctly formatted and will
|
|
111
|
+
appear aligned in most editors and monospaced fonts:
|
|
55
112
|
|
|
56
113
|
<!-- markdownlint-capture -->
|
|
57
114
|
<!-- markdownlint-disable extended-ascii -->
|
|
@@ -59,12 +116,15 @@ editors render the emoji wider:
|
|
|
59
116
|
```markdown
|
|
60
117
|
| Response | Emoji |
|
|
61
118
|
| -------- | ----- |
|
|
62
|
-
| Yes | ✅
|
|
63
|
-
| No | ❎
|
|
119
|
+
| Yes | ✅ |
|
|
120
|
+
| No | ❎ |
|
|
64
121
|
```
|
|
65
122
|
|
|
66
123
|
<!-- markdownlint-restore -->
|
|
67
124
|
|
|
68
125
|
Rationale: Consistent formatting makes it easier to understand a document.
|
|
69
126
|
|
|
127
|
+
[cjk-characters]: https://wikipedia.org/wiki/CJK_characters
|
|
128
|
+
[emoji]: https://wikipedia.org/wiki/Emoji
|
|
70
129
|
[gfm-table-060]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
|
|
130
|
+
[latin-script]: https://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.
|
|
26
|
-
[jsdoc]: https://
|
|
27
|
-
[markdown]: https://
|
|
25
|
+
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.41.0/doc/CustomRules.md
|
|
26
|
+
[jsdoc]: https://wikipedia.org/wiki/JSDoc
|
|
27
|
+
[markdown]: https://wikipedia.org/wiki/Markdown
|
|
28
28
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
|
29
|
-
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.
|
|
29
|
+
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.41.0/doc/Rules.md
|
package/helpers/helpers.cjs
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
const micromark = require("./micromark-helpers.cjs");
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { newlineRe, nextLinesRe } = require("./shared.cjs");
|
|
8
8
|
|
|
9
|
-
module.exports.newLineRe =
|
|
9
|
+
module.exports.newLineRe = newlineRe;
|
|
10
10
|
module.exports.nextLinesRe = nextLinesRe;
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../lib/exports.mjs").RuleOnError} RuleOnError */
|
|
@@ -311,7 +311,7 @@ module.exports.addErrorDetailIf = addErrorDetailIf;
|
|
|
311
311
|
*/
|
|
312
312
|
function addErrorContext(onError, lineNumber, context, start, end, range, fixInfo) {
|
|
313
313
|
// Normalize new line characters so Linux and Windows trim consistently
|
|
314
|
-
context = ellipsify(context.replace(
|
|
314
|
+
context = ellipsify(context.replace(newlineRe, "\n"), start, end);
|
|
315
315
|
addError(onError, lineNumber, undefined, context, range, fixInfo);
|
|
316
316
|
}
|
|
317
317
|
module.exports.addErrorContext = addErrorContext;
|
|
@@ -438,59 +438,59 @@ function getReferenceLinkImageData(tokens) {
|
|
|
438
438
|
case "gfmFootnoteDefinitionLabelString":
|
|
439
439
|
labelPrefix = "^";
|
|
440
440
|
case "definitionLabelString": // eslint-disable-line no-fallthrough
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
441
|
+
{
|
|
442
|
+
// definitions and definitionLineIndices
|
|
443
|
+
const reference = normalizeReference(`${labelPrefix}${token.text}`);
|
|
444
|
+
if (definitions.has(reference)) {
|
|
445
|
+
duplicateDefinitions.push([ reference, token.startLine - 1 ]);
|
|
446
|
+
} else {
|
|
447
|
+
const parent =
|
|
448
|
+
micromark.getParentOfType(token, [ "definition" ]);
|
|
449
|
+
const destinationString = parent &&
|
|
450
|
+
micromark.getDescendantsByType(parent, [ "definitionDestination", "definitionDestinationRaw", "definitionDestinationString" ])[0]?.text;
|
|
451
|
+
definitions.set(
|
|
452
|
+
reference,
|
|
453
|
+
[ token.startLine - 1, destinationString || "" ]
|
|
454
|
+
);
|
|
456
455
|
}
|
|
457
456
|
break;
|
|
457
|
+
}
|
|
458
458
|
case "gfmFootnoteCall":
|
|
459
459
|
case "image":
|
|
460
460
|
case "link":
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
// Track link (handle shortcuts separately due to ambiguity in "text [text] text")
|
|
479
|
-
if (isShortcut || isFullOrCollapsed) {
|
|
480
|
-
addReferenceToDictionary(token, getText(referenceString) || label, isShortcut);
|
|
461
|
+
{
|
|
462
|
+
// Identify if shortcut or full/collapsed
|
|
463
|
+
let isShortcut = (token.children.length === 1);
|
|
464
|
+
const isFullOrCollapsed = (token.children.length === 2) && !token.children.some((t) => t.type === "resource");
|
|
465
|
+
const [ labelText ] = micromark.getDescendantsByType(token, [ "label", "labelText" ]);
|
|
466
|
+
const [ referenceString ] = micromark.getDescendantsByType(token, [ "reference", "referenceString" ]);
|
|
467
|
+
let label = getText(labelText);
|
|
468
|
+
// Identify if footnote
|
|
469
|
+
if (!isShortcut && !isFullOrCollapsed) {
|
|
470
|
+
const [ footnoteCallMarker, footnoteCallString ] = token.children.filter(
|
|
471
|
+
(t) => [ "gfmFootnoteCallMarker", "gfmFootnoteCallString" ].includes(t.type)
|
|
472
|
+
);
|
|
473
|
+
if (footnoteCallMarker && footnoteCallString) {
|
|
474
|
+
label = `${footnoteCallMarker.text}${footnoteCallString.text}`;
|
|
475
|
+
isShortcut = true;
|
|
481
476
|
}
|
|
482
477
|
}
|
|
478
|
+
// Track link (handle shortcuts separately due to ambiguity in "text [text] text")
|
|
479
|
+
if (isShortcut || isFullOrCollapsed) {
|
|
480
|
+
addReferenceToDictionary(token, getText(referenceString) || label, isShortcut);
|
|
481
|
+
}
|
|
483
482
|
break;
|
|
483
|
+
}
|
|
484
484
|
case "undefinedReferenceCollapsed":
|
|
485
485
|
case "undefinedReferenceFull":
|
|
486
486
|
case "undefinedReferenceShortcut":
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
487
|
+
{
|
|
488
|
+
const undefinedReference = micromark.getDescendantsByType(token, [ "undefinedReference" ])[0];
|
|
489
|
+
const label = undefinedReference.children.map((t) => t.text).join("");
|
|
490
|
+
const isShortcut = (token.type === "undefinedReferenceShortcut");
|
|
491
|
+
addReferenceToDictionary(token, label, isShortcut);
|
|
493
492
|
break;
|
|
493
|
+
}
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
return {
|
|
@@ -514,7 +514,7 @@ function getPreferredLineEnding(input, os) {
|
|
|
514
514
|
let cr = 0;
|
|
515
515
|
let lf = 0;
|
|
516
516
|
let crlf = 0;
|
|
517
|
-
const endings = input.match(
|
|
517
|
+
const endings = input.match(newlineRe) || [];
|
|
518
518
|
for (const ending of endings) {
|
|
519
519
|
// eslint-disable-next-line default-case
|
|
520
520
|
switch (ending) {
|
|
@@ -630,7 +630,6 @@ function convertLintErrorsVersion2To0(errors) {
|
|
|
630
630
|
function copyAndTransformResults(results, transform) {
|
|
631
631
|
/** @type {Object.<string, LintErrors>} */
|
|
632
632
|
const newResults = {};
|
|
633
|
-
Object.defineProperty(newResults, "toString", { "value": results.toString });
|
|
634
633
|
for (const key of Object.keys(results)) {
|
|
635
634
|
const arr = results[key].map((r) => ({ ...r }));
|
|
636
635
|
newResults[key] = transform(arr);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
-
const { flatTokensSymbol, htmlFlowSymbol,
|
|
5
|
+
const { flatTokensSymbol, htmlFlowSymbol, newlineRe } = require("./shared.cjs");
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line jsdoc/valid-types
|
|
8
8
|
/** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */
|
|
@@ -152,7 +152,6 @@ function getBlockQuotePrefixText(tokens, lineNumber, count = 1) {
|
|
|
152
152
|
.map((prefix) => prefix.text)
|
|
153
153
|
.join("")
|
|
154
154
|
.trimEnd()
|
|
155
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
156
155
|
.concat("\n")
|
|
157
156
|
.repeat(count);
|
|
158
157
|
};
|
|
@@ -224,7 +223,7 @@ function getHeadingText(heading) {
|
|
|
224
223
|
.flatMap((descendant) => descendant.children.filter((child) => child.type !== "htmlText"))
|
|
225
224
|
.map((data) => data.text)
|
|
226
225
|
.join("")
|
|
227
|
-
.replace(
|
|
226
|
+
.replace(newlineRe, " ");
|
|
228
227
|
}
|
|
229
228
|
|
|
230
229
|
/**
|
|
@@ -285,7 +284,9 @@ function isDocfxTab(heading) {
|
|
|
285
284
|
// See https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#tabs
|
|
286
285
|
if (heading?.type === "atxHeading") {
|
|
287
286
|
const headingTexts = getDescendantsByType(heading, [ "atxHeadingText" ]);
|
|
287
|
+
// eslint-disable-next-line unicorn/better-dom-traversing
|
|
288
288
|
if ((headingTexts.length === 1) && (headingTexts[0].children.length === 1) && (headingTexts[0].children[0].type === "link")) {
|
|
289
|
+
// eslint-disable-next-line unicorn/better-dom-traversing
|
|
289
290
|
const resourceDestinationStrings = filterByTypes(headingTexts[0].children[0].children, [ "resourceDestinationString" ]);
|
|
290
291
|
return (resourceDestinationStrings.length === 1) && docfxTabSyntaxRe.test(resourceDestinationStrings[0].text);
|
|
291
292
|
}
|
package/helpers/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-rule-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "A collection of markdownlint helper functions for custom rules",
|
|
5
5
|
"main": "./helpers.cjs",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
|
18
18
|
"funding": "https://github.com/sponsors/DavidAnson",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=22"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"markdownlint",
|
package/helpers/shared.cjs
CHANGED
|
@@ -10,7 +10,7 @@ module.exports.htmlFlowSymbol = Symbol("html-flow");
|
|
|
10
10
|
|
|
11
11
|
// Regular expression for matching common newline characters
|
|
12
12
|
// See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
|
|
13
|
-
module.exports.
|
|
13
|
+
module.exports.newlineRe = /\r\n?|\n/g;
|
|
14
14
|
|
|
15
15
|
// Regular expression for matching next lines
|
|
16
16
|
module.exports.nextLinesRe = /[\r\n][\s\S]*$/;
|