Skip to content

Commit 06a7555

Browse files
committed
fix superfluous space
1 parent c478588 commit 06a7555

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

rich/markdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def __rich_console__(
677677
and context.stack.top.on_child_close(context, element)
678678
)
679679
if should_render:
680-
if new_line:
680+
if new_line and node_type != "inline":
681681
yield _new_line_segment
682682
yield from console.render(element, context.options)
683683

tests/test_markdown.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
Paragraphs are separated
1919
by a blank line.
2020
21-
Two spaces at the end of a line
21+
Two spaces at the end of a line
2222
produces a line break.
2323
24-
Text attributes _italic_,
24+
Text attributes _italic_,
2525
**bold**, `monospace`.
2626
2727
Horizontal rule:
@@ -174,6 +174,31 @@ def test_partial_table():
174174
assert result == expected
175175

176176

177+
def test_table_with_empty_cells() -> None:
178+
"""Test a table with empty cells is rendered without extra newlines above.
179+
Regression test for #3027 https://github.com/Textualize/rich/issues/3027
180+
"""
181+
complete_table = Markdown(
182+
"""\
183+
| First Header | Second Header |
184+
| ------------- | ------------- |
185+
| Content Cell | Content Cell |
186+
| Content Cell | Content Cell |
187+
"""
188+
)
189+
table_with_empty_cells = Markdown(
190+
"""\
191+
| First Header | |
192+
| ------------- | ------------- |
193+
| Content Cell | Content Cell |
194+
| | Content Cell |
195+
"""
196+
)
197+
result = len(render(table_with_empty_cells).splitlines())
198+
expected = len(render(complete_table).splitlines())
199+
assert result == expected
200+
201+
177202
if __name__ == "__main__":
178203
markdown = Markdown(MARKDOWN)
179204
rendered = render(markdown)

0 commit comments

Comments
 (0)