redbug312 / markdown-it-multimd-table

Multimarkdown table syntax plugin for markdown-it markdown parser
MIT License
146 stars 37 forks source link

[BUG] Consecutive tables get merged into one table #34

Closed cuonghuunguyen closed 2 years ago

cuonghuunguyen commented 3 years ago

Description When parsing 2 or more consecutive tables, they will be merged into one table with multiple tbody

Example code

| --- | --- |
| 1   | 2   |
| 3   |  4   |

| --- | --- |
| 5   | 6   |
| 7   | 8    |

Expected output

<table>

<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>

Actual output

<table>
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
<tbody>
<tr>
<td>---</td>
<td>---</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
</tr>
</tbody>
</table>
redbug312 commented 3 years ago

Hi, this is expected behavior as defined in MultiMarkdown:

You can create multiple <tbody> tags (for HTML) within a table by having a single empty line between rows of the table.

But this rule seems to have confused some (#18). I'm considering add an option like multitbody: false to disable this.

cuonghuunguyen commented 3 years ago

Hi, Thank you for your very quick response. That would be great to have that feature. For now, I think I should apply the workaround to have 2 or more line breaks between tables. Do you have any better workarounds for the moment (e.g. overriding rules)? I would be appreciated to hear that.

redbug312 commented 3 years ago

Yes. For now, the best workaround is to introduce more empty lines.

Adding a table caption at the bottom also indicates the end of tables, but this introduces conflict against common standards again.

redbug312 commented 2 years ago

Closed for version 4.2.0.