markdown.nvim icon indicating copy to clipboard operation
markdown.nvim copied to clipboard

Rendering wide tables properly? (where character count exceeds viewport width)

Open YousufSSyed opened this issue 1 year ago • 1 comments

I have this table

| Preference                                                                                                                  | Value     | Function                                                                                                             |
| --------------------------------------------------------------------------------------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
| `gfx.webrender.all`                                                                                                         |           | Enables Backdrop filter.                                                                                             |
| `browser.tabs.insertRelatedAfterCurrent`                                                                                    |           | Open new tab next to current one instead of at the rightmost.                                                        |
| `accessibility.force_disabled`                                                                                              |           | Disable Accessibility & improves performance.                                                                        |
| `toolkit.legacyUserProfile`<br>`Customizations.stylesheets`                                                                 |           | Enables custom CSS.                                                                                                  |
| `svg.context-properties.content.enabled`                                                                                    |           | Allows the `context-fill` property for Userchrome CSS.                                                               |
| `dom.disable_beforeunload`                                                                                                  |           | Disables warnings before tabs close.                                                                                 |
| `browser.link.open_newwindow.restriction`                                                                                   |           | Divert regular AND scripted windows with features.                                                                   |
| `browser.urlbar.update2.engineAliasRefresh`                                                                                 |           | Allows adding your own search engine..                                                                               |
| `apz.allow_double_tap_zooming`                                                                                              |           | Disable double tapping to zoom.                                                                                      |
| `layout.css.has-selector.enabled`                                                                                           |           | Enables the CSS `:has()` selector.                                                                                   |
| ` full-screen-api.enabled`                                                                                                  |           | Completely disable full screen, prevents websites to enabling it.                                                    |
| `browser.urlbar.showSearchTerms.featureGate`                                                                                |           | Show the search query in the URL bar instead of the URL (only for the default search engine).                        |
| `browser.gesture.swipe.up`<br>`browser.gesture.swipe.down`<br>`browser.gesture.swipe.left`<br>`browser.gesture.swipe.right` | .gestu    | Disables the respective mouse gestures. **Doesn't require a restart!**                                               |
| `accessibility.typeaheadfind.manual`</br>`accessibility.typeaheadfind`</br>`accessibility.typeaheadfind.autostart`          | d.autost  | Disables Quick Find                                                                                                  |
| ``browser.tabs.loadBookmarksInTabs``                                                                                        |           | Open bookmarks in new tabs                                                                                           |
| `xpinstall.signatures.required`                                                                                             |           | Disable requiring signatures for addons and permanently sideload them **(Only works on Firefox Developer Edition)**. |
| browser.cache.disk.capacity                                                                                                 | `1024000` | The capacityof the disk cache for page, size in MBs.                                                                 |
| browser.cache.disk.smart_size.enabled                                                                                       | `False`   | Disable automatically resizing the disk cache capacity                                                               |
| `dom.event.clipboardevents.enabled`                                                                                         | `false`   | Allow pasting in any input box                                                                                       |
|                                                                                                                             |           |                                                                                                                      |

And it shows up like this with the plugin: CleanShot 2024-10-10 at 20 23 21@2x

YousufSSyed avatar Oct 11 '24 00:10 YousufSSyed

What would you like me to do?

Once a table is that wide and has content in the cells that fills it up there's not much I can do, you can disable line wrapping but that's up to you.

There's not a good way to split a line into multiple, i.e. respecting the <br>, but I'll try it out.

I can add an option to disable rendering for tables that exceed some specified width based on the viewport but there's not really a way to fix this and make it look nice if the space does not exist.

MeanderingProgrammer avatar Oct 11 '24 20:10 MeanderingProgrammer

@MeanderingProgrammer Would it be possible to wrap the cell lines and keep the box shapes, like tables in other apps do? CleanShot 2024-10-15 at 14 15 54@2x

YousufSSyed avatar Oct 15 '24 18:10 YousufSSyed

Unfortunately not really. I don't have the kind of control I would get rendering in an application I control from top to bottom or in a web app, only what I can do with virtual text through the neovim APIs.

Its come surprisingly far given the limitations but there are going to be things I can't really accomplish. There are definitely things I don't know and I could be missing something so if you have a suggestion for how to implement this LMK or open a PR.

Ultimately for this limitation it comes down to:

There's not a good way to split a line into multiple

MeanderingProgrammer avatar Oct 15 '24 20:10 MeanderingProgrammer

Even with nowrap, the view still glitches for me. When scrolling horizontally, the border lines above/below the table and between header and body don't scroll horizontally (thus they don't line up with the vertical lines anymore).

Thyrum avatar Oct 18 '24 11:10 Thyrum

@Thyrum, thanks for letting me know!

The plugin should stop rendering when the user horizontally scrolls since there are a lot of complicated behaviors I would need to handle to have this work properly. However the logic to do this was broken, have fixed it here: https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/1871dc4ced6fd775591a63df8e4c343ebaf1a2d2.

MeanderingProgrammer avatar Oct 18 '24 20:10 MeanderingProgrammer

Feel free to re-open if there's any follow up.

MeanderingProgrammer avatar Oct 20 '24 17:10 MeanderingProgrammer

ive also encountered this issue, and the fix really is much appreciated. I am wondering, would multiline cells be feasible? if so, a working-but-not-that-elegant solution would be an option for allowing the user to split lines manually (using an escape character?)

andtsa avatar Nov 06 '24 07:11 andtsa

What did you have in mind as far as what happens when a user types an escape character?

I don't think multi line cells really exist, but maybe I'm missing something.

As an example lets say we have:

| Column 1 | Column 2 |
| -------- | -------- |
| Item 1   | A much longer item than ever seen before |

Then the user types an a backslash (our escape character in this example) right after item which would trigger the following transformation:

| Column 1 | Column 2 |
| -------- | -------- |
| Item 1   | A much longer item |
|          | than ever seen before |

Unfortunately in this case what we end up doing is making a new row with new cells which I don't think is the goal.

LMK if I'm missing something or if you had different idea!

MeanderingProgrammer avatar Nov 06 '24 20:11 MeanderingProgrammer

What does typing \ do in this case and what provides the functionality?

YousufSSyed avatar Nov 06 '24 21:11 YousufSSyed

Nothing provides this functionality this was just an example of how I interpreted:

a working-but-not-that-elegant solution would be an option for allowing the user to split lines manually (using an escape character?)

But I'm not sure I understood it correctly so am checking if this is what they meant.

MeanderingProgrammer avatar Nov 06 '24 21:11 MeanderingProgrammer

Creating a new row is exactly what I had in mind

| Column 1 | Column 2 |
| -------- | -------- |
| Item 1   | A much longer item \N |
|          | than ever seen before |

This isn't proper markdown obviously, but for anyone using exclusively neovim w/ this plugin (which I do for some files) it is fine. Only the escape character would have to be concealed and since there's no horizontal line between the cells I think it looks just fine

andtsa avatar Dec 01 '24 06:12 andtsa