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

131 Initial implementation of table balancing #159

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

PeterJFB
Copy link
Contributor

@PeterJFB PeterJFB commented Oct 13, 2024

  • textcomponent.rs:
    • Implements transform_table, which finds widths / heights of each cell based on some balancing formula, and splits any word which wrap within a cell.
    • Implements word_wrapping, returning a list where each entry fits within a single line
  • markdown_renderer.rs Reimplements render_table, using widths / heights and clipping to determine how many rows in each cell should be rendered (otherwise the cell will not be rendered(?)).
  • parser.rs and md.pest:
    • Add support of empty cells in parser
    • Fix link highlighting when they have no separation

Remaining work / considerations:

  • unify use of word-wrapping in paragraph and table cells
    • add support for hyphen!
  • more stress-testing
    • fix link highlighting when wrapping
    • extremely narrow overflowing column will not render bottom row
  • find a way to keep Copy-trait on TextNode enum
    • Seeing that TextNode is part of TextComponent, which is already expensive to duplicate, i think is it a reasonable place to store the dynamically sized Table information, and improves some of the implicit handling of the meta_info struct (see content_as_lines and selected_heights).

@henriklovhaug
Copy link
Owner

Could you add a more gracious fail when the table gets too big to render?

@PeterJFB
Copy link
Contributor Author

Could you add a more gracious fail when the table gets too big to render?

Updated balancing function to consider (relatively) large cells.
Added support for empty cells, which also used to panic.

@henriklovhaug henriklovhaug linked an issue Oct 16, 2024 that may be closed by this pull request
@PeterJFB PeterJFB force-pushed the feat/table-balancing branch from 6260967 to 2fa7065 Compare October 17, 2024 11:06
@PeterJFB
Copy link
Contributor Author

We're at a point where the implementation is relatively stable, it can be considered ready if nothing is added the next two days:)

@PeterJFB PeterJFB force-pushed the feat/table-balancing branch from 2fa7065 to 98265d8 Compare October 18, 2024 08:19
Support (relatively) huge and empty cells

Combine and improve word-wrapping in paragraph and table

Fix separation of links

Lint and formatting
@PeterJFB PeterJFB force-pushed the feat/table-balancing branch from 98265d8 to a7dd4b1 Compare October 18, 2024 08:39
@PeterJFB
Copy link
Contributor Author

Remaining work has been addressed :shipit:

@PeterJFB PeterJFB changed the title Experimental implementation of table balancing 131 Initial implementation of table balancing Oct 18, 2024
@henriklovhaug henriklovhaug merged commit 981cf15 into henriklovhaug:main Oct 18, 2024
5 checks passed
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.

Table balancing
2 participants