redbug312 / markdown-it-multimd-table

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

Can I create multiple lines of row without any HTML/Markdown tags? #22

Closed nyaapass closed 5 years ago

nyaapass commented 5 years ago

Hello,

When I was using the Multiple lines of row option, I found this feature can only be used with HTML/Markdown tags:

| A   | B     |
| --- | ----- |
| 1   | - 2   | \
|     | - 3   |

But when I was using it without any HTML/Markdown tags like #2:

| A   | B   |
| --- | --- |
| 1   | 2   | \
|     | 3   |

The parsed HTML is:

 <table>
  <thead>
    <tr>
      <th>A</th>
      <th>B</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td colspan="2">
        <p>2 3</p>
      </td>
    </tr>
  </tbody>
</table>

There is only one <p> tag but I think it should be two <p> like this:

<table>
  <thead>
    <tr>
      <th>A</th>
      <th>B</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td colspan="2">
        <p>2</p>
        <p>3</p>
      </td>
    </tr>
  </tbody>
</table>

Is this a designed feature or just a bug? Thank you.

redbug312 commented 5 years ago

Thanks for the report. Multi-line rows intend to call markdown-it API, having ParserBlock parse the cells for simplicity. Thus it cannot generate multi-line row without tags inside.

And, because single line-break doesn't split the paragraph in native markdown-it, the example you given above should be parsed as:

<table>
<thead>
<tr>
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>1</p>
</td>
<td>
<p>2
3</p>
</td>
</tr>
</tbody>
</table>

No colspan and one paragraph only. To create two paragraphs with colspan 2, it should be:

| A   | B        ||
| --- | --- | --- |
| 1   | 2        || \
|     |          || \
|     | 3        ||

Multi-line line-breaks are badly handled in current version (v3.2.3), and I may not fix this version since develop branch (will be v4.0.0) has this issue solved. You can test if it works as expected.

nyaapass commented 5 years ago

Thanks for your reply. I just found that I need to turn on the breaks option of markdown-it to create multiple lines of row without any tags or blank rows.

Also, although the colspan="2" situation cannot pass the test case, it does not cause any visual side effects if the border-collapse: collapse; style is added to a bordered table.

So my problem solved in current version (v3.2.3). Thank you very much!