markdownlint 0.33.0 → 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.
Files changed (70) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CONTRIBUTING.md +4 -3
  3. package/demo/markdownlint-browser.js +2730 -1541
  4. package/doc/CustomRules.md +14 -7
  5. package/doc/Rules.md +40 -7
  6. package/doc/md013.md +8 -7
  7. package/doc/md049.md +3 -0
  8. package/doc/md050.md +3 -0
  9. package/doc/md051.md +26 -0
  10. package/helpers/README.md +5 -3
  11. package/helpers/helpers.js +5 -5
  12. package/helpers/micromark.cjs +45 -27
  13. package/helpers/package.json +2 -2
  14. package/lib/configuration.d.ts +102 -102
  15. package/lib/constants.js +1 -1
  16. package/lib/markdownlint.d.ts +79 -6
  17. package/lib/markdownlint.js +95 -20
  18. package/lib/md001.js +3 -0
  19. package/lib/md003.js +3 -0
  20. package/lib/md004.js +3 -0
  21. package/lib/md005.js +9 -1
  22. package/lib/md007.js +14 -9
  23. package/lib/md009.js +3 -0
  24. package/lib/md010.js +4 -1
  25. package/lib/md011.js +3 -0
  26. package/lib/md012.js +3 -0
  27. package/lib/md013.js +3 -0
  28. package/lib/md014.js +4 -0
  29. package/lib/md018.js +4 -0
  30. package/lib/md019.js +3 -0
  31. package/lib/md020.js +3 -0
  32. package/lib/md021.js +3 -0
  33. package/lib/md022.js +10 -2
  34. package/lib/md023.js +3 -0
  35. package/lib/md024.js +3 -0
  36. package/lib/md025.js +3 -0
  37. package/lib/md026.js +9 -5
  38. package/lib/md027.js +29 -43
  39. package/lib/md028.js +31 -14
  40. package/lib/md029.js +3 -0
  41. package/lib/md030.js +9 -4
  42. package/lib/md031.js +3 -0
  43. package/lib/md032.js +12 -14
  44. package/lib/md033.js +9 -2
  45. package/lib/md034.js +31 -5
  46. package/lib/md035.js +9 -2
  47. package/lib/md036.js +33 -39
  48. package/lib/md037.js +10 -2
  49. package/lib/md038.js +10 -3
  50. package/lib/md039.js +4 -0
  51. package/lib/md040.js +26 -21
  52. package/lib/md041.js +21 -26
  53. package/lib/md042.js +4 -0
  54. package/lib/md043.js +3 -0
  55. package/lib/md044.js +9 -1
  56. package/lib/md045.js +10 -3
  57. package/lib/md046.js +14 -7
  58. package/lib/md047.js +5 -2
  59. package/lib/md048.js +26 -13
  60. package/lib/md049-md050.js +26 -7
  61. package/lib/md051.js +20 -16
  62. package/lib/md052.js +3 -0
  63. package/lib/md053.js +3 -0
  64. package/lib/md054.js +10 -5
  65. package/lib/md055.js +9 -1
  66. package/lib/md056.js +9 -1
  67. package/package.json +17 -22
  68. package/schema/.markdownlint.jsonc +50 -50
  69. package/schema/.markdownlint.yaml +50 -50
  70. package/schema/markdownlint-config-schema.json +104 -104
@@ -28,11 +28,13 @@ the parsed input and a function to log any violations.
28
28
  A simple rule implementation looks like:
29
29
 
30
30
  ```javascript
31
+ /** @type import("markdownlint").Rule */
31
32
  module.exports = {
32
33
  "names": [ "any-blockquote" ],
33
34
  "description": "Rule that reports an error for any blockquote",
34
35
  "information": new URL("https://example.com/rules/any-blockquote"),
35
36
  "tags": [ "test" ],
37
+ "parser": "markdownit",
36
38
  "function": function rule(params, onError) {
37
39
  params.parsers.markdownit.tokens.filter(function filterToken(token) {
38
40
  return token.type === "blockquote_open";
@@ -48,8 +50,7 @@ module.exports = {
48
50
  };
49
51
  ```
50
52
 
51
- A rule is implemented as an `Object` with one optional and four required
52
- properties:
53
+ A rule is implemented as an `Object`:
53
54
 
54
55
  - `names` is a required `Array` of `String` values that identify the rule in
55
56
  output messages and config.
