Skip to content

bug: #93

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

Closed
zenoli opened this issue Jul 24, 2024 · 12 comments
Closed

bug: #93

zenoli opened this issue Jul 24, 2024 · 12 comments
Labels
not a bug Not a bug in this plugin

Comments

@zenoli
Copy link

zenoli commented Jul 24, 2024

Neovim version (nvim -v)

0.10.0

Operating system

MacOS

Terminal emulator / GUI

Kitty

Describe the bug

There is no space between bullet points and text:
image

Expected behavior

There should be a space between the bullet point and the text

Healthcheck output (:checkhealth render-markdown)

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

markdown.nvim [neovim version] ~
- OK Version >= 0.10

markdown.nvim [configuration] ~
- OK valid

markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown_inline: parser installed
- OK latex: parser installed
- OK highlights enabled

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

Additional information

The DEBUG LOG output of the test markdown from the screenshot is:

~/.local/state/nvim/render-markdown.log

2024-07-24 19:32:08 - DEBUG - {
  after = 3,
  before = 3,
  option = "conceallevel",
  win = 1000
}
2024-07-24 19:32:08 - DEBUG - {
  after = "",
  before = "",
  option = "concealcursor",
  win = 1000
}

@zenoli zenoli added the bug Something isn't working label Jul 24, 2024
@MeanderingProgrammer
Copy link
Owner

What is your config and what is the raw markdown text in your screenshot.

@zenoli
Copy link
Author

zenoli commented Jul 24, 2024

My config (the modified bullet chars are single-character nerd font icons):

return {
    "MeanderingProgrammer/markdown.nvim",
    main = "render-markdown",
    opts = {
        log_level = "debug",
        checkbox = {
            unchecked = { icon = " " },
            checked = { icon = "󰄲 " },
        },
        bullet = {
            icons = { "", '●', '', "◆" },
        },
    },
    name = "render-markdown",                                                            -- Only needed if you have another plugin named markdown.nvim
    dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
}

The raw markdown text:

# Heading

- Item
  - Nested

> [!NOTE]
> A note

- [ ] Unchecked
- [x] Checked

@eofferma
Copy link

eofferma commented Jul 25, 2024

Same problem here:

Captura desde 2024-07-24 23-04-54
Captura desde 2024-07-24 23-04-44

Captura desde 2024-07-24 23-59-02
Captura desde 2024-07-24 23-59-15

nvim v0.10.0
kitty 0.21.2
checkhealth:

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

markdown.nvim [neovim version] ~

  • OK Version >= 0.10

markdown.nvim [configuration] ~

  • OK valid

markdown.nvim [nvim-treesitter] ~

  • OK installed
  • OK markdown: parser installed
  • OK markdown_inline: parser installed
  • OK highlights enabled

markdown.nvim [executables] ~

  • OK none to check

@MeanderingProgrammer
Copy link
Owner

Interesting, I'm not quite able to reproduce this.

I think the end result relies a lot on your font configuration for Kitty, but I do get something like it if I switch my font to JetBrainsMono Nerd Font.

I'm assuming the config you sent me is slightly off? The first and second values in the icons array appear swapped compared to the screenshot.

Due to just the vast number of ways different fonts, terminal emulators and associated configs can render text there is no great fix. In this case for some reason the icons appear shifted to the right, in other cases if there is space around an icon the terminal can make the icon larger to fill the space. Right shifting seems like the worse of these, but I can't begin debugging what exactly is going here without spending just too much time. I have done so for my own terminal configuration before.

Instead I provided a mediocre patch to allow bullets to add right padding here: 2c8be07.

Please update and set a value like: bullet = { right_pad = 1 } and see if it improves the look.

It will have edge cases as there is no way to tell 100% how your terminal will show a particular icon and therefore how much space it will take up but it should at lease improve things.

@MeanderingProgrammer
Copy link
Owner

@eofferma your issue maybe related. I don't think it is, but this actually could also account for the right shifting seen by @zenoli.

Yours looks like you are concealing some part of a checkbox in your own config, which isn't playing nicely with this plugin.

Do you have any custom highlights.scm that conceal either list marks or some part of a checkbox?

I quick way to check is if you create a markdown file with a single checkbox:

- [ ] A checkbox

Disable this plugin entirely. Set the conceallevel to 3: :set conceallevel=3. Then move your cursor off the line the raw text should be unchanged. You should still see:

- [ ] A checkbox

If something is hidden something in your config or another plugin is hiding it. Depending on what's going on I can potentially handle it better on my side as well, LMK what you find!

@MeanderingProgrammer
Copy link
Owner

Do either of you potentially use obsidian.nvim? It could be related to this: #67.

@eofferma
Copy link

@MeanderingProgrammer, thank you! It was the obsidian.nvim plugin that tried to make some changes to those icons as well. It can be resolved by adding to its configuration:

ui = {
   enable = false,
}

On the other hand, I tried the right_pad = 1 solution even with the obsidian.nvim UI enabled, and it works too.

Thanks!

@MeanderingProgrammer
Copy link
Owner

Awesome, I'll add a note to the README.

Since this has come up a few times I decided to see if there would be interest in using this plugin as the UI for obsidian.nvim: epwalsh/obsidian.nvim#664. Not sure where it'll go but thought it was worth considering.

@zenoli
Copy link
Author

zenoli commented Jul 25, 2024

I'm assuming the config you sent me is slightly off? The first and second values in the icons array appear swapped compared to the screenshot.

Yes, I think I changed them after I made the screenshot to further debug the issue, to rule out that this was having an impact. Sorry for the confusion.

Please update and set a value like: bullet = { right_pad = 1 } and see if it improves the look.
I was hoping to have such a config to play around with :-)
This actually fixed the issue for me!

@MeanderingProgrammer Wow, that an incredibly quick response and patch for my issue! Thank you very much :-)

@zenoli
Copy link
Author

zenoli commented Jul 25, 2024

The original issue can be fixed using the workaround of manually configuring the right_pad option.
The explanation of why a workaround is needed was outlined by @MeanderingProgrammer:

Due to just the vast number of ways different fonts, terminal emulators and associated configs can render text there is no great fix. In this case for some reason the icons appear shifted to the right, in other cases if there is space around an icon the terminal can make the icon larger to fill the space. Right shifting seems like the worse of these, but I can't begin debugging what exactly is going here without spending just too much time. I have done so for my own terminal configuration before.

Instead I provided a mediocre patch to allow bullets to add right padding here: 2c8be07.

Please update and set a value like: bullet = { right_pad = 1 } and see if it improves the look.

@zenoli zenoli closed this as completed Jul 25, 2024
@zenoli
Copy link
Author

zenoli commented Jul 28, 2024

@MeanderingProgrammer I just noticed that my original issue was most likely due to an outdated treesitter version. I no longer rely on the right_pad option and the bullet lists get rendered as expected. So my initial bug report was a false positive. Sorry for the inconvenience.

@MeanderingProgrammer
Copy link
Owner

Ah, that makes sense and is a good thing for me to be aware of in the future :)

The right_pad option might still be useful for people who like extra spacing around elements so will keep it around.

@MeanderingProgrammer MeanderingProgrammer added not a bug Not a bug in this plugin and removed bug Something isn't working labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug Not a bug in this plugin
Projects
None yet
Development

No branches or pull requests

3 participants