github/cmark-gfm

<pre> blocks in markdown tables behave differently than rest of document, including html tables

digitalmoksha opened this issue · 2 comments

When you have a block like this

<pre>`something` and `another`</pre>

it usually gives you the same html back - the code blocks are ignored.

cmark-gfm -e table --unsafe
<pre>`something` and `another`</pre>

gives

<pre>`something` and `another`</pre>

But with a markdown table, it processes the code blocks:

 cmark-gfm -e table --unsafe
| Test |
| --- |
| <pre>`something` and `another`</pre> |

gives

<table>
<thead>
<tr>
<th>Test</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre><code>something</code> and <code>another</code></pre></td>
</tr>
</tbody>
</table>

With an HTML table, it works as expected:

cmark-gfm -e table --unsafe
<table>
<tr><td><pre>`something` and `another`</pre></td></tr>
</table>

gives

<table>
<tr><td><pre>`something` and `another`</pre></td></tr>
</table>

This has to do with the difference between block level HTML and inline HTML. The table cells contents are parsed as inline markdown not block level markdown like inside lists.

Inline html is parsed between the tags where block level html is not.

@UziTech you're absolutely right. My test of a single line with <pre>`one` and `two`</pre> pushed it through the block rendering, whereas Paragraph <pre>`one` and `two`</pre> uses inline rendering, which the table uses.

Example: https://spec.commonmark.org/dingus/?text=%3Cpre%3E%60one%60%20and%20%60two%60%3C%2Fpre%3E%0A%0AParagraph%20%3Cpre%3E%60one%60%20and%20%60two%60%3C%2Fpre%3E

Not an issue, closing...