forked from DavidAnson/markdownlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletters-E-X.js
32 lines (30 loc) · 928 Bytes
/
letters-E-X.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// @ts-check
"use strict";
/** @type import("../../lib/markdownlint").Rule */
module.exports = {
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
"description": "Rule that reports an error for lines with the letters 'EX'",
"information": new URL(
"https://github.com/DavidAnson/markdownlint" +
"/blob/main/test/rules/letters-E-X.js"
),
"tags": [ "test" ],
"parser": "markdownit",
"function": (params, onError) => {
for (const inline of params.parsers.markdownit.tokens.filter(
(token) => token.type === "inline"
)) {
for (const text of inline.children.filter(
(child) => child.type === "text"
)) {
const index = text.content.toLowerCase().indexOf("ex");
if (index !== -1) {
onError({
"lineNumber": text.lineNumber,
"context": text.content.substr(index - 1, 4)
});
}
}
}
}
};