fix for markdown table

This commit is contained in:
Will McGugan 2023-07-29 10:07:27 +01:00
parent 01b85ac116
commit dbf66e8bb9
3 changed files with 13 additions and 4 deletions

View File

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Text.expand_tabs not expanding spans.
- Fixed TimeElapsedColumn from showing negative.
- Fix for escaping strings with a trailing backslash https://github.com/Textualize/rich/issues/2987
- Fixed exception in Markdown with partial table https://github.com/Textualize/rich/issues/3053
### Added

View File

@ -259,10 +259,10 @@ class TableElement(MarkdownElement):
for column in self.header.row.cells:
table.add_column(column.content)
assert self.body is not None
for row in self.body.rows:
row_content = [element.content for element in row.cells]
table.add_row(*row_content)
if self.body is not None:
for row in self.body.rows:
row_content = [element.content for element in row.cells]
table.add_row(*row_content)
yield table

View File

@ -133,6 +133,14 @@ def test_markdown_table():
assert result == expected
def test_partial_table():
markdown = Markdown("| Simple | Table |\n| ------ | ----- ")
result = render(markdown)
print(repr(result))
expected = "\n \n \x1b[1m \x1b[0m\x1b[1mSimple\x1b[0m\x1b[1m \x1b[0m \x1b[1m \x1b[0m\x1b[1mTable\x1b[0m\x1b[1m \x1b[0m \n ━━━━━━━━━━━━━━━━ \n \n"
assert result == expected
if __name__ == "__main__":
markdown = Markdown(MARKDOWN)
rendered = render(markdown)