Skip to content

GFM tables without leading empty lines inside list items are interpreted incorrectly as plain text #540

@FToovvr

Description

@FToovvr

Hello.

As title says, for example, if I run cargo run - --enable-tables with the following as input:

| A | table    |
| ------ | ---- |
| not   |  in  |
| a     | list|

* A blockquote:
  > inside a list item
* A Heading:
  # inside a list item
* A table:

  | inside | a       |
  | ------ | ------- |
  | list   | item    |
  | with   | leading |
  | empty  | lines   |
* A table:
  | inside  | a       |
  | ------- | ------- |
  | list    | item    |
  | without | leading |
  | empty   | lines   |

I'd expect the output to be 1:

A table
not in
a list
  • A blockquote:

    inside a list item

  • A Heading:

    inside a list item

  • A table:

    inside a
    list item
    with leading
    empty lines
  • A table:

    inside a
    list item
    without leading
    empty lines

But the actual output is:

Atable
notin
alist
  • A blockquote:

    inside a list item

  • A Heading:

    inside a list item

  • A table:

    insidea
    listitem
    withleading
    emptylines
  • A table: | inside | a | | ------- | ------- | | list | item | | without | leading | | empty | lines |

Raw HTML of the actual output
<table><thead><tr><th>A</th><th>table</th></tr></thead><tbody>
<tr><td>not</td><td>in</td></tr>
<tr><td>a</td><td>list</td></tr>
</tbody></table>
<ul>
<li>
<p>A blockquote:</p>
<blockquote>
<p>inside a list item</p>
</blockquote>
</li>
<li>
<p>A Heading:</p>
<h1>inside a list item</h1>
</li>
<li>
<p>A table:</p>
<table><thead><tr><th>inside</th><th>a</th></tr></thead><tbody>
<tr><td>list</td><td>item</td></tr>
<tr><td>with</td><td>leading</td></tr>
<tr><td>empty</td><td>lines</td></tr>
</tbody></table>
</li>
<li>
<p>A table:
| inside  | a       |
| ------- | ------- |
| list    | item    |
| without | leading |
| empty   | lines   |</p>
</li>
</ul>

As the above shows:

  • Table extension is enabled (hence the first table above is rendered).
  • Generally, block elements inside list items are rendered exactly as what they would be in other places, no matter if there are leading empty lines. The CommonMark dingus also works this way (hence the blockquote and h1 above is rendered).
  • However, unlike other block elements, pulldown-cmark interprets tables inside list items without leading empty lines as paragraphs, not tables.

Commit I built the binary from: 5088b21 (The current head commit)

Footnotes

  1. I pasted the exact markdown text above to here and appended > to the beginning of each line, so this is just how GitHub's markdown renderer renders my input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions