[GH-ISSUE #419] MD033: Feature request: Allow all descendant elements of configured allowed_elements #2195

Open
opened 2026-03-07 20:05:27 +03:00 by kerem · 1 comment
Owner

Originally created by @sideshowbarker on GitHub (Aug 15, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/419

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).

Originally created by @sideshowbarker on GitHub (Aug 15, 2021). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/419 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: ```yaml 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: ```yaml 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).
Author
Owner

@groenroos commented on GitHub (Feb 19, 2022):

+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.

<!-- gh-comment-id:1045650079 --> @groenroos commented on GitHub (Feb 19, 2022): +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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#2195
No description provided.