Skip to content
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

Update markdown.py #3313

Closed
wants to merge 1 commit into from
Closed

Update markdown.py #3313

wants to merge 1 commit into from

Conversation

Rhythmicc
Copy link

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Fix the extra blank lines that appear when displaying tables:
image
image

After modified:
image

修复展示表格时产生的多余空行
@willmcgugan
Copy link
Collaborator

I can't reproduce this. Assuming fixed.

@willmcgugan willmcgugan closed this Jul 1, 2024
@TomJGooding
Copy link
Contributor

TomJGooding commented Jul 1, 2024

@willmcgugan Here's a quick test which hopefully demonstrates this isn't fixed on master:

def test_table_with_empty_cells():
    """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

@willmcgugan
Copy link
Collaborator

So it is empty cells that is the issue? Could have used that in description!

@willmcgugan willmcgugan reopened this Jul 1, 2024
@TomJGooding
Copy link
Contributor

So it is empty cells that is the issue? Could have used that in description!

Sorry this isn't my PR and it has been several months. I agree this could have been clearer, this is the relevant issue:

@willmcgugan
Copy link
Collaborator

Thanks. Fixed in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants