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

Table marks are not aligning properly #75

Closed
ColinKennedy opened this issue Aug 5, 2024 · 27 comments · Fixed by #88 or #90
Closed

Table marks are not aligning properly #75

ColinKennedy opened this issue Aug 5, 2024 · 27 comments · Fixed by #88 or #90
Labels
bug Something isn't working

Comments

@ColinKennedy
Copy link

ColinKennedy commented Aug 5, 2024

Describe the bug
The table rendering is off when it contains marked-up character(s)

image

Are you using a distro?
No

To Reproduce
Steps to reproduce the behavior:

  1. Install markview.nvim.
  2. Open a markdown document.
| 1 |      2       |                                         3                               |
| - | ------------ | ----------------------------------------------------------------------- |
| n | `<leader>`rr | [r]e-[r]un the last terminal command (The !! syntax is UNIX-specific)   |
| n | `<leader>`st | [s]end to the nearest [t]erminal your system clipboard text.            |

Expected behavior
The table should have consistent boundaries like here

https://jbt.github.io/markdown-editor/#pdA9C8IwEAbgvb/iiosOEdRVnFxcOikIpdCYnhjIR0mu2EJ/vEe1YF0UfIeEy4XnQmaQ4R32XjUWHSVJDyvoYcj6uY3lD9l86ffMC/bEWz7KPzLwjr1ya1BWGHZlCFzmoUDBS+OAbghGRgLCYLWTBpS3VroK5kdupSnEzpFsQUc4ZYeziDUqfdVq8Xr9lGeI+VggA+QH3aEMyOc5FeOIzjeB3UhoQRldX7wMfB9bWk4/5wE=

Or with MeanderingProgrammer/markdown.nvim

image

Actual behavior
The table is misaligned

Neovim version
0.10.0

@ColinKennedy ColinKennedy added the bug Something isn't working label Aug 5, 2024
@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 5, 2024

Screenshot_2024-08-05-19-30-16-740_com termux

@davidosomething
Copy link

not quite fixed yet,
image

using commit 9e5275f
file tested: https://raw.githubusercontent.com/davidosomething/dotfiles/dev/README.md

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 5, 2024

It's only fixed on the dev branch.

Screenshot_2024-08-05-21-37-47-897_com termux-edit

@davidosomething
Copy link

nice, confirmed!

@davidosomething
Copy link

davidosomething commented Aug 6, 2024

might need to re-render the box-drawing lines upon returning to normal mode
e.g. in middle of table hit tab to insert spaces, then exit edit mode

Screencast_20240806_003430.webm

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 6, 2024

That's actually the intended behavior since the goal was to preserve the original width without causing cursor jumps.

Guess I should tweak this behavior a bit.

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 6, 2024

It should work now.

Input:
Screenshot_2024-08-06-12-52-38-998_com termux-edit

Preview:
Screenshot_2024-08-06-12-52-49-672_com termux-edit

Note

Rows who don't have the correct number of columns are unaffected(so that this doesn't break odd table structures).
Otherwise, the width is snapped to the separators width.

@RaidOpe
Copy link

RaidOpe commented Aug 14, 2024

Is there a 64-byte width limit, here are my test results?
image
image

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 14, 2024

No there is not.
Screenshot_2024-08-14-17-25-17-099_com termux-edit

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 14, 2024

If you have wrap enabled then this could happen.

@RaidOpe
Copy link

RaidOpe commented Aug 14, 2024

If you have wrap enabled then this could happen.

