Skip to content

Commit

Permalink
fix superfluous space
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Aug 26, 2024
1 parent c478588 commit 06a7555
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rich/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def __rich_console__(
and context.stack.top.on_child_close(context, element)
)
if should_render:
if new_line:
if new_line and node_type != "inline":
yield _new_line_segment
yield from console.render(element, context.options)

Expand Down
29 changes: 27 additions & 2 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
Paragraphs are separated
by a blank line.
Two spaces at the end of a line
Two spaces at the end of a line
produces a line break.
Text attributes _italic_,
Text attributes _italic_,
**bold**, `monospace`.
Horizontal rule:
Expand Down Expand Up @@ -174,6 +174,31 @@ def test_partial_table():
assert result == expected


def test_table_with_empty_cells() -> None:
"""Test a table with empty cells is rendered without extra newlines above.
Regression test for #3027 https://github.com/Textualize/rich/issues/3027
"""
complete_table = Markdown(
"""\
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
"""
)
table_with_empty_cells = Markdown(
"""\
| First Header | |
| ------------- | ------------- |
| Content Cell | Content Cell |
| | Content Cell |
"""
)
result = len(render(table_with_empty_cells).splitlines())
expected = len(render(complete_table).splitlines())
assert result == expected


if __name__ == "__main__":
markdown = Markdown(MARKDOWN)
rendered = render(markdown)
Expand Down

0 comments on commit 06a7555

Please sign in to comment.