eslint-plugin-markdown-preferences 0.36.0 → 0.36.1

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/lib/index.d.ts CHANGED
@@ -545,7 +545,7 @@ declare namespace meta_d_exports {
545
545
  export { name, version };
546
546
  }
547
547
  declare const name: "eslint-plugin-markdown-preferences";
548
- declare const version: "0.36.0";
548
+ declare const version: "0.36.1";
549
549
  //#endregion
550
550
  //#region src/language/ast-types.d.ts
551
551
  type Node = mdast.Node;
package/lib/index.js CHANGED
@@ -40,7 +40,7 @@ function createRule(ruleName, rule) {
40
40
 
41
41
  //#endregion
42
42
  //#region src/utils/ast.ts
43
- const RE_HTML_COMMENT = /<!--(.*?)-->/u;
43
+ const RE_HTML_COMMENT = /<!--(.*?)-->/gu;
44
44
  /**
45
45
  * Get the parent of a node.
46
46
  */
@@ -138,17 +138,25 @@ function getThematicBreakMarker(sourceCode, node) {
138
138
  };
139
139
  }
140
140
  /**
141
- * Check whether a node is an HTML comment.
141
+ * Get all HTML comments in a node.
142
142
  */
143
- function isHTMLComment(node) {
144
- return node.type === "html" && RE_HTML_COMMENT.test(node.value);
145
- }
146
- /**
147
- * Get the value of an HTML comment.
148
- */
149
- function getHTMLCommentValue(node) {
150
- if (!isHTMLComment(node)) return null;
151
- return RE_HTML_COMMENT.exec(node.value)?.[1] ?? null;
143
+ function getHTMLComments(sourceCode, node) {
144
+ const [startIndex] = sourceCode.getRange(node);
145
+ return [...iterate()];
146
+ /**
147
+ * An iterator which iterates HTML comments.
148
+ */
149
+ function* iterate() {
150
+ let match;
151
+ while (match = RE_HTML_COMMENT.exec(node.value)) {
152
+ const start = startIndex + match.index;
153
+ const end = start + match[0].length;
154
+ yield {
155
+ value: match[1],
156
+ range: [start, end]
157
+ };
158
+ }
159
+ }
152
160
  }
153
161
 
154
162
  //#endregion
@@ -9503,9 +9511,14 @@ var padding_line_between_blocks_default = createRule("padding-line-between-block
9503
9511
  * Check if the previous block is ignored
9504
9512
  */
9505
9513
  function isIgnore(prevBlock) {
9506
- if (isHTMLComment(prevBlock)) {
9507
- const value = getHTMLCommentValue(prevBlock);
9508
- if (/^\s*(?:eslint|markdownlint)-disable-next-line\b/u.test(value)) return true;
9514
+ if (prevBlock.type === "html") {
9515
+ const comments = getHTMLComments(sourceCode, prevBlock);
9516
+ const loc = sourceCode.getLoc(prevBlock);
9517
+ for (const comment of comments) {
9518
+ const value = comment.value;
9519
+ if (!/^\s*(?:eslint|markdownlint)-disable-next-line\b/u.test(value)) continue;
9520
+ if (sourceCode.getLocFromIndex(comment.range[1]).line === loc.end.line) return true;
9521
+ }
9509
9522
  }
9510
9523
  return false;
9511
9524
  }
@@ -12213,7 +12226,7 @@ var meta_exports = /* @__PURE__ */ __export({
12213
12226
  version: () => version
12214
12227
  });
12215
12228
  const name = "eslint-plugin-markdown-preferences";
12216
- const version = "0.36.0";
12229
+ const version = "0.36.1";
12217
12230
 
12218
12231
  //#endregion
12219
12232
  //#region src/language/extensions/micromark-custom-container.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-markdown-preferences",
3
- "version": "0.36.0",
3
+ "version": "0.36.1",
4
4
  "description": "ESLint plugin that enforces our markdown preferences",
5
5
  "type": "module",
6
6
  "exports": {