Skip to content

marko unindents gfm Tables within List Items #255

@tahv

Description

@tahv

When rendering a markdown, marko break the indentation of tables who are list item children:

>>> from marko import Markdown
>>> from marko.md_renderer import MarkdownRenderer
>>> text = "- List item.\n\n  |foo|bar|\n  |---|---|\n  |foo|bar|"
>>> print(text)
- List item.

  |foo|bar|
  |---|---|
  |foo|bar|

>>> md = Markdown(extensions=["gfm"], renderer=MarkdownRenderer)
>>> print(md.convert(text))
- List item.
  
| foo | bar |
| --- | --- |
| foo | bar |

Marko result is rendered like this on GitHub:

  • List item.
foo bar
foo bar

The original text is rendered like this:

  • List item.
    foo bar
    foo bar

The default html renderer keep the table a child of the list item:

>>> from marko import Markdown
>>> md = Markdown(extensions=["gfm"])
>>> print(md.convert("- List item.\n\n  |foo|bar|\n  |---|---|\n  |foo|bar|"))
<ul>
<li>
<p>List item.</p>
<table>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>foo</td>
<td>bar</td>
</tr>
</tbody></table></li>
</ul>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions