@alexlit/lint-kit 190.0.1 → 191.0.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/package.json +1 -1
- package/packages/config-eslint/package.json +3 -3
- package/packages/config-markdownlint/package.json +2 -2
- package/packages/config-markdownlint/node_modules/ansi-regex/index.d.ts +0 -33
- package/packages/config-markdownlint/node_modules/ansi-regex/index.js +0 -14
- package/packages/config-markdownlint/node_modules/ansi-regex/license +0 -9
- package/packages/config-markdownlint/node_modules/ansi-regex/package.json +0 -61
- package/packages/config-markdownlint/node_modules/ansi-regex/readme.md +0 -66
- package/packages/config-markdownlint/node_modules/markdownlint/CHANGELOG.md +0 -529
- package/packages/config-markdownlint/node_modules/markdownlint/CONTRIBUTING.md +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/README.md +0 -1112
- package/packages/config-markdownlint/node_modules/markdownlint/doc/CustomRules.md +0 -194
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Prettier.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/ReleaseProcess.md +0 -20
- package/packages/config-markdownlint/node_modules/markdownlint/doc/Rules.md +0 -2858
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md001.md +0 -51
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md003.md +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md004.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md005.md +0 -53
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md007.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md009.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md010.md +0 -62
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md011.md +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md012.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md013.md +0 -58
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md014.md +0 -54
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md018.md +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md019.md +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md020.md +0 -29
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md021.md +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md022.md +0 -67
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md023.md +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md024.md +0 -44
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md025.md +0 -49
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md026.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md027.md +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md028.md +0 -44
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md029.md +0 -100
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md030.md +0 -82
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md031.md +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md032.md +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md033.md +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md034.md +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md035.md +0 -44
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md036.md +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md037.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md038.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md039.md +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md040.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md041.md +0 -64
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md042.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md043.md +0 -87
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md044.md +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md045.md +0 -48
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md046.md +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md047.md +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md048.md +0 -42
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md049.md +0 -36
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md050.md +0 -35
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md051.md +0 -117
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md052.md +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md053.md +0 -38
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md054.md +0 -100
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md055.md +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md056.md +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md058.md +0 -48
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md059.md +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/doc/md060.md +0 -130
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/LICENSE +0 -21
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/README.md +0 -29
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/helpers.cjs +0 -695
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/micromark-helpers.cjs +0 -332
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/package.json +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/helpers/shared.cjs +0 -16
- package/packages/config-markdownlint/node_modules/markdownlint/lib/cache.mjs +0 -80
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration-strict.d.ts +0 -2417
- package/packages/config-markdownlint/node_modules/markdownlint/lib/configuration.d.ts +0 -8
- package/packages/config-markdownlint/node_modules/markdownlint/lib/constants.mjs +0 -14
- package/packages/config-markdownlint/node_modules/markdownlint/lib/defer-require.cjs +0 -18
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.d.mts +0 -1
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-async.mjs +0 -3
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.d.mts +0 -1
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-promise.mjs +0 -3
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.d.mts +0 -1
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports-sync.mjs +0 -3
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.d.mts +0 -30
- package/packages/config-markdownlint/node_modules/markdownlint/lib/exports.mjs +0 -33
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownit.cjs +0 -171
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.d.mts +0 -615
- package/packages/config-markdownlint/node_modules/markdownlint/lib/markdownlint.mjs +0 -1592
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md001.mjs +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md003.mjs +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md004.mjs +0 -72
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md005.mjs +0 -69
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md007.mjs +0 -84
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md009.mjs +0 -96
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md010.mjs +0 -78
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md011.mjs +0 -56
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md012.mjs +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md013.mjs +0 -91
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md014.mjs +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md018.mjs +0 -43
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md019-md021.mjs +0 -77
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md020.mjs +0 -68
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md022.mjs +0 -103
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md023.mjs +0 -37
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md024.mjs +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md025.mjs +0 -45
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md026.mjs +0 -46
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md027.mjs +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md028.mjs +0 -39
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md029.mjs +0 -84
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md030.mjs +0 -57
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md031.mjs +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md032.mjs +0 -78
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md033.mjs +0 -46
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md034.mjs +0 -92
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md035.mjs +0 -23
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md036.mjs +0 -55
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md037.mjs +0 -94
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md038.mjs +0 -73
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md039.mjs +0 -59
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md040.mjs +0 -32
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md041.mjs +0 -71
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md042.mjs +0 -58
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md043.mjs +0 -72
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md044.mjs +0 -110
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md045.mjs +0 -61
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md046.mjs +0 -31
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md047.mjs +0 -28
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md048.mjs +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md049-md050.mjs +0 -115
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md051.mjs +0 -173
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md052.mjs +0 -40
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md053.mjs +0 -60
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md054.mjs +0 -122
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md055.mjs +0 -72
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md056.mjs +0 -50
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md058.mjs +0 -57
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md059.mjs +0 -71
- package/packages/config-markdownlint/node_modules/markdownlint/lib/md060.mjs +0 -209
- package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-parse.mjs +0 -337
- package/packages/config-markdownlint/node_modules/markdownlint/lib/micromark-types.d.mts +0 -11
- package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-browser.mjs +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/lib/node-imports-node.mjs +0 -11
- package/packages/config-markdownlint/node_modules/markdownlint/lib/parse-configuration.mjs +0 -47
- package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.cjs +0 -52
- package/packages/config-markdownlint/node_modules/markdownlint/lib/resolve-module.d.cts +0 -34
- package/packages/config-markdownlint/node_modules/markdownlint/lib/rules.mjs +0 -122
- package/packages/config-markdownlint/node_modules/markdownlint/lib/types.d.mts +0 -13
- package/packages/config-markdownlint/node_modules/markdownlint/package.json +0 -120
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.jsonc +0 -349
- package/packages/config-markdownlint/node_modules/markdownlint/schema/.markdownlint.yaml +0 -310
- package/packages/config-markdownlint/node_modules/markdownlint/schema/ValidatingConfiguration.md +0 -26
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema-strict.json +0 -5138
- package/packages/config-markdownlint/node_modules/markdownlint/schema/markdownlint-config-schema.json +0 -5143
- package/packages/config-markdownlint/node_modules/markdownlint/style/all.json +0 -5
- package/packages/config-markdownlint/node_modules/markdownlint/style/cirosantilli.json +0 -22
- package/packages/config-markdownlint/node_modules/markdownlint/style/prettier.json +0 -27
- package/packages/config-markdownlint/node_modules/markdownlint/style/relaxed.json +0 -12
- package/packages/config-markdownlint/node_modules/string-width/index.d.ts +0 -39
- package/packages/config-markdownlint/node_modules/string-width/index.js +0 -203
- package/packages/config-markdownlint/node_modules/string-width/license +0 -9
- package/packages/config-markdownlint/node_modules/string-width/package.json +0 -65
- package/packages/config-markdownlint/node_modules/string-width/readme.md +0 -66
- package/packages/config-markdownlint/node_modules/strip-ansi/index.d.ts +0 -15
- package/packages/config-markdownlint/node_modules/strip-ansi/index.js +0 -19
- package/packages/config-markdownlint/node_modules/strip-ansi/license +0 -9
- package/packages/config-markdownlint/node_modules/strip-ansi/package.json +0 -59
- package/packages/config-markdownlint/node_modules/strip-ansi/readme.md +0 -37
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
|
4
|
-
import { getBlockQuotePrefixText } from "../helpers/micromark-helpers.cjs";
|
|
5
|
-
import { filterByTypesCached } from "./cache.mjs";
|
|
6
|
-
|
|
7
|
-
/** @typedef {import("micromark-extension-gfm-table")} */
|
|
8
|
-
|
|
9
|
-
/** @type {import("markdownlint").Rule} */
|
|
10
|
-
export default {
|
|
11
|
-
"names": [ "MD058", "blanks-around-tables" ],
|
|
12
|
-
"description": "Tables should be surrounded by blank lines",
|
|
13
|
-
"tags": [ "table" ],
|
|
14
|
-
"parser": "micromark",
|
|
15
|
-
"function": function MD058(params, onError) {
|
|
16
|
-
const { lines } = params;
|
|
17
|
-
const blockQuotePrefixes = filterByTypesCached([ "blockQuotePrefix", "linePrefix" ]);
|
|
18
|
-
|
|
19
|
-
// For every table...
|
|
20
|
-
const tables = filterByTypesCached([ "table" ]);
|
|
21
|
-
for (const table of tables) {
|
|
22
|
-
|
|
23
|
-
// Look for a blank line above the table
|
|
24
|
-
const firstLineNumber = table.startLine;
|
|
25
|
-
if (!isBlankLine(lines[firstLineNumber - 2])) {
|
|
26
|
-
addErrorContext(
|
|
27
|
-
onError,
|
|
28
|
-
firstLineNumber,
|
|
29
|
-
lines[firstLineNumber - 1].trim(),
|
|
30
|
-
undefined,
|
|
31
|
-
undefined,
|
|
32
|
-
undefined,
|
|
33
|
-
{
|
|
34
|
-
"insertText": getBlockQuotePrefixText(blockQuotePrefixes, firstLineNumber)
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Look for a blank line below the table
|
|
40
|
-
const lastLineNumber = table.endLine;
|
|
41
|
-
if (!isBlankLine(lines[lastLineNumber])) {
|
|
42
|
-
addErrorContext(
|
|
43
|
-
onError,
|
|
44
|
-
lastLineNumber,
|
|
45
|
-
lines[lastLineNumber - 1].trim(),
|
|
46
|
-
undefined,
|
|
47
|
-
undefined,
|
|
48
|
-
undefined,
|
|
49
|
-
{
|
|
50
|
-
"lineNumber": lastLineNumber + 1,
|
|
51
|
-
"insertText": getBlockQuotePrefixText(blockQuotePrefixes, lastLineNumber)
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { addErrorContext } from "../helpers/helpers.cjs";
|
|
4
|
-
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
|
5
|
-
import { filterByTypesCached } from "./cache.mjs";
|
|
6
|
-
|
|
7
|
-
/** @typedef {import("markdownlint").MicromarkTokenType} MicromarkTokenType */
|
|
8
|
-
/** @type {Set<MicromarkTokenType>} */
|
|
9
|
-
const allowedChildrenTypes = new Set([
|
|
10
|
-
"codeText",
|
|
11
|
-
"htmlText"
|
|
12
|
-
]);
|
|
13
|
-
const defaultProhibitedTexts = [
|
|
14
|
-
"click here",
|
|
15
|
-
"here",
|
|
16
|
-
"link",
|
|
17
|
-
"more"
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Normalizes a string by removing extra whitespaces and punctuation.
|
|
22
|
-
*
|
|
23
|
-
* @param {string} str String to normalize.
|
|
24
|
-
* @returns {string} Normalized string.
|
|
25
|
-
*/
|
|
26
|
-
function normalize(str) {
|
|
27
|
-
return str
|
|
28
|
-
.replace(/[\W_]+/g, " ")
|
|
29
|
-
.replace(/\s+/g, " ")
|
|
30
|
-
.toLowerCase()
|
|
31
|
-
.trim();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** @type {import("markdownlint").Rule} */
|
|
35
|
-
export default {
|
|
36
|
-
"names": [ "MD059", "descriptive-link-text" ],
|
|
37
|
-
"description": "Link text should be descriptive",
|
|
38
|
-
"tags": [ "accessibility", "links" ],
|
|
39
|
-
"parser": "micromark",
|
|
40
|
-
"function": function MD059(params, onError) {
|
|
41
|
-
const prohibitedTexts = new Set(
|
|
42
|
-
(params.config.prohibited_texts || defaultProhibitedTexts).map(normalize)
|
|
43
|
-
);
|
|
44
|
-
if (prohibitedTexts.size > 0) {
|
|
45
|
-
const links = filterByTypesCached([ "link" ]);
|
|
46
|
-
for (const link of links) {
|
|
47
|
-
const labelTexts = getDescendantsByType(link, [ "label", "labelText" ]);
|
|
48
|
-
for (const labelText of labelTexts) {
|
|
49
|
-
const { children, endColumn, endLine, parent, startColumn, startLine, text } = labelText;
|
|
50
|
-
if (
|
|
51
|
-
!children.some((child) => allowedChildrenTypes.has(child.type)) &&
|
|
52
|
-
prohibitedTexts.has(normalize(text))
|
|
53
|
-
) {
|
|
54
|
-
const range = (startLine === endLine) ?
|
|
55
|
-
[ startColumn, endColumn - startColumn ] :
|
|
56
|
-
undefined;
|
|
57
|
-
addErrorContext(
|
|
58
|
-
onError,
|
|
59
|
-
startLine,
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
parent.text,
|
|
62
|
-
undefined,
|
|
63
|
-
undefined,
|
|
64
|
-
range
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { filterByTypes } from "../helpers/micromark-helpers.cjs";
|
|
4
|
-
import { filterByTypesCached } from "./cache.mjs";
|
|
5
|
-
import stringWidth from "string-width";
|
|
6
|
-
|
|
7
|
-
/** @typedef {import("micromark-extension-gfm-table")} */
|
|
8
|
-
/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
|
|
9
|
-
/** @typedef {import("markdownlint").RuleOnErrorInfo} RuleOnErrorInfo */
|
|
10
|
-
/** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Adds a RuleOnErrorInfo object to a list of RuleOnErrorInfo objects.
|
|
14
|
-
*
|
|
15
|
-
* @param {RuleOnErrorInfo[]} errors List of errors.
|
|
16
|
-
* @param {number} lineNumber Line number.
|
|
17
|
-
* @param {number} column Column number.
|
|
18
|
-
* @param {string} detail Detail message.
|
|
19
|
-
* @param {RuleOnErrorFixInfo} [fixInfo] Fix information.
|
|
20
|
-
*/
|
|
21
|
-
function addError(errors, lineNumber, column, detail, fixInfo) {
|
|
22
|
-
errors.push({
|
|
23
|
-
lineNumber,
|
|
24
|
-
detail,
|
|
25
|
-
"range": [ column, 1 ],
|
|
26
|
-
fixInfo
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @typedef Column
|
|
32
|
-
* @property {number} actual Actual column (1-based).
|
|
33
|
-
* @property {number} effective Effective column (1-based).
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Gets a list of table cell divider columns.
|
|
38
|
-
*
|
|
39
|
-
* @param {readonly string[]} lines File/string lines.
|
|
40
|
-
* @param {MicromarkToken} row Micromark row token.
|
|
41
|
-
* @returns {Column[]} Divider columns.
|
|
42
|
-
*/
|
|
43
|
-
function getTableDividerColumns(lines, row) {
|
|
44
|
-
return filterByTypes(
|
|
45
|
-
row.children,
|
|
46
|
-
[ "tableCellDivider" ]
|
|
47
|
-
).map(
|
|
48
|
-
(divider) => ({
|
|
49
|
-
"actual": divider.startColumn,
|
|
50
|
-
"effective": stringWidth(lines[row.startLine - 1].slice(0, divider.startColumn - 1))
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Checks the specified table rows for consistency with the "aligned" style.
|
|
57
|
-
*
|
|
58
|
-
* @param {readonly string[]} lines File/string lines.
|
|
59
|
-
* @param {MicromarkToken[]} rows Micromark row tokens.
|
|
60
|
-
* @param {string} detail Detail message.
|
|
61
|
-
* @returns {RuleOnErrorInfo[]} List of errors.
|
|
62
|
-
*/
|
|
63
|
-
function checkStyleAligned(lines, rows, detail) {
|
|
64
|
-
/** @type {RuleOnErrorInfo[]} */
|
|
65
|
-
const errorInfos = [];
|
|
66
|
-
const headerRow = rows[0];
|
|
67
|
-
const headerDividerColumns = getTableDividerColumns(lines, headerRow);
|
|
68
|
-
for (const row of rows.slice(1)) {
|
|
69
|
-
const remainingHeaderDividerColumns = new Set(headerDividerColumns.map((column) => column.effective));
|
|
70
|
-
const rowDividerColumns = getTableDividerColumns(lines, row);
|
|
71
|
-
for (const dividerColumn of rowDividerColumns) {
|
|
72
|
-
if ((remainingHeaderDividerColumns.size > 0) && !remainingHeaderDividerColumns.delete(dividerColumn.effective)) {
|
|
73
|
-
addError(errorInfos, row.startLine, dividerColumn.actual, detail);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return errorInfos;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** @type {import("markdownlint").Rule} */
|
|
81
|
-
export default {
|
|
82
|
-
"names": [ "MD060", "table-column-style" ],
|
|
83
|
-
"description": "Table column style",
|
|
84
|
-
"tags": [ "table" ],
|
|
85
|
-
"parser": "micromark",
|
|
86
|
-
"function": function MD060(params, onError) {
|
|
87
|
-
const style = String(params.config.style || "any");
|
|
88
|
-
const styleAlignedAllowed = (style === "any") || (style === "aligned");
|
|
89
|
-
const styleCompactAllowed = (style === "any") || (style === "compact");
|
|
90
|
-
const styleTightAllowed = (style === "any") || (style === "tight");
|
|
91
|
-
const alignedDelimiter = !!params.config.aligned_delimiter;
|
|
92
|
-
const lines = params.lines;
|
|
93
|
-
|
|
94
|
-
// Scan all tables/rows
|
|
95
|
-
const tables = filterByTypesCached([ "table" ]);
|
|
96
|
-
for (const table of tables) {
|
|
97
|
-
const rows = filterByTypes(table.children, [ "tableDelimiterRow", "tableRow" ]);
|
|
98
|
-
|
|
99
|
-
// Determine errors for style "aligned"
|
|
100
|
-
/** @type {RuleOnErrorInfo[]} */
|
|
101
|
-
const errorsIfAligned = [];
|
|
102
|
-
if (styleAlignedAllowed) {
|
|
103
|
-
errorsIfAligned.push(...checkStyleAligned(lines, rows, "Table pipe does not align with header for style \"aligned\""));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Determine errors for styles "compact" and "tight"
|
|
107
|
-
/** @type {RuleOnErrorInfo[]} */
|
|
108
|
-
const errorsIfCompact = [];
|
|
109
|
-
/** @type {RuleOnErrorInfo[]} */
|
|
110
|
-
const errorsIfTight = [];
|
|
111
|
-
if (
|
|
112
|
-
(styleCompactAllowed || styleTightAllowed) &&
|
|
113
|
-
!(styleAlignedAllowed && (errorsIfAligned.length === 0))
|
|
114
|
-
) {
|
|
115
|
-
if (alignedDelimiter) {
|
|
116
|
-
const errorInfos = checkStyleAligned(lines, rows.slice(0, 2), "Table pipe does not align with header for option \"aligned_delimiter\"");
|
|
117
|
-
errorsIfCompact.push(...errorInfos);
|
|
118
|
-
errorsIfTight.push(...errorInfos);
|
|
119
|
-
}
|
|
120
|
-
for (const row of rows) {
|
|
121
|
-
const tokensOfInterest = filterByTypes(row.children, [ "tableCellDivider", "tableContent", "whitespace" ]);
|
|
122
|
-
for (let i = 0; i < tokensOfInterest.length; i++) {
|
|
123
|
-
const { startColumn, startLine, type } = tokensOfInterest[i];
|
|
124
|
-
if (type === "tableCellDivider") {
|
|
125
|
-
const previous = tokensOfInterest[i - 1];
|
|
126
|
-
if (previous) {
|
|
127
|
-
if (previous.type === "whitespace") {
|
|
128
|
-
if (previous.text.length !== 1) {
|
|
129
|
-
addError(
|
|
130
|
-
errorsIfCompact,
|
|
131
|
-
startLine,
|
|
132
|
-
startColumn,
|
|
133
|
-
"Table pipe has extra space to the left for style \"compact\"",
|
|
134
|
-
{ "editColumn": previous.startColumn, "deleteCount": previous.text.length - 1 }
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
addError(
|
|
138
|
-
errorsIfTight,
|
|
139
|
-
startLine,
|
|
140
|
-
startColumn,
|
|
141
|
-
"Table pipe has space to the left for style \"tight\"",
|
|
142
|
-
{ "editColumn": previous.startColumn, "deleteCount": previous.text.length }
|
|
143
|
-
);
|
|
144
|
-
} else {
|
|
145
|
-
addError(
|
|
146
|
-
errorsIfCompact,
|
|
147
|
-
startLine,
|
|
148
|
-
startColumn,
|
|
149
|
-
"Table pipe is missing space to the left for style \"compact\"",
|
|
150
|
-
{ "editColumn": previous.endColumn, "insertText": " " }
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const next = tokensOfInterest[i + 1];
|
|
155
|
-
if (next) {
|
|
156
|
-
if (next.type === "whitespace") {
|
|
157
|
-
if (next.endColumn !== row.endColumn) {
|
|
158
|
-
if (next.text.length !== 1) {
|
|
159
|
-
addError(
|
|
160
|
-
errorsIfCompact,
|
|
161
|
-
startLine,
|
|
162
|
-
startColumn,
|
|
163
|
-
"Table pipe has extra space to the right for style \"compact\"",
|
|
164
|
-
{ "editColumn": next.startColumn, "deleteCount": next.text.length - 1 }
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
addError(
|
|
168
|
-
errorsIfTight,
|
|
169
|
-
startLine,
|
|
170
|
-
startColumn,
|
|
171
|
-
"Table pipe has space to the right for style \"tight\"",
|
|
172
|
-
{ "editColumn": next.startColumn, "deleteCount": next.text.length }
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
addError(
|
|
177
|
-
errorsIfCompact,
|
|
178
|
-
startLine,
|
|
179
|
-
startColumn,
|
|
180
|
-
"Table pipe is missing space to the right for style \"compact\"",
|
|
181
|
-
{ "editColumn": next.startColumn, "insertText": " " }
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Report errors for whatever (allowed) style has the fewest
|
|
191
|
-
let errorInfos = errorsIfAligned;
|
|
192
|
-
if (
|
|
193
|
-
styleCompactAllowed &&
|
|
194
|
-
((errorsIfCompact.length < errorInfos.length) || !styleAlignedAllowed)
|
|
195
|
-
) {
|
|
196
|
-
errorInfos = errorsIfCompact;
|
|
197
|
-
}
|
|
198
|
-
if (
|
|
199
|
-
styleTightAllowed &&
|
|
200
|
-
((errorsIfTight.length < errorInfos.length) || (!styleAlignedAllowed && !styleCompactAllowed))
|
|
201
|
-
) {
|
|
202
|
-
errorInfos = errorsIfTight;
|
|
203
|
-
}
|
|
204
|
-
for (const errorInfo of errorInfos) {
|
|
205
|
-
onError(errorInfo);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import { directive } from "micromark-extension-directive";
|
|
4
|
-
import { gfmAutolinkLiteral } from "micromark-extension-gfm-autolink-literal";
|
|
5
|
-
import { gfmFootnote } from "micromark-extension-gfm-footnote";
|
|
6
|
-
import { gfmTable } from "micromark-extension-gfm-table";
|
|
7
|
-
import { math } from "micromark-extension-math";
|
|
8
|
-
import { parse as micromarkParse, postprocess as micromarkPostprocess, preprocess as micromarkPreprocess } from "micromark";
|
|
9
|
-
// micromark-core-commonmark must exactly match what's used by micromark for the shim below to work correctly
|
|
10
|
-
// Unfortunately, omitting this dependency from package.json breaks strict dependency resolution (e.g., pnpm)
|
|
11
|
-
import { labelEnd } from "micromark-core-commonmark";
|
|
12
|
-
import { isHtmlFlowComment } from "../helpers/micromark-helpers.cjs";
|
|
13
|
-
import { flatTokensSymbol, htmlFlowSymbol, newlineRe } from "../helpers/shared.cjs";
|
|
14
|
-
|
|
15
|
-
/** @typedef {import("micromark-util-types").Event} Event */
|
|
16
|
-
/** @typedef {import("micromark-util-types").Extension} Extension */
|
|
17
|
-
/** @typedef {import("micromark-util-types").ParseOptions} MicromarkParseOptions */
|
|
18
|
-
/** @typedef {import("micromark-util-types").State} State */
|
|
19
|
-
/** @typedef {import("micromark-util-types").Token} Token */
|
|
20
|
-
/** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
|
|
21
|
-
/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
|
|
22
|
-
/** @typedef {import("./micromark-types.d.mts")} */
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets a modified micromark-extension-directive without support for inline directives.
|
|
26
|
-
*
|
|
27
|
-
* @see {@link https://github.com/DavidAnson/markdownlint/issues/2080}
|
|
28
|
-
* @returns {Extension} Modified implementation.
|
|
29
|
-
*/
|
|
30
|
-
function directiveNoInline() {
|
|
31
|
-
const extension = {
|
|
32
|
-
...directive()
|
|
33
|
-
};
|
|
34
|
-
delete extension.text;
|
|
35
|
-
return extension;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Gets the Markdown text for a Micromark token.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} markdown Markdown content.
|
|
42
|
-
* @param {Token} token Micromark token.
|
|
43
|
-
* @returns {string} Token text.
|
|
44
|
-
*/
|
|
45
|
-
function getText(markdown, token) {
|
|
46
|
-
return markdown.slice(token.start.offset, token.end.offset);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Parse options.
|
|
51
|
-
*
|
|
52
|
-
* @typedef {Object} ParseOptions
|
|
53
|
-
* @property {boolean} [freezeTokens] Whether to freeze output Tokens.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Parses a Markdown document and returns Micromark events.
|
|
58
|
-
*
|
|
59
|
-
* @param {string} markdown Markdown document.
|
|
60
|
-
* @param {MicromarkParseOptions} [micromarkParseOptions] Options for micromark.
|
|
61
|
-
* @returns {Event[]} Micromark events.
|
|
62
|
-
*/
|
|
63
|
-
export function getEvents(
|
|
64
|
-
markdown,
|
|
65
|
-
micromarkParseOptions = {}
|
|
66
|
-
) {
|
|
67
|
-
// Customize extensions list to add useful extensions
|
|
68
|
-
const extensions = [
|
|
69
|
-
directiveNoInline(),
|
|
70
|
-
gfmAutolinkLiteral(),
|
|
71
|
-
gfmFootnote(),
|
|
72
|
-
gfmTable(),
|
|
73
|
-
math(),
|
|
74
|
-
...(micromarkParseOptions.extensions || [])
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
// // Shim labelEnd to identify undefined link labels
|
|
78
|
-
/** @type {Event[][]} */
|
|
79
|
-
const artificialEventLists = [];
|
|
80
|
-
const tokenizeOriginal = labelEnd.tokenize;
|
|
81
|
-
|
|
82
|
-
/** @type {Tokenizer} */
|
|
83
|
-
function tokenizeShim(effects, okOriginal, nokOriginal) {
|
|
84
|
-
// eslint-disable-next-line consistent-this, no-invalid-this, unicorn/no-this-assignment, unicorn/no-this-outside-of-class
|
|
85
|
-
const tokenizeContext = this;
|
|
86
|
-
const events = tokenizeContext.events;
|
|
87
|
-
|
|
88
|
-
/** @type {State} */
|
|
89
|
-
const nokShim = (code) => {
|
|
90
|
-
// Find start of label (image or link)
|
|
91
|
-
let indexStart = events.length;
|
|
92
|
-
while (--indexStart >= 0) {
|
|
93
|
-
const event = events[indexStart];
|
|
94
|
-
const [ kind, token ] = event;
|
|
95
|
-
if (kind === "enter") {
|
|
96
|
-
const { type } = token;
|
|
97
|
-
if ((type === "labelImage") || (type === "labelLink")) {
|
|
98
|
-
// Found it
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// If found...
|
|
105
|
-
if (indexStart >= 0) {
|
|
106
|
-
// Create artificial enter/exit events and replicate all data/lineEnding events within
|
|
107
|
-
const eventStart = events[indexStart];
|
|
108
|
-
const [ , eventStartToken ] = eventStart;
|
|
109
|
-
const eventEnd = events[events.length - 1];
|
|
110
|
-
const [ , eventEndToken ] = eventEnd;
|
|
111
|
-
/** @type {Token} */
|
|
112
|
-
const undefinedReferenceType = {
|
|
113
|
-
"type": "undefinedReferenceShortcut",
|
|
114
|
-
"start": eventStartToken.start,
|
|
115
|
-
"end": eventEndToken.end
|
|
116
|
-
};
|
|
117
|
-
/** @type {Token} */
|
|
118
|
-
const undefinedReference = {
|
|
119
|
-
"type": "undefinedReference",
|
|
120
|
-
"start": eventStartToken.start,
|
|
121
|
-
"end": eventEndToken.end
|
|
122
|
-
};
|
|
123
|
-
const eventsToReplicate = events
|
|
124
|
-
.slice(indexStart)
|
|
125
|
-
.filter((event) => {
|
|
126
|
-
const [ , eventToken ] = event;
|
|
127
|
-
const { type } = eventToken;
|
|
128
|
-
return (type === "data") || (type === "lineEnding");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Determine the type of the undefined reference
|
|
132
|
-
const previousUndefinedEvent = (artificialEventLists.length > 0) && artificialEventLists[artificialEventLists.length - 1][0];
|
|
133
|
-
const previousUndefinedToken = previousUndefinedEvent && previousUndefinedEvent[1];
|
|
134
|
-
if (
|
|
135
|
-
previousUndefinedToken &&
|
|
136
|
-
(previousUndefinedToken.end.line === undefinedReferenceType.start.line) &&
|
|
137
|
-
(previousUndefinedToken.end.column === undefinedReferenceType.start.column)
|
|
138
|
-
) {
|
|
139
|
-
// Previous undefined reference event is immediately before this one
|
|
140
|
-
if (eventsToReplicate.length === 0) {
|
|
141
|
-
// The pair represent a collapsed reference (ex: [...][])
|
|
142
|
-
previousUndefinedToken.type = "undefinedReferenceCollapsed";
|
|
143
|
-
previousUndefinedToken.end = eventEndToken.end;
|
|
144
|
-
} else {
|
|
145
|
-
// The pair represent a full reference (ex: [...][...])
|
|
146
|
-
undefinedReferenceType.type = "undefinedReferenceFull";
|
|
147
|
-
undefinedReferenceType.start = previousUndefinedToken.start;
|
|
148
|
-
artificialEventLists.pop();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Create artificial event list and replicate content
|
|
153
|
-
const text = eventsToReplicate
|
|
154
|
-
.filter((event) => event[0] === "enter")
|
|
155
|
-
.map((event) => getText(markdown, event[1]))
|
|
156
|
-
.join("")
|
|
157
|
-
.trim();
|
|
158
|
-
if ((text.length > 0) && !text.includes("]")) {
|
|
159
|
-
/** @type {Event[]} */
|
|
160
|
-
const artificialEvents = [
|
|
161
|
-
[ "enter", undefinedReferenceType, tokenizeContext ],
|
|
162
|
-
[ "enter", undefinedReference, tokenizeContext ]
|
|
163
|
-
];
|
|
164
|
-
for (const event of eventsToReplicate) {
|
|
165
|
-
const [ kind, token ] = event;
|
|
166
|
-
// Copy token because the current object will get modified by the parser
|
|
167
|
-
artificialEvents.push([ kind, { ...token }, tokenizeContext ]);
|
|
168
|
-
}
|
|
169
|
-
artificialEvents.push(
|
|
170
|
-
[ "exit", undefinedReference, tokenizeContext ],
|
|
171
|
-
[ "exit", undefinedReferenceType, tokenizeContext ]
|
|
172
|
-
);
|
|
173
|
-
artificialEventLists.push(artificialEvents);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Continue with original behavior
|
|
178
|
-
return nokOriginal(code);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// Shim nok handler of labelEnd's tokenize
|
|
182
|
-
return tokenizeOriginal.call(tokenizeContext, effects, okOriginal, nokShim);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
// Shim labelEnd behavior to detect undefined references
|
|
187
|
-
labelEnd.tokenize = tokenizeShim;
|
|
188
|
-
|
|
189
|
-
// Use micromark to parse document into Events
|
|
190
|
-
const encoding = undefined;
|
|
191
|
-
const eol = true;
|
|
192
|
-
const parseContext = micromarkParse({ ...micromarkParseOptions, extensions });
|
|
193
|
-
const chunks = micromarkPreprocess()(markdown, encoding, eol);
|
|
194
|
-
const events = micromarkPostprocess(parseContext.document().write(chunks));
|
|
195
|
-
|
|
196
|
-
// Append artificial events and return all events
|
|
197
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
198
|
-
return events.concat(...artificialEventLists);
|
|
199
|
-
} finally {
|
|
200
|
-
// Restore shimmed labelEnd behavior
|
|
201
|
-
labelEnd.tokenize = tokenizeOriginal;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Parses a Markdown document and returns micromark tokens (internal).
|
|
207
|
-
*
|
|
208
|
-
* @param {string} markdown Markdown document.
|
|
209
|
-
* @param {ParseOptions} [parseOptions] Options.
|
|
210
|
-
* @param {MicromarkParseOptions} [micromarkParseOptions] Options for micromark.
|
|
211
|
-
* @param {number} [lineDelta] Offset for start/end line.
|
|
212
|
-
* @param {MicromarkToken} [ancestor] Parent of top-most tokens.
|
|
213
|
-
* @returns {MicromarkToken[]} Micromark tokens.
|
|
214
|
-
*/
|
|
215
|
-
function parseInternal(
|
|
216
|
-
markdown,
|
|
217
|
-
parseOptions = {},
|
|
218
|
-
micromarkParseOptions = {},
|
|
219
|
-
lineDelta = 0,
|
|
220
|
-
ancestor = undefined
|
|
221
|
-
) {
|
|
222
|
-
// Get options
|
|
223
|
-
const freezeTokens = Boolean(parseOptions.freezeTokens);
|
|
224
|
-
|
|
225
|
-
// Use micromark to parse document into Events
|
|
226
|
-
const events = getEvents(markdown, micromarkParseOptions);
|
|
227
|
-
|
|
228
|
-
// Create Token objects
|
|
229
|
-
/** @type {MicromarkToken[]} */
|
|
230
|
-
const document = [];
|
|
231
|
-
/** @type {MicromarkToken[]} */
|
|
232
|
-
let flatTokens = [];
|
|
233
|
-
/** @type {MicromarkToken} */
|
|
234
|
-
const root = {
|
|
235
|
-
"type": "data",
|
|
236
|
-
"startLine": -1,
|
|
237
|
-
"startColumn": -1,
|
|
238
|
-
"endLine": -1,
|
|
239
|
-
"endColumn": -1,
|
|
240
|
-
"text": "ROOT",
|
|
241
|
-
"children": document,
|
|
242
|
-
"parent": null
|
|
243
|
-
};
|
|
244
|
-
const history = [ root ];
|
|
245
|
-
let current = root;
|
|
246
|
-
/** @type {MicromarkParseOptions | null} */
|
|
247
|
-
let reparseOptions = null;
|
|
248
|
-
let lines = null;
|
|
249
|
-
let skipHtmlFlowChildren = false;
|
|
250
|
-
for (const event of events) {
|
|
251
|
-
const [ kind, token ] = event;
|
|
252
|
-
const { type, start, end } = token;
|
|
253
|
-
const { "column": startColumn, "line": startLine } = start;
|
|
254
|
-
const { "column": endColumn, "line": endLine } = end;
|
|
255
|
-
const text = getText(markdown, token);
|
|
256
|
-
if ((kind === "enter") && !skipHtmlFlowChildren) {
|
|
257
|
-
const previous = current;
|
|
258
|
-
history.push(previous);
|
|
259
|
-
current = {
|
|
260
|
-
type,
|
|
261
|
-
"startLine": startLine + lineDelta,
|
|
262
|
-
startColumn,
|
|
263
|
-
"endLine": endLine + lineDelta,
|
|
264
|
-
endColumn,
|
|
265
|
-
text,
|
|
266
|
-
"children": [],
|
|
267
|
-
"parent": ((previous === root) ? (ancestor || null) : previous)
|
|
268
|
-
};
|
|
269
|
-
if (ancestor) {
|
|
270
|
-
Object.defineProperty(current, htmlFlowSymbol, { "value": true });
|
|
271
|
-
}
|
|
272
|
-
previous.children.push(current);
|
|
273
|
-
flatTokens.push(current);
|
|
274
|
-
if ((current.type === "htmlFlow") && !isHtmlFlowComment(current)) {
|
|
275
|
-
skipHtmlFlowChildren = true;
|
|
276
|
-
if (!reparseOptions || !lines) {
|
|
277
|
-
reparseOptions = {
|
|
278
|
-
...micromarkParseOptions,
|
|
279
|
-
"extensions": [
|
|
280
|
-
{
|
|
281
|
-
"disable": {
|
|
282
|
-
"null": [ "codeIndented", "htmlFlow" ]
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
]
|
|
286
|
-
};
|
|
287
|
-
lines = markdown.split(newlineRe);
|
|
288
|
-
}
|
|
289
|
-
const reparseMarkdown = lines
|
|
290
|
-
.slice(current.startLine - 1, current.endLine)
|
|
291
|
-
.join("\n");
|
|
292
|
-
const tokens = parseInternal(
|
|
293
|
-
reparseMarkdown,
|
|
294
|
-
parseOptions,
|
|
295
|
-
reparseOptions,
|
|
296
|
-
current.startLine - 1,
|
|
297
|
-
current
|
|
298
|
-
);
|
|
299
|
-
current.children = tokens;
|
|
300
|
-
// Avoid stack overflow of Array.push(...spread)
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
303
|
-
flatTokens = flatTokens.concat(tokens[flatTokensSymbol]);
|
|
304
|
-
}
|
|
305
|
-
} else if (kind === "exit") {
|
|
306
|
-
if (type === "htmlFlow") {
|
|
307
|
-
skipHtmlFlowChildren = false;
|
|
308
|
-
}
|
|
309
|
-
if (!skipHtmlFlowChildren) {
|
|
310
|
-
if (freezeTokens) {
|
|
311
|
-
Object.freeze(current.children);
|
|
312
|
-
Object.freeze(current);
|
|
313
|
-
}
|
|
314
|
-
// @ts-ignore
|
|
315
|
-
current = history.pop();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Return document
|
|
321
|
-
Object.defineProperty(document, flatTokensSymbol, { "value": flatTokens });
|
|
322
|
-
if (freezeTokens) {
|
|
323
|
-
Object.freeze(document);
|
|
324
|
-
}
|
|
325
|
-
return document;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Parses a Markdown document and returns micromark tokens.
|
|
330
|
-
*
|
|
331
|
-
* @param {string} markdown Markdown document.
|
|
332
|
-
* @param {ParseOptions} [parseOptions] Options.
|
|
333
|
-
* @returns {MicromarkToken[]} Micromark tokens.
|
|
334
|
-
*/
|
|
335
|
-
export function parse(markdown, parseOptions) {
|
|
336
|
-
return parseInternal(markdown, parseOptions);
|
|
337
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
|
|
3
|
-
// Augment TokenTypeMap with markdownlint-specific types.
|
|
4
|
-
declare module "micromark-util-types" {
|
|
5
|
-
export interface TokenTypeMap {
|
|
6
|
-
undefinedReference: "undefinedReference"
|
|
7
|
-
undefinedReferenceCollapsed: "undefinedReferenceCollapsed"
|
|
8
|
-
undefinedReferenceFull: "undefinedReferenceFull"
|
|
9
|
-
undefinedReferenceShortcut: "undefinedReferenceShortcut"
|
|
10
|
-
}
|
|
11
|
-
}
|