gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 275 forks source link

Odd behavior with nested table and mixing block and inline elements #803

Closed vincerubinetti closed 7 months ago

vincerubinetti commented 7 months ago

Not sure if this belongs here or in kramdown/parser-gfm. I'm suspecting it's here.

Very specific case here. I'm using Jekyll (default kramdown parser) and getting weird behavior with nested tables.

Input:

<table>
  <tr>
    <td>test</td>
    <td>test</td>
  </tr>
  <tr>
    <td>test</td>
    <td>
      <span>test</span>

      <table>
        <tr>
          <td>test</td>
          <td>test</td>
          <td>test</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Output:

Screenshot 2024-03-25 at 4 32 43 PM

Interestingly, in my IDE vscode, the syntax highlighting seems to think there is something wrong with this:

Screenshot 2024-03-25 at 4 33 46 PM

If I remove the newline and space between the span and the nested table, I get this also wrong and weird behavior:

Screenshot 2024-03-25 at 4 35 42 PM

If I wrap the nested stuff in a single block element...

<td>
  <div>
    <span>test</span>
    <table>
       ...
    </table>
  </div>
</td>

... or if I remove the span and only have the nested table, I get what is expected:

Screenshot 2024-03-25 at 4 36 56 PM

Btw, according to the HTML spec and validator, this is all perfectly valid HTML.

vincerubinetti commented 7 months ago

Turns out this is a very specific error with jekyll-spaceship:

https://github.com/jeffreytse/jekyll-spaceship/issues/97