remarkjs / remark-gfm

remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists)
https://remark.js.org
MIT License
744 stars 26 forks source link

Returns invalid attributes in tr/td elements #29

Closed Trott closed 2 years ago

Trott commented 2 years ago

Initial checklist

Affected packages and versions

remark-gfm@3.0.1

Link to runnable example

No response

Steps to reproduce

Run the example.js file in the README with the example.md in the README as input.

Expected behavior

Output should match the output shown in the README.

Actual behavior

The output for the table has align="none" attribute showing up. This appears to be an interoperability issue between rehypeStringify and remark-gfm (and really the underlying micromark-extension-gfm-table and hast-util-to-html modules).

align="none" is not valid, or at least that's my reading of https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td#attr-align. Regardless, align is deprecated and I think the right thing to do here is omit it (which is what the example output does).

Here's the output I get:

<h1>GFM</h1>
<h2>Autolink literals</h2>
<p><a href="http://www.example.com">www.example.com</a>, <a href="https://example.com">https://example.com</a>, and <a href="mailto:contact@example.com">contact@example.com</a>.</p>
<h2>Footnote</h2>
<p>A note<sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<h2>Strikethrough</h2>
<p><del>one</del> or <del>two</del> tildes.</p>
<h2>Table</h2>
<table>
<thead>
<tr>
<th align="none">a</th>
<th align="left">b</th>
<th align="right">c</th>
<th align="center">d</th>
</tr>
</thead>
</table>
<h2>Tasklist</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" disabled> to do</li>
<li class="task-list-item"><input type="checkbox" checked disabled> done</li>
</ul>
<section data-footnotes class="footnotes"><h2 id="footnote-label" class="sr-only">Footnotes</h2>
<ol>
<li id="user-content-fn-1">
<p>Big note. <a href="#user-content-fnref-1" data-footnote-backref class="data-footnote-backref" aria-label="Back to content">↩</a></p>
</li>
</ol>
</section>

Runtime

Node v17

Package manager

npm v7

OS

macOS

Build and bundle tools

No response

wooorm commented 2 years ago

Presumably a mistake I made before leaving for holiday last week. Will try to solve it tomorrow. Thanks for raising!

github-actions[bot] commented 2 years ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

wooorm commented 2 years ago

Something which I assumed was internal was leaking and causing this error. Fixed!