2018-02-15 21:35:58 -08:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2024-12-03 19:58:28 -08:00
|
|
|
/** @type {import("markdownlint").Rule} */
|
2018-02-15 21:35:58 -08:00
|
|
|
module.exports = {
|
|
|
|
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
|
|
|
"description": "Rule that reports an error for lines with the letters 'EX'",
|
2019-01-15 21:56:38 -08:00
|
|
|
"information": new URL(
|
|
|
|
"https://github.com/DavidAnson/markdownlint" +
|
2020-08-11 22:52:29 -07:00
|
|
|
"/blob/main/test/rules/letters-E-X.js"
|
2019-01-15 21:56:38 -08:00
|
|
|
),
|
2018-02-15 21:35:58 -08:00
|
|
|
"tags": [ "test" ],
|
2024-03-09 16:17:50 -08:00
|
|
|
"parser": "markdownit",
|
2023-02-18 21:41:07 -08:00
|
|
|
"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"
|
|
|
|
)) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const index = text.content.toLowerCase().indexOf("ex");
|
2018-02-15 21:35:58 -08:00
|
|
|
if (index !== -1) {
|
|
|
|
onError({
|
|
|
|
"lineNumber": text.lineNumber,
|
2018-02-27 21:14:02 -08:00
|
|
|
"context": text.content.substr(index - 1, 4)
|
2018-02-15 21:35:58 -08:00
|
|
|
});
|
|
|
|
}
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 21:35:58 -08:00
|
|
|
}
|
|
|
|
};
|