AphrodyBun GitHub

Runtime docs · Linter · Rules

markdown/no-html

Disallow HTML tags

Markdown passes HTML through unchanged, but not every renderer does: some strip it, some escape it, and MDX reads it as JSX. This rule limits a document to plain Markdown, or to a short list of allowed elements.

Each opening tag is reported. Closing tags and comments are not.

Configure

Off by default. It needs an ESLint config that says which files are in the language:

eslint.config.js
import markdown from "@eslint/markdown";

export default [
  {
    files: ["**/*.md"],
    plugins: { markdown },
    language: "markdown/commonmark",
    rules: { "markdown/no-html": "error" },
  },
];

It also works with markdown/gfm.

Examples

Reported:

<div align="center">

Press <kbd>Enter</kbd>.

</div>

Not reported:

Press **Enter**.

<!-- A comment -->

Options

OptionDefaultWhat it does
allowed[]The names of the elements that are allowed.
allowedIgnoreCasefalseIgnore case, so KBD is allowed if kbd is on the list.
Press <kbd>Enter</kbd>.
Press <KBD>Enter</KBD>.
Press <KBD>Enter</KBD>.