Tags: html
Aliases: no-inline-html
This rule is triggered when raw HTML is used in a Markdown document.
# Markdown heading
<h1>Inline HTML heading</h1>Raw HTML is allowed in Markdown, but this rule is included for those who want their documents to only include "pure" Markdown, or for those who are rendering Markdown documents into something other than HTML.
The allowed_elements parameter can be used to specify a list of HTML elements that are allowed to be used in the document. By default, no HTML elements are allowed.
Example configuration:
[linters.settings.no-inline-html]
allowed_elements = ["p", "div", "span", "br", "hr"]With this configuration, the following would not trigger the rule:
<p>This paragraph is allowed</p>
<div>This div is allowed</div>
<span>This span is allowed</span>
Line break: <br>
Horizontal rule: <hr>But this would still trigger the rule:
<h1>This heading is not allowed</h1>
<img src="image.jpg" alt="This image is not allowed">- HTML elements in code blocks and code spans are ignored by this rule
- Only opening tags are reported as violations; closing tags are not reported separately
- Element names are compared case-insensitively when checking against the allowed elements list
- Self-closing tags (like
<br/>and<hr/>) are treated the same as opening tags