markdownlint icon indicating copy to clipboard operation
markdownlint copied to clipboard

MD033: Feature request: Add option for allowing HTML tables (and all descendant elements)

Open sideshowbarker opened this issue 4 years ago • 0 comments

This is a request to add a boolean option to allow HTML tables, and all descendant elements. Maybe as an alternative to #419.

Use case: Some tables are too complex to try to represent in Markdown — or too unwieldy in practice for authors to try to edit in Markdown. So it’s not uncommon for large sets of Markdown documents to have some documents with HTML tables.

For example, for the https://github.com/mdn/content/ project, we’ve been converting all our existing HTML sources to Markdown. Currently, the following MDN subtrees have been converted to Markdown:

  • https://github.com/mdn/content/tree/main/files/en-us/web/css
  • https://github.com/mdn/content/tree/main/files/en-us/web/javascript
  • https://github.com/mdn/content/tree/main/files/en-us/web/http

A significant subset of those documents contain HTML tables that our conversion process did not convert to Markdown.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#table is one such example among many that we have in the MDN docs. (And that’s not even one of the most complex tables we have, and not even one of the ones that’d be the most impractical and unwieldy for authors to try to edit in Markdown. We have dozens of others.)

So when using markdownlint, the problem we’ve run into in practice is that markdownlint reports errors for all those tables.

And so the solution we’ve tried is to configure the MD033 value like this:

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

However, the actual tables in our documents also contain descendant <code>…</code>, and <p>…</p>, etc., markup. So markdownlint still reports errors for all those other elements. Which is what led me to raise #419.

But as an alternative to #419, what would actually be preferable is to have a single option to allow HTML tables — including all their descendant elements.

I can imagine a naive way to implement it would be, when seeing an HTML <table> start tag, turn off all error reporting until an HTML </table> end tag is seen.

I know that would at least solve the problem for the MDN use case.

sideshowbarker avatar Aug 15 '21 11:08 sideshowbarker