File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -677,7 +677,7 @@ def __rich_console__(
677
677
and context .stack .top .on_child_close (context , element )
678
678
)
679
679
if should_render :
680
- if new_line :
680
+ if new_line and node_type != "inline" :
681
681
yield _new_line_segment
682
682
yield from console .render (element , context .options )
683
683
Original file line number Diff line number Diff line change 18
18
Paragraphs are separated
19
19
by a blank line.
20
20
21
- Two spaces at the end of a line
21
+ Two spaces at the end of a line
22
22
produces a line break.
23
23
24
- Text attributes _italic_,
24
+ Text attributes _italic_,
25
25
**bold**, `monospace`.
26
26
27
27
Horizontal rule:
@@ -174,6 +174,31 @@ def test_partial_table():
174
174
assert result == expected
175
175
176
176
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
+
177
202
if __name__ == "__main__" :
178
203
markdown = Markdown (MARKDOWN )
179
204
rendered = render (markdown )
You can’t perform that action at this time.
0 commit comments