mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
38
lib/md033.mjs
Normal file
38
lib/md033.mjs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// @ts-check
|
||||
|
||||
import { addError, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD033", "no-inline-html" ],
|
||||
"description": "Inline HTML",
|
||||
"tags": [ "html" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD033(params, onError) {
|
||||
let allowedElements = params.config.allowed_elements;
|
||||
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
||||
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
||||
for (const token of filterByTypesCached([ "htmlText" ], true)) {
|
||||
const htmlTagInfo = getHtmlTagInfo(token);
|
||||
if (
|
||||
htmlTagInfo &&
|
||||
!htmlTagInfo.close &&
|
||||
!allowedElements.includes(htmlTagInfo.name.toLowerCase())
|
||||
) {
|
||||
const range = [
|
||||
token.startColumn,
|
||||
token.text.replace(nextLinesRe, "").length
|
||||
];
|
||||
addError(
|
||||
onError,
|
||||
token.startLine,
|
||||
"Element: " + htmlTagInfo.name,
|
||||
undefined,
|
||||
range
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue