-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Extra Space above Certain Markdown Tables #3027
Comments
It looks like an extra new line is rendered for every blank cell in the table. I'm still getting to grips with the codebase, but I think I've narrowed it down to here Lines 692 to 699 in 720800e
|
@TomJGooding Thanks for contributing a PR for this. Do you know if there's a workaround in the meantime until your PR is merged? |
A simple workaround would be to replace the empty cells in the table. Here's a quick example where I found using an invisible space character seems to trick Rich! import re
from rich.console import Console
from rich.markdown import Markdown
from rich.rule import Rule
table_with_empty_cells = """\
| First Header | |
| ------------- | ------------- |
| Content Cell | Content Cell |
| | Content Cell |\
"""
empty_cell_pat = re.compile(r"(?<=\|) +(?=\|)")
new_empty_cell = "\u200B" # invisible space
new_table = empty_cell_pat.sub(new_empty_cell, table_with_empty_cells)
console = Console()
console.print(Rule("table_with_empty_cells"))
console.print(Markdown(table_with_empty_cells))
console.print(Rule("new_table"))
console.print(Markdown(new_table)) |
@TomJGooding Ah, good idea. Thanks for the example code. |
I hope we solved your problem. If you like using Rich, you might also enjoy Textual |
Describe the bug
Certain markdown tables contain extra newlines above them in Rich 13.4.2.
Platform
Click to expand
Windows 10.
The text was updated successfully, but these errors were encountered: