redbug312 / markdown-it-multimd-table

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

Render issue with text between two tables #18

Closed AWolf81 closed 5 years ago

AWolf81 commented 5 years ago

I'm working on a feature where it looks like markdown-it-multimd-table is not correctly rendering the markdown. You can find the mentioned PR here.

The problem is that the following input

Colons can be used to align columns.

| Tables | Are | Cool |
| --- | :-: | --: |
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |

There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.

| Markdown | Less | Pretty |
| --- | --- | --- |
| _Still_ | `renders` | **nicely** |
| 1 | 2 | 3 |

is rendered like in the below screenshot (from Boostnote app) with the "p-tag" in the table but it should render two tables with a p-tag between them. grafik

I created a minimal example of the issue in the following Codesandbox.

Expected result

Created by adding a <br/> after first table but it should render like this with-out the additional newline. grafik

redbug312 commented 5 years ago

Thanks for the report, but this buggy case seemed unavoidable.

MultiMarkdown allows users to create multiple <tbody> by inserting single empty line between them, which is against GFM spec.

This plugin recognizes <tbody> by checking any presence of | (from MultiMD spec), regardless of | at begin/ends (from MultiMD spec) or column numbers (from GFM spec). This is why the <p> in this case is mistaken for a <tbody>.

As the expected behavior you given, it forces users to have two empty lines to break the table, if its following paragrahph contains |. :confused:

Edit: HTML escape code for pipe &#124; works too.

AWolf81 commented 5 years ago

Thanks for your detailed feedback.

I think it's really a special use-case "using a pipe in the text" and MultiMarkdown can not detect that it shouldn't be with-in the table.

We can close this issue because I think it's not possible to fix it.