@@ -59,6 +60,9 @@ properties:
59
60
  about the rule.
60
61
  - `tags` is a required `Array` of `String` values that groups related rules for
61
62
  easier customization.
63
+ - `parser` is a required `String` value `"markdownit" | "none"` that specifies
64
+ the parser data used via `params.parsers` (see below).
65
+ - Note: The value `"micromark"` is valid but is NOT currently supported.
62
66
  - `asynchronous` is an optional `Boolean` value that indicates whether the rule
63
67
  returns a `Promise` and runs asynchronously.
64
68
  - `function` is a required `Function` that implements the rule and is passed two
@@ -66,8 +70,13 @@ properties:
66
70
  - `params` is an `Object` with properties that describe the content being
67
71
  analyzed:
68
72
  - `name` is a `String` that identifies the input file/string.
69
- - `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token] with
70
- added `line` and `lineNumber` properties.
73
+ - `parsers` is an `Object` with properties corresponding to the value of
74
+ `parser` in the rule definition (see above).
75
+ - `markdownit` is an `Object` that provides access to output from the
76
+ [`markdown-it`][markdown-it] parser.
77
+ - `tokens` is an `Array` of [`markdown-it` `Token`s][markdown-it-token]
78
+ with added `line` and `lineNumber` properties. (This property was
79
+ previously on the `params` object.)
71
80
  - `lines` is an `Array` of `String` values corresponding to the lines of the
72
81
  input file/string.
73
82
  - `frontMatterLines` is an `Array` of `String` values corresponding to any
@@ -122,7 +131,6 @@ exception.
122
131
  - [Code for all `markdownlint` built-in rules][lib]
123
132
  - [Package configuration for publishing to npm][test-rules-npm]
124
133
  - Packages should export a single rule object or an `Array` of rule objects
125
- - [Custom rules from the axibase/docs-util repository][docs-util]
126
134
  - [Custom rules from the webhintio/hint repository][hint]
127
135
 
128
136
  ## References
@@ -145,7 +153,7 @@ Yields the `params` object:
145
153
  ```json
