markdownlint 0.32.1 → 0.34.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 +18 -0
- package/CONTRIBUTING.md +4 -3
- package/README.md +6 -0
- package/demo/markdownlint-browser.js +3866 -3564
- package/doc/CustomRules.md +14 -7
- package/doc/Rules.md +139 -12
- package/doc/md013.md +8 -7
- package/doc/md024.md +2 -5
- package/doc/md049.md +3 -0
- package/doc/md050.md +3 -0
- package/doc/md051.md +26 -0
- package/doc/md055.md +54 -0
- package/doc/md056.md +37 -0
- package/helpers/README.md +5 -3
- package/helpers/helpers.js +5 -5
- package/helpers/micromark.cjs +46 -27
- package/helpers/package.json +2 -2
- package/lib/configuration.d.ts +136 -110
- package/lib/constants.js +1 -1
- package/lib/markdownlint.d.ts +79 -6
- package/lib/markdownlint.js +95 -21
- package/lib/md001.js +3 -0
- package/lib/md003.js +3 -0
- package/lib/md004.js +3 -0
- package/lib/md005.js +12 -4
- package/lib/md007.js +17 -11
- package/lib/md009.js +3 -0
- package/lib/md010.js +4 -1
- package/lib/md011.js +3 -0
- package/lib/md012.js +3 -0
- package/lib/md013.js +3 -0
- package/lib/md014.js +4 -0
- package/lib/md018.js +4 -0
- package/lib/md019.js +3 -0
- package/lib/md020.js +3 -0
- package/lib/md021.js +3 -0
- package/lib/md022.js +10 -2
- package/lib/md023.js +3 -0
- package/lib/md024.js +11 -4
- package/lib/md025.js +3 -0
- package/lib/md026.js +11 -7
- package/lib/md027.js +29 -43
- package/lib/md028.js +31 -14
- package/lib/md029.js +3 -0
- package/lib/md030.js +9 -4
- package/lib/md031.js +3 -0
- package/lib/md032.js +12 -14
- package/lib/md033.js +9 -2
- package/lib/md034.js +31 -5
- package/lib/md035.js +9 -2
- package/lib/md036.js +33 -39
- package/lib/md037.js +10 -2
- package/lib/md038.js +27 -18
- package/lib/md039.js +4 -0
- package/lib/md040.js +26 -21
- package/lib/md041.js +21 -26
- package/lib/md042.js +4 -0
- package/lib/md043.js +3 -0
- package/lib/md044.js +9 -1
- package/lib/md045.js +10 -3
- package/lib/md046.js +14 -7
- package/lib/md047.js +5 -2
- package/lib/md048.js +26 -13
- package/lib/md049-md050.js +26 -7
- package/lib/md051.js +20 -16
- package/lib/md052.js +3 -0
- package/lib/md053.js +3 -0
- package/lib/md054.js +10 -5
- package/lib/md055.js +80 -0
- package/lib/md056.js +52 -0
- package/lib/rules.js +5 -3
- package/package.json +26 -32
- package/schema/.markdownlint.jsonc +58 -51
- package/schema/.markdownlint.yaml +56 -50
- package/schema/ValidatingConfiguration.md +28 -0
- package/schema/markdownlint-config-schema.json +165 -113
package/helpers/micromark.cjs
CHANGED
|
@@ -4,27 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
const {
|
|
7
|
-
gfmAutolinkLiteral, gfmFootnote, gfmTable, math,
|
|
8
|
-
preprocess
|
|
7
|
+
directive, gfmAutolinkLiteral, gfmFootnote, gfmTable, math,
|
|
8
|
+
parse, postprocess, preprocess
|
|
9
9
|
// @ts-ignore
|
|
10
10
|
} = require("markdownlint-micromark");
|
|
11
11
|
const { newLineRe } = require("./shared.js");
|
|
12
12
|
|
|
13
13
|
const flatTokensSymbol = Symbol("flat-tokens");
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @property {string} type Token type.
|
|
20
|
-
* @property {number} startLine Start line (1-based).
|
|
21
|
-
* @property {number} startColumn Start column (1-based).
|
|
22
|
-
* @property {number} endLine End line (1-based).
|
|
23
|
-
* @property {number} endColumn End column (1-based).
|
|
24
|
-
* @property {string} text Token text.
|
|
25
|
-
* @property {Token[]} children Child tokens.
|
|
26
|
-
* @property {Token | null} parent Parent token.
|
|
27
|
-
*/
|
|
15
|
+
/** @typedef {import("markdownlint-micromark").Event} Event */
|
|
16
|
+
/** @typedef {import("markdownlint-micromark").ParseOptions} ParseOptions */
|
|
17
|
+
/** @typedef {import("markdownlint-micromark").TokenType} TokenType */
|
|
18
|
+
/** @typedef {import("../lib/markdownlint.js").MicromarkToken} Token */
|
|
28
19
|
|
|
29
20
|
/**
|
|
30
21
|
* Returns whether a token is an htmlFlow type containing an HTML comment.
|
|
@@ -59,9 +50,9 @@ function isHtmlFlowComment(token) {
|
|
|
59
50
|
* Parses a Markdown document and returns Micromark events.
|
|
60
51
|
*
|
|
61
52
|
* @param {string} markdown Markdown document.
|
|
62
|
-
* @param {
|
|
53
|
+
* @param {ParseOptions} [micromarkOptions] Options for micromark.
|
|
63
54
|
* @param {boolean} [referencesDefined] Treat references as defined.
|
|
64
|
-
* @returns {
|
|
55
|
+
* @returns {Event[]} Micromark events.
|
|
65
56
|
*/
|
|
66
57
|
function getMicromarkEvents(
|
|
67
58
|
markdown,
|
|
@@ -72,6 +63,7 @@ function getMicromarkEvents(
|
|
|
72
63
|
// Customize options object to add useful extensions
|
|
73
64
|
micromarkOptions.extensions = micromarkOptions.extensions || [];
|
|
74
65
|
micromarkOptions.extensions.push(
|
|
66
|
+
directive(),
|
|
75
67
|
gfmAutolinkLiteral(),
|
|
76
68
|
gfmFootnote(),
|
|
77
69
|
gfmTable(),
|
|
@@ -95,7 +87,7 @@ function getMicromarkEvents(
|
|
|
95
87
|
* Parses a Markdown document and returns (frozen) tokens.
|
|
96
88
|
*
|
|
97
89
|
* @param {string} markdown Markdown document.
|
|
98
|
-
* @param {
|
|
90
|
+
* @param {ParseOptions} micromarkOptions Options for micromark.
|
|
99
91
|
* @param {boolean} referencesDefined Treat references as defined.
|
|
100
92
|
* @param {number} lineDelta Offset to apply to start/end line.
|
|
101
93
|
* @param {Token} [ancestor] Parent of top-most tokens.
|
|
@@ -118,7 +110,7 @@ function micromarkParseWithOffset(
|
|
|
118
110
|
let flatTokens = [];
|
|
119
111
|
/** @type {Token} */
|
|
120
112
|
const root = {
|
|
121
|
-
"type": "
|
|
113
|
+
"type": "data",
|
|
122
114
|
"startLine": -1,
|
|
123
115
|
"startColumn": -1,
|
|
124
116
|
"endLine": -1,
|
|
@@ -129,6 +121,8 @@ function micromarkParseWithOffset(
|
|
|
129
121
|
};
|
|
130
122
|
const history = [ root ];
|
|
131
123
|
let current = root;
|
|
124
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
125
|
+
/** @type ParseOptions | null */
|
|
132
126
|
let reparseOptions = null;
|
|
133
127
|
let lines = null;
|
|
134
128
|
let skipHtmlFlowChildren = false;
|
|
@@ -206,7 +200,7 @@ function micromarkParseWithOffset(
|
|
|
206
200
|
* Parses a Markdown document and returns (frozen) tokens.
|
|
207
201
|
*
|
|
208
202
|
* @param {string} markdown Markdown document.
|
|
209
|
-
* @param {
|
|
203
|
+
* @param {ParseOptions} [micromarkOptions] Options for micromark.
|
|
210
204
|
* @param {boolean} [referencesDefined] Treat references as defined.
|
|
211
205
|
* @returns {Token[]} Micromark tokens (frozen).
|
|
212
206
|
*/
|
|
@@ -282,7 +276,7 @@ function filterByPredicate(tokens, allowed, transformChildren) {
|
|
|
282
276
|
* Filter a list of Micromark tokens by type.
|
|
283
277
|
*
|
|
284
278
|
* @param {Token[]} tokens Micromark tokens.
|
|
285
|
-
* @param {
|
|
279
|
+
* @param {TokenType[]} types Types to allow.
|
|
286
280
|
* @returns {Token[]} Filtered tokens.
|
|
287
281
|
*/
|
|
288
282
|
function filterByTypes(tokens, types) {
|
|
@@ -315,11 +309,19 @@ function getHeadingLevel(heading) {
|
|
|
315
309
|
return level;
|
|
316
310
|
}
|
|
317
311
|
|
|
312
|
+
/**
|
|
313
|
+
* HTML tag information.
|
|
314
|
+
*
|
|
315
|
+
* @typedef {Object} HtmlTagInfo
|
|
316
|
+
* @property {boolean} close True iff close tag.
|
|
317
|
+
* @property {string} name Tag name.
|
|
318
|
+
*/
|
|
319
|
+
|
|
318
320
|
/**
|
|
319
321
|
* Gets information about the tag in an HTML token.
|
|
320
322
|
*
|
|
321
323
|
* @param {Token} token Micromark token.
|
|
322
|
-
* @returns {
|
|
324
|
+
* @returns {HtmlTagInfo | null} HTML tag information.
|
|
323
325
|
*/
|
|
324
326
|
function getHtmlTagInfo(token) {
|
|
325
327
|
const htmlTagNameRe = /^<([^!>][^/\s>]*)/;
|
|
@@ -341,7 +343,7 @@ function getHtmlTagInfo(token) {
|
|
|
341
343
|
* Gets the nearest parent of the specified type for a Micromark token.
|
|
342
344
|
*
|
|
343
345
|
* @param {Token} token Micromark token.
|
|
344
|
-
* @param {
|
|
346
|
+
* @param {TokenType[]} types Types to allow.
|
|
345
347
|
* @returns {Token | null} Parent token.
|
|
346
348
|
*/
|
|
347
349
|
function getTokenParentOfType(token, types) {
|
|
@@ -357,7 +359,7 @@ function getTokenParentOfType(token, types) {
|
|
|
357
359
|
* Get the text of the first match from a list of Micromark tokens by type.
|
|
358
360
|
*
|
|
359
361
|
* @param {Token[]} tokens Micromark tokens.
|
|
360
|
-
* @param {
|
|
362
|
+
* @param {TokenType} type Type to match.
|
|
361
363
|
* @returns {string | null} Text of token.
|
|
362
364
|
*/
|
|
363
365
|
function getTokenTextByType(tokens, type) {
|
|
@@ -379,8 +381,8 @@ function inHtmlFlow(token) {
|
|
|
379
381
|
* Determines a list of Micromark tokens matches and returns a subset.
|
|
380
382
|
*
|
|
381
383
|
* @param {Token[]} tokens Micromark tokens.
|
|
382
|
-
* @param {
|
|
383
|
-
* @param {
|
|
384
|
+
* @param {TokenType[]} matchTypes Types to match.
|
|
385
|
+
* @param {TokenType[]} [resultTypes] Types to return.
|
|
384
386
|
* @returns {Token[] | null} Matching tokens.
|
|
385
387
|
*/
|
|
386
388
|
function matchAndGetTokensByType(tokens, matchTypes, resultTypes) {
|
|
@@ -404,13 +406,28 @@ function matchAndGetTokensByType(tokens, matchTypes, resultTypes) {
|
|
|
404
406
|
* Returns the specified token iff it is of the desired type.
|
|
405
407
|
*
|
|
406
408
|
* @param {Token} token Micromark token candidate.
|
|
407
|
-
* @param {
|
|
409
|
+
* @param {TokenType} type Desired type.
|
|
408
410
|
* @returns {Token | null} Token instance.
|
|
409
411
|
*/
|
|
410
412
|
function tokenIfType(token, type) {
|
|
411
413
|
return (token && (token.type === type)) ? token : null;
|
|
412
414
|
}
|
|
413
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Set containing token types that do not contain content.
|
|
418
|
+
*
|
|
419
|
+
* @type {Set<TokenType>}
|
|
420
|
+
*/
|
|
421
|
+
const nonContentTokens = new Set([
|
|
422
|
+
"blockQuoteMarker",
|
|
423
|
+
"blockQuotePrefix",
|
|
424
|
+
"blockQuotePrefixWhitespace",
|
|
425
|
+
"lineEnding",
|
|
426
|
+
"lineEndingBlank",
|
|
427
|
+
"linePrefix",
|
|
428
|
+
"listItemIndent"
|
|
429
|
+
]);
|
|
430
|
+
|
|
414
431
|
module.exports = {
|
|
415
432
|
"parse": micromarkParse,
|
|
416
433
|
filterByPredicate,
|
|
@@ -421,6 +438,8 @@ module.exports = {
|
|
|
421
438
|
getTokenParentOfType,
|
|
422
439
|
getTokenTextByType,
|
|
423
440
|
inHtmlFlow,
|
|
441
|
+
isHtmlFlowComment,
|
|
424
442
|
matchAndGetTokensByType,
|
|
443
|
+
nonContentTokens,
|
|
425
444
|
tokenIfType
|
|
426
445
|
};
|
package/helpers/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-rule-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "A collection of markdownlint helper functions for custom rules",
|
|
5
5
|
"main": "./helpers.js",
|
|
6
6
|
"exports": "./helpers.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
|
15
15
|
"funding": "https://github.com/sponsors/DavidAnson",
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"markdownlint-micromark": "0.1.2"
|