(neovim/neovim#13474) it fits with :lua vim.wo.wrap = false in command mode 🫢
But if you don't add '\n' manually, the text of the paragraph becomes very long, which is ultimately not conducive to reading

@OXY2DEV
Copy link
Owner

OXY2DEV commented Aug 14, 2024

Not much I can do about long lines other than, "Stop trying shove everything inside tables" since trying to do that will be VERY difficult(as people will end up using other syntaxes inside table cells).

But then again even GitHub doesn't do that for long tables(at least not on mobile) so this shouldn't be a problem most of the time.

@shibotto
Copy link

Just trying to understand here, why does the table header separator wrap when there is still plenty of space left though?

image

image

@OXY2DEV
Copy link
Owner

OXY2DEV commented Sep 19, 2024

Just trying to understand here, why does the table header separator wrap when there is still plenty of space left though?

image

image

Probably because neovim doesn't take concealed text into account when checking if a line should wrap or not.

So, after adding the borders the line's width becomes twice of its original width which causes neovim to wrap it.

@l00sed
Copy link

l00sed commented Nov 4, 2024

I'm still having issues with table formatting when there is concealed text in the table. Is there a way around this? I believe my markdown syntax is correct... Is there a setting I'm missing? I should be using the latest main branch release (24.0.0, I believe). Thanks

store price + core CCA warranty
Advance Auto Parts $169.99 + $22.00 750 3-year free replacement
AutoZone $169.99 + $18.00 750 3-year warranty
Costco $89.99 + $15.00 700 3-year limited warranty
Home Depot $99.00 + $15.00 750 30-month free replacement
O' Reilly Auto Parts $134.99 + $18.00 700 3-year free replacement
Walmart $98.76 + ? 750 3-year free replacement

image

@OXY2DEV
Copy link
Owner

OXY2DEV commented Nov 4, 2024

There's 2 issues here,

  1. You are manually adding spaces which causes the first column to become too big as the plugin doesn't modify the text itself.
  2. You need to do \$ instead of $ as it's used for latex blocks(this is from tree-sitter).

@l00sed
Copy link

l00sed commented Nov 4, 2024

I think GitHub might have auto-formatted your second suggestion. Is there a \ to escape the $?

@OXY2DEV
Copy link
Owner

OXY2DEV commented Nov 4, 2024

I think GitHub might have auto-formatted your second suggestion. Is there a \ to escape the $?

Yes

@l00sed
Copy link

l00sed commented Nov 4, 2024

If I eliminate the manually-added spaces and escape the $, I'm still getting odd formatting:

| store | price + core | CCA | warranty |
|:---|:---|:---|:---|
| [Advance Auto Parts](https://shop.advanceautoparts.com/p/diehard-gold-battery-group-size-24f-750-cca-24f-6/2130001-P?navigationPath=L1*14920%7CL2*15000) | \$169.99 + \$22.00 | 750 | 3-year free replacement |
| [AutoZone](https://www.autozone.com/batteries-starting-and-charging/battery/duralast-gold-battery-24f-dlg-group-size-24f-750-cca/832327_0_0) | \$169.99 + \$18.00 | 750 | 3-year warranty |
| [Costco](https://www.costco.com/automotive-batteries.html) | \$89.99 + \$15.00 | 700 | 3-year limited warranty |
| [Home Depot](https://www.homedepot.com/p/Exide-SPRINTER-MAX-12-volts-Lead-Acid-6-Cell-24F-Group-Size-750-Cold-Cranking-Amps-BCI-Auto-Battery-SX24F/308488599?) | \$99.00 + \$15.00  | 750 | 30-month free replacement |
| [O' Reilly Auto Parts](https://www.oreillyauto.com/detail/c/tested-tough-max/marine---boat/battery---automotive/9e0b1d7dae44/motorcraft-tested-tough-max-battery-group-size-24f-24r/mot2/bxt24fa?pos=4) | \$134.99 + \$18.00 | 700 | 3-year free replacement |
| [Walmart](https://www.walmart.com/ip/EverStart-Maxx-Lead-Acid-Automotive-Battery-Group-Size-24F/28275657) | \$98.76 + ? | 750 | 3-year free replacement |
store price + core CCA warranty
Advance Auto Parts $169.99 + $22.00 750 3-year free replacement
AutoZone $169.99 + $18.00 750 3-year warranty
Costco $89.99 + $15.00 700 3-year limited warranty
Home Depot $99.00 + $15.00 750 30-month free replacement
O' Reilly Auto Parts $134.99 + $18.00 700 3-year free replacement
Walmart $98.76 + ? 750 3-year free replacement

image

@OXY2DEV
Copy link
Owner

OXY2DEV commented Nov 4, 2024

I think I found the issue.

There seems to be a % in the first link that is causing the issue.

This will probably take a while to fix(as it seems to break other stuff one way or another).

@l00sed
Copy link

l00sed commented Nov 4, 2024

Ok, thanks for taking a look. Should I open a new issue?

OXY2DEV added a commit that referenced this issue Nov 6, 2024
Literal `%` in strings no longer turn into `^@%`. Fixes alignment issues
of tables & widtb calculations.

Ref: #75, #177
@OXY2DEV
Copy link
Owner

OXY2DEV commented Nov 6, 2024

Turns out, I'm stupid 😑.

@l00sed
Copy link

l00sed commented Nov 6, 2024

Hey, hey, hey! You're a frickin genius, this is a rad plugin that you've dedicated a lot of work to it. Thanks very much for your help. Glad that was easy, though ;)

@OXY2DEV
Copy link
Owner

OXY2DEV commented Nov 6, 2024

Hey, hey, hey! You're a frickin genius, this is a rad plugin that you've dedicated a lot of work to it. Thanks very much for your help.

Thanks for your kind words 😀. Glad you like the plugin.

Glad that was easy, though ;)

Unfortunately this will take a while to be added to the main branch(as I am rewriting the plugin, and have only done 55% of work. You can try out the dev branch if you need the fix immediately. Be warned though configuration has changed a bit.
You can see the config for dev here

@l00sed
Copy link

l00sed commented Nov 6, 2024

I'll keep tabs on the dev branch, thanks!

@uwla
Copy link

uwla commented Dec 29, 2024

Hi @OXY2DEV

Your plugin rocks but I still get issues with long tables, whose borders are all messed up when the cursor column is greater than the terminal width. When that happens, If I go further left (with wrap or nowrap), the border messes up.

MARKVIM 1
MARKVIM 2

In such scenario, when the cursor column is greater than the terminal width, I think one solution would be to simply disable the hightlight completely and show raw markdown text.

@OXY2DEV
Copy link
Owner

OXY2DEV commented Dec 30, 2024

@uwla Tables no longer render when the start column of the table isn't visible.

OXY2DEV added a commit that referenced this issue Jan 10, 2025
Literal `%` in strings no longer turn into `^@%`. Fixes alignment issues
of tables & widtb calculations.

Ref: #75, #177
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
7 participants