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

fix(markdown): render table without extra newlines above #3080

Conversation

TomJGooding
Copy link
Contributor

@TomJGooding TomJGooding commented Aug 9, 2023

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

This PR looks to fix #3027 by adding new_line = False to the TableRowElement and TableDataElement.

Currently if a markdown table contains any empty cells, an extra new line is rendered above the table for every empty cell. See the screenshot in the linked issue for an example.

These extra newlines seem to be caused by this code in Markdown:

rich/rich/markdown.py

Lines 692 to 699 in 720800e

should_render = (
not context.stack
or context.stack
and context.stack.top.on_child_close(context, element)
)
if should_render:
if new_line:
yield _new_line_segment

I confess I'm not as familiar with the Rich codebase as I am with Textual, so please let me know if I'm on the wrong track here.

@TomJGooding TomJGooding marked this pull request as ready for review August 9, 2023 22:44
@TomJGooding TomJGooding changed the title fix(markdown): render table without extra newlines fix(markdown): render table without extra newlines above Aug 12, 2023
@TomJGooding
Copy link
Contributor Author

Closed in favour of #3313.

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.

[BUG] Extra Space above Certain Markdown Tables
1 participant