146
154
  {
147
155
  "name": "doc/example.md",
148
- "tokens": [
156
+ "parsers.markdownit.tokens": [
149
157
  {
150
158
  "type": "heading_open",
151
159
  "tag": "h1",
@@ -364,7 +372,6 @@ Yields the `params` object:
364
372
  ```
365
373
 
366
374
  [commonmark]: https://commonmark.org/
367
- [docs-util]: https://github.com/axibase/docs-util/tree/master/linting-rules
368
375
  [hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
369
376
  [lib]: ../lib
370
377
  [markdown-it]: https://github.com/markdown-it/markdown-it
package/doc/Rules.md CHANGED
@@ -495,12 +495,12 @@ For example (assuming normal behavior):
495
495
  ```markdown
496
496
  IF THIS LINE IS THE MAXIMUM LENGTH
497
497
  This line is okay because there are-no-spaces-beyond-that-length
498
- And this line is a violation because there are
499
- This-line-is-also-okay-because-there-are-no-spaces
498
+ This line is a violation because there are spaces beyond that length
499
+ This-line-is-okay-because-there-are-no-spaces-anywhere-within
500
500
  ```
501
501
 
502
- In `strict` or `stern` modes, the two middle lines above are a violation. The
503
- third line is a violation in `strict` mode but allowed in `stern` mode.
502
+ In `strict` mode, the last three lines above are all violations. In `stern`
503
+ mode, the middle two lines above are both violations, but the last is okay.
504
504
 
505
505
  You have the option to exclude this rule for code blocks, tables, or headings.
506
506
  To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
@@ -509,9 +509,10 @@ Code blocks are included in this rule by default since it is often a
509
509
  requirement for document readability, and tentatively compatible with code
510
510
  rules. Still, some languages do not lend themselves to short lines.
511
511
 
512
- Lines with link/image reference definitions are always exempted from this rule
513
- (even in `strict` mode) because there is generally no way to split such lines
514
- without breaking the URL.
512
+ Lines with link/image reference definitions and standalone lines (i.e., not part
513
+ of a paragraph) with only a link/image (possibly using (strong) emphasis) are
514
+ always exempted from this rule (even in `strict` mode) because there is often no
515
+ way to split such lines without breaking the URL.
515
516
 
516
517
  Rationale: Extremely long lines can be difficult to work with in some editors.
517
518
  More information: <https://cirosantilli.com/markdown-style-guide#line-wrapping>.
@@ -2035,6 +2036,9 @@ To fix this issue, use the configured emphasis style throughout the document:
2035
2036
  The configured emphasis style can be a specific symbol to use ("asterisk",
2036
2037
  "underscore"), or can require that usage be consistent within the document.
2037
2038
 
2039
+ Note: Emphasis within a word is restricted to "asterisk" in order to avoid
2040
+ unwanted emphasis for words containing internal underscores like_this_one.
2041
+
2038
2042
  Rationale: Consistent formatting makes it easier to understand a document.
2039
2043
 
2040
2044
  <a name="md050"></a>
@@ -2070,6 +2074,9 @@ To fix this issue, use the configured strong style throughout the document:
2070
2074
  The configured strong style can be a specific symbol to use ("asterisk",
2071
2075
  "underscore"), or can require that usage be consistent within the document.
2072
2076
 
2077
+ Note: Emphasis within a word is restricted to "asterisk" in order to avoid
2078
+ unwanted emphasis for words containing internal underscores like_this_one.
2079
+
2073
2080
  Rationale: Consistent formatting makes it easier to understand a document.
2074
2081
 
2075
2082
  <a name="md051"></a>
@@ -2100,6 +2107,16 @@ generated name (see below):
2100
2107
  [Link](#heading-name)
2101
2108
  ```
2102
2109
 
2110
+ Link fragments may be handled case-sensitively, so this rule requires fragments
2111
+ to exactly match the [GitHub heading algorithm][github-heading-algorithm].
2112
+ Therefore, the following example is reported as a violation:
2113
+
2114
+ ```markdown
2115
+ # Heading Name
2116
+
2117
+ [Link](#Heading-Name)
2118
+ ```
2119
+
2103
2120
  Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
2104
2121
  within a heading to provide a specific name (consisting of only lower-case
2105
2122
  letters, numbers, `-`, and `_`):
@@ -2122,6 +2139,21 @@ attribute can be used to define a fragment:
2122
2139
  An `a` tag can be useful in scenarios where a heading is not appropriate or for
2123
2140
  control over the text of the fragment identifier.
2124
2141
 
2142
+ This rule also recognizes the custom fragment syntax used by GitHub to highlight
2143
+ [specific content in a document][github-linking-to-content].
2144
+
2145
+ For example, this link to line 20:
2146
+
2147
+ ```markdown
2148
+ [Link](#L20)
2149
+ ```
2150
+
2151
+ And this link to content starting within line 19 running into line 21:
2152
+
2153
+ ```markdown
2154
+ [Link](#L19C5-L21C11)
2155
+ ```
2156
+
2125
2157
  Rationale: [GitHub section links][github-section-links] are created
2126
2158
  automatically for every heading when Markdown content is displayed on GitHub.
2127
2159
  This makes it easy to link directly to different sections within a document.
@@ -2135,6 +2167,7 @@ append an incrementing integer as needed for uniqueness.
2135
2167
 
2136
2168
  [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
2137
2169
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
2170
+ [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
2138
2171
 
2139
2172
  <a name="md052"></a>
2140
2173
 
package/doc/md013.md CHANGED
@@ -35,12 +35,12 @@ For example (assuming normal behavior):
35
35
  ```markdown
36
36
  IF THIS LINE IS THE MAXIMUM LENGTH
37
37
  This line is okay because there are-no-spaces-beyond-that-length
38
- And this line is a violation because there are
39
- This-line-is-also-okay-because-there-are-no-spaces
38
+ This line is a violation because there are spaces beyond that length
39
+ This-line-is-okay-because-there-are-no-spaces-anywhere-within
40
40
  ```
41
41
 
42
- In `strict` or `stern` modes, the two middle lines above are a violation. The
43
- third line is a violation in `strict` mode but allowed in `stern` mode.
42
+ In `strict` mode, the last three lines above are all violations. In `stern`
43
+ mode, the middle two lines above are both violations, but the last is okay.
44
44
 
45
45
  You have the option to exclude this rule for code blocks, tables, or headings.
46
46
  To do so, set the `code_blocks`, `tables`, or `headings` parameter(s) to false.
@@ -49,9 +49,10 @@ Code blocks are included in this rule by default since it is often a
49
49
  requirement for document readability, and tentatively compatible with code
50
50
  rules. Still, some languages do not lend themselves to short lines.
51
51
 
52
- Lines with link/image reference definitions are always exempted from this rule
53
- (even in `strict` mode) because there is generally no way to split such lines
54
- without breaking the URL.
52
+ Lines with link/image reference definitions and standalone lines (i.e., not part
53
+ of a paragraph) with only a link/image (possibly using (strong) emphasis) are
54
+ always exempted from this rule (even in `strict` mode) because there is often no
55
+ way to split such lines without breaking the URL.
55
56
 
56
57
  Rationale: Extremely long lines can be difficult to work with in some editors.
57
58
  More information: <https://cirosantilli.com/markdown-style-guide#line-wrapping>.
package/doc/md049.md CHANGED
@@ -29,4 +29,7 @@ To fix this issue, use the configured emphasis style throughout the document:
29
29
  The configured emphasis style can be a specific symbol to use ("asterisk",
30
30
  "underscore"), or can require that usage be consistent within the document.
31
31
 
32
+ Note: Emphasis within a word is restricted to "asterisk" in order to avoid
33
+ unwanted emphasis for words containing internal underscores like_this_one.
34
+
32
35
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md050.md CHANGED
@@ -29,4 +29,7 @@ To fix this issue, use the configured strong style throughout the document:
29
29
  The configured strong style can be a specific symbol to use ("asterisk",
30
30
  "underscore"), or can require that usage be consistent within the document.
31
31
 
32
+ Note: Emphasis within a word is restricted to "asterisk" in order to avoid
33
+ unwanted emphasis for words containing internal underscores like_this_one.
34
+
32
35
  Rationale: Consistent formatting makes it easier to understand a document.
package/doc/md051.md CHANGED
@@ -24,6 +24,16 @@ generated name (see below):
24
24
  [Link](#heading-name)
25
25
  ```
26
26
 
27
+ Link fragments may be handled case-sensitively, so this rule requires fragments
28
+ to exactly match the [GitHub heading algorithm][github-heading-algorithm].
29
+ Therefore, the following example is reported as a violation:
30
+
31
+ ```markdown
32
+ # Heading Name
33
+
34
+ [Link](#Heading-Name)
35
+ ```
36
+
27
37
  Alternatively, some platforms allow the syntax `{#named-anchor}` to be used
28
38
  within a heading to provide a specific name (consisting of only lower-case
29
39
  letters, numbers, `-`, and `_`):
@@ -46,6 +56,21 @@ attribute can be used to define a fragment:
46
56
  An `a` tag can be useful in scenarios where a heading is not appropriate or for
47
57
  control over the text of the fragment identifier.
48
58
 
59
+ This rule also recognizes the custom fragment syntax used by GitHub to highlight
60
+ [specific content in a document][github-linking-to-content].
61
+
62
+ For example, this link to line 20:
63
+
64
+ ```markdown
65
+ [Link](#L20)
66
+ ```
67
+
68
+ And this link to content starting within line 19 running into line 21:
69
+
70
+ ```markdown
71
+ [Link](#L19C5-L21C11)
72
+ ```
73
+
49
74
  Rationale: [GitHub section links][github-section-links] are created
50
75
  automatically for every heading when Markdown content is displayed on GitHub.
51
76
  This makes it easy to link directly to different sections within a document.
@@ -59,3 +84,4 @@ append an incrementing integer as needed for uniqueness.
59
84
 
60
85
  [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
61
86
  [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
87
+ [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
package/helpers/README.md CHANGED
@@ -24,10 +24,12 @@ be useful to custom rule authors and may avoid duplicating code.
24
24
  ```javascript
25
25
  const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
26
26
 
27
+ /** @type import("markdownlint").Rule */
27
28
  module.exports = {
28
29
  "names": [ "every-n-lines" ],
29
30
  "description": "Rule that reports an error every N lines",
30
31
  "tags": [ "test" ],
32
+ "parser": "none",
31
33
  "function": (params, onError) => {
32
34
  const n = params.config.n || 2;
33
35
  forEachLine(getLineMetadata(params), (line, lineIndex) => {
@@ -62,9 +64,9 @@ See also: [`markdownlint` built-in rule implementations][lib].
62
64
  *None* - The entire body of code is tested to 100% coverage by the core
63
65
  `markdownlint` project, so there are no additional tests here.
64
66
 
65
- [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/CustomRules.md
67
+ [custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/CustomRules.md
66
68
  [jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
67
- [lib]: https://github.com/DavidAnson/markdownlint/tree/v0.33.0/lib
69
+ [lib]: https://github.com/DavidAnson/markdownlint/tree/v0.34.0/lib
68
70
  [markdown]: https://en.wikipedia.org/wiki/Markdown
69
71
  [markdownlint]: https://github.com/DavidAnson/markdownlint
70
- [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/Rules.md
72
+ [rules]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/Rules.md
@@ -277,7 +277,7 @@ module.exports.fencedCodeBlockStyleFor =
277
277
  * Return the string representation of a emphasis or strong markup character.
278
278
  *
279
279
  * @param {string} markup Emphasis or strong string.
280
- * @returns {string} String representation.
280
+ * @returns {"asterisk" | "underscore"} String representation.
281
281
  */
282
282
  module.exports.emphasisOrStrongStyleFor =
283
283
  function emphasisOrStrongStyleFor(markup) {
@@ -316,7 +316,7 @@ module.exports.headingStyleFor = function headingStyleFor(token) {
316
316
  * Return the string representation of an unordered list marker.
317
317
  *
318
318
  * @param {Object} token MarkdownItToken instance.
319
- * @returns {string} String representation.
319
+ * @returns {"asterisk" | "dash" | "plus"} String representation.
320
320
  */
321
321
  module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
322
322
  switch (token.markup) {
@@ -702,10 +702,10 @@ module.exports.frontMatterHasTitle =
702
702
  /**
703
703
  * Returns an object with information about reference links and images.
704
704
  *
705
- * @param {Object} params RuleParams instance.
705
+ * @param {import("../helpers/micromark.cjs").Token[]} tokens Micromark tokens.
706
706
  * @returns {Object} Reference link/image data.
707
707
  */
708
- function getReferenceLinkImageData(params) {
708
+ function getReferenceLinkImageData(tokens) {
709
709
  const normalizeReference = (s) => s.toLowerCase().trim().replace(/\s+/g, " ");
710
710
  const definitions = new Map();
711
711
  const definitionLineIndices = [];
@@ -714,7 +714,7 @@ function getReferenceLinkImageData(params) {
714
714
  const shortcuts = new Map();
715
715
  const filteredTokens =
716
716
  micromark.filterByTypes(
717
- params.parsers.micromark.tokens,
717
+ tokens,
718
718
  [
719
719
  // definitionLineIndices
720
720
  "definition", "gfmFootnoteDefinition",
@@ -4,27 +4,18 @@
4
4
 
5
5
  // @ts-ignore
6
6
  const {
7
- directive, gfmAutolinkLiteral, gfmFootnote, gfmTable, math, parse,
8
- postprocess, 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
- * Markdown token.
17
- *
18
- * @typedef {Object} Token
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 {Object} [micromarkOptions] Options for micromark.
53
+ * @param {ParseOptions} [micromarkOptions] Options for micromark.
63
54
  * @param {boolean} [referencesDefined] Treat references as defined.
64
- * @returns {Object[]} Micromark events.
55
+ * @returns {Event[]} Micromark events.
65
56
  */
66
57
  function getMicromarkEvents(
67
58
  markdown,
@@ -96,7 +87,7 @@ function getMicromarkEvents(
96
87
  * Parses a Markdown document and returns (frozen) tokens.
97
88
  *
98
89
  * @param {string} markdown Markdown document.
99
- * @param {Object} micromarkOptions Options for micromark.
90
+ * @param {ParseOptions} micromarkOptions Options for micromark.
100
91
  * @param {boolean} referencesDefined Treat references as defined.
101
92
  * @param {number} lineDelta Offset to apply to start/end line.
102
93
  * @param {Token} [ancestor] Parent of top-most tokens.
@@ -119,7 +110,7 @@ function micromarkParseWithOffset(
119
110
  let flatTokens = [];
120
111
  /** @type {Token} */
121
112
  const root = {
122
- "type": "ROOT",
113
+ "type": "data",
123
114
  "startLine": -1,
124
115
  "startColumn": -1,
125
116
  "endLine": -1,
@@ -130,6 +121,8 @@ function micromarkParseWithOffset(
130
121
  };
131
122
  const history = [ root ];
132
123
  let current = root;
124
+ // eslint-disable-next-line jsdoc/valid-types
125
+ /** @type ParseOptions | null */
133
126
  let reparseOptions = null;
134
127
  let lines = null;
135
128
  let skipHtmlFlowChildren = false;
@@ -207,7 +200,7 @@ function micromarkParseWithOffset(
207
200
  * Parses a Markdown document and returns (frozen) tokens.
208
201
  *
209
202
  * @param {string} markdown Markdown document.
210
- * @param {Object} [micromarkOptions] Options for micromark.
203
+ * @param {ParseOptions} [micromarkOptions] Options for micromark.
211
204
  * @param {boolean} [referencesDefined] Treat references as defined.
212
205
  * @returns {Token[]} Micromark tokens (frozen).
213
206
  */
@@ -283,7 +276,7 @@ function filterByPredicate(tokens, allowed, transformChildren) {
283
276
  * Filter a list of Micromark tokens by type.
284
277
  *
285
278
  * @param {Token[]} tokens Micromark tokens.
286
- * @param {string[]} types Types to allow.
279
+ * @param {TokenType[]} types Types to allow.
287
280
  * @returns {Token[]} Filtered tokens.
288
281
  */
289
282
  function filterByTypes(tokens, types) {
@@ -316,11 +309,19 @@ function getHeadingLevel(heading) {
316
309
  return level;
317
310
  }
318
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
+
319
320
  /**
320
321
  * Gets information about the tag in an HTML token.
321
322
  *
322
323
  * @param {Token} token Micromark token.
323
- * @returns {Object | null} HTML tag information.
324
+ * @returns {HtmlTagInfo | null} HTML tag information.
324
325
  */
325
326
  function getHtmlTagInfo(token) {
326
327
  const htmlTagNameRe = /^<([^!>][^/\s>]*)/;
@@ -342,7 +343,7 @@ function getHtmlTagInfo(token) {
342
343
  * Gets the nearest parent of the specified type for a Micromark token.
343
344
  *
344
345
  * @param {Token} token Micromark token.
345
- * @param {string[]} types Types to allow.
346
+ * @param {TokenType[]} types Types to allow.
346
347
  * @returns {Token | null} Parent token.
347
348
  */
348
349
  function getTokenParentOfType(token, types) {
@@ -358,7 +359,7 @@ function getTokenParentOfType(token, types) {
358
359
  * Get the text of the first match from a list of Micromark tokens by type.
359
360
  *
360
361
  * @param {Token[]} tokens Micromark tokens.
361
- * @param {string} type Types to match.
362
+ * @param {TokenType} type Type to match.
362
363
  * @returns {string | null} Text of token.
363
364
  */
364
365
  function getTokenTextByType(tokens, type) {
@@ -380,8 +381,8 @@ function inHtmlFlow(token) {
380
381
  * Determines a list of Micromark tokens matches and returns a subset.
381
382
  *
382
383
  * @param {Token[]} tokens Micromark tokens.
383
- * @param {string[]} matchTypes Types to match.
384
- * @param {string[]} [resultTypes] Types to return.
384
+ * @param {TokenType[]} matchTypes Types to match.
385
+ * @param {TokenType[]} [resultTypes] Types to return.
385
386
  * @returns {Token[] | null} Matching tokens.
386
387
  */
387
388
  function matchAndGetTokensByType(tokens, matchTypes, resultTypes) {
@@ -405,13 +406,28 @@ function matchAndGetTokensByType(tokens, matchTypes, resultTypes) {
405
406
  * Returns the specified token iff it is of the desired type.
406
407
  *
407
408
  * @param {Token} token Micromark token candidate.
408
- * @param {string} type Desired type.
409
+ * @param {TokenType} type Desired type.
409
410
  * @returns {Token | null} Token instance.
410
411
  */
411
412
  function tokenIfType(token, type) {
412
413
  return (token && (token.type === type)) ? token : null;
413
414
  }
414
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
+
415
431
  module.exports = {
416
432
  "parse": micromarkParse,
417
433
  filterByPredicate,
@@ -422,6 +438,8 @@ module.exports = {
422
438
  getTokenParentOfType,
423
439
  getTokenTextByType,
424
440
  inHtmlFlow,
441
+ isHtmlFlowComment,
425
442
  matchAndGetTokensByType,
443
+ nonContentTokens,
426
444
  tokenIfType
427
445
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-rule-helpers",
3
- "version": "0.24.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": ">=16"
17
+ "node": ">=18"
18
18
  },
19
19
  "dependencies": {
20
20
  "markdownlint-micromark": "0.1.2"