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

bug: table rendering broken when containing inline code #287

Closed
2 tasks done
michamos opened this issue Jan 7, 2025 · 1 comment
Closed
2 tasks done

bug: table rendering broken when containing inline code #287

michamos opened this issue Jan 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@michamos
Copy link

michamos commented Jan 7, 2025

Neovim version (nvim -v)

0.10.2

Neovim distribution

N/A

Operating system

Linux

Terminal emulator / GUI

kitty

Describe the bug

When a table contains inline code between backticks (like so), the borders of the table are not drawn at the correct place on that line. It looks like the computation of the required line length is off.

Minimal example:

|`foo`|bar|
|---|---|
|a|b|

is displayed as
image

Expected behavior

the table border should be at the correct place

Healthcheck output

==============================================================================
render-markdown: require("render-markdown.health").check()

render-markdown.nvim [version] ~
- OK plugin 7.8.2
- OK neovim >= 0.10

render-markdown.nvim [configuration] ~
- OK valid

render-markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown: highlight enabled
- OK markdown_inline: parser installed
- OK markdown_inline: highlight enabled
- WARNING latex: parser not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [icons] ~
- OK using: nvim-web-devicons

render-markdown.nvim [executables] ~
- WARNING latex2text: not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [conflicts] ~
- OK headlines: not installed
- OK obsidian: installed but should not conflict

Plugin configuration

{ render_modes = true }

Plugin error log

N/A

Confirmations

  • I have updated this plugin to the latest version using my plugin manager
  • I have provided the text contained in all screenshots as raw text in this issue. This means if there is a screenshot below it is the copy pasted contents of the file in the screenshot. I understand that my issue will be closed if I have not.

Additional information

No response

@michamos michamos added the bug Something isn't working label Jan 7, 2025
MeanderingProgrammer added a commit that referenced this issue Jan 8, 2025
## Details

Issue: #287

We have a default padding of 1 set for pipe table cells. However when
there is not actually enough space available to create this padding we
end up with unhandled negative values which lead to poor rendering.

To fix this adjust column width calculation to account for needed space.

For example if we have a cell like `|foo|`, it would normally have a
width of 3. Naturally there is not enough space on either side for
padding. The fix adds to the width value for each cell to ensure it can
allow for the specified amount of padding on both side, so now the width
calculation is 5. With a column width of 5 and the cell still having an
actual width of 3 we'll end up doing the correct thing and adding a
space on both sides resulting in `| foo |`.
@MeanderingProgrammer
Copy link
Owner

Ah, that happens when the cells don't have space available on either side and that cell also happens to be >= the longest line in that column.

Updated the logic to handle this and create space when needed: 786d643.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants