markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD033: Feature request: Allow all descendant elements of configured `allowed_elements`

Open sideshowbarker opened this issue 4 years ago • 1 comments

For any element named in the MD033 allowed_elements array, allow any child elements of the named elements.

Use case: To cause all HTML tables to be allowed, I have the following configured:

allowed_elements: ["table", "tr", "td", "th", "thead", "tbody", "tfoot", "caption", "colgroup", "col"]

However, the actual tables in my documents also contain descendant <code>…</code>, and <p>…</p>, etc., markup.

I want markdownlint to report those <code>…</code>, and <p>…</p>, etc., elements when they occur anywhere else in a document — but I just don’t want markdownlint to report them when they are descendants of an HTML table element.

So if this feature were implemented, everything would work if I just did the following:

allowed_elements: ["table"]

That is, the above would allow any HTML table and all its descendant elements.

So as an alternative to this request, I raised #420 with a request for a specific option that causes HTML tables to be allowed (including all their descendant elements).

sideshowbarker avatar Aug 15 '21 11:08 sideshowbarker

+1 for this; for my usecase, I use Markdown for blog posts, where sometimes embedded HTML content must be added, for example;

### Hello

Check out this **awesome** video from <a href="https://youtube.com">YouTube</a>:

<figure>
    <video>..</video>
    <p><a href="#share">Share this</a></p>
</figure>

I would've wanted to use the allowed_elements option of MD033 to allow everything nested inside the <figure>, as it cannot be replicated in Markdown.

However, I would still want this rule to catch the inline HTML <a> in the paragraph, as that could easily be a [link]().

My use case would be totally solved if there was some sort of "all descendants" option for MD033 that excused any children of allowed tags.

groenroos avatar Feb 19 '22 03:02 groenroos