MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.39k stars 33 forks source link

bug: Headlines Not Displaying Correctly in Quarto Files (.qmd) #49

Closed bassamsdata closed 2 months ago

bassamsdata commented 2 months ago

Neovim version (nvim -v)

0.10.0

Operating system

MacOS

Terminal emulator / GUI

WezTerm

Describe the bug

Headlines don't appear correctly in Quarto files (.qmd). The more nested the headlines are, the more letters are hidden from the beginning of the line. The video below illustrates the issue clearly. Kapture 2024-07-06 at 12 26 35

Expected behavior

show the headlines correctly.

to reproduce:

  1. create quarto file: touch testQuarto.qmd
  2. paste the below code in it.
    
    ---
    title: "Premier League clubs best and worst seasons"
    format:
    html:
    code-fold: true
    code-link: true
    code-summary: "Show the code"
    code-tools: true
    theme:
      light: cosmo
      dark: darkly
    execute:
    echo: fenced
    ---

Create a chart for clubs

chart to look for best and worst seasons based on points, gF, gA, xgF, xgA

Load libraries

Load libraries


### Healthcheck output (:checkhealth render-markdown)

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

markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown_inline: parser installed
- WARNING latex: parser not installed
  - ADVICE:
    - If you do not want LaTeX support avoid this warning by setting { latex_enabled = false }
- OK highlights enabled

markdown.nvim [executables] ~
- WARNING latex2text: not installed
  - ADVICE:
    - If you do not want LaTeX support avoid this warning by setting { latex_enabled = false }

markdown.nvim [configuration] ~
- ERROR Invalid key: file_types.2
- ERROR Invalid key: file_types.3

### Additional information

here is my config:
```r
  {
    "MeanderingProgrammer/markdown.nvim",
    ft = { "markdown", "rmd", "quarto" },
    name = "render-markdown",
    dependencies = { "nvim-treesitter/nvim-treesitter" },
    opts = {
      file_types = { "markdown", "rmd", "quarto" },
    },
  },

Thank you

MeanderingProgrammer commented 2 months ago

I think I know what's going on here.

This plugin assumes default conceal behavior in markdown files. Currently the heading prefix ###, is not concealed by default.

Do you have any custom highlights that set conceal on atx_h1_marker etc.?

bassamsdata commented 2 months ago

Thank you for the response, and yes, you’re right. There was some highlighting related to atx_h1_marker as shown in the Inspect command image below:

Screenshot 2024-07-07 at 2 25 56 AM

After debugging, I discovered the issue was due to enabling regex highlights in Markdown files via Tree-sitter with additional_vim_regex_highlighting = { "markdown" },. What struck me was that the issue didn't appear in Markdown files, only in Quarto files.

Thank you again for your reply; the issue is now resolved.

MeanderingProgrammer commented 2 months ago

Strange, it does seem like this should also have been an issue on markdown files.

Will work on handling these cases better in general, assuming concealing behavior is going to lead to inconsistencies, though I'm not sure of a better way to handle it at the moment.

Glad it's working now!

MeanderingProgrammer commented 2 months ago

I did push a fix for this here https://github.com/MeanderingProgrammer/markdown.nvim/commit/5ce35662725b1024c6dddc8d0bc03befc5abc878, if you want to re-enable the concealing behavior and are using neovim >= 0.10.0.

marty-oehme commented 1 month ago

Edit: with the pushed fix above (and neovim 0.10.0), everything does work wonderfully. Leaving this small fix here for those that still have issues.

Just wanted to chime in that I seem to have stumbled upon the same (I think?) issue with headlines getting cut off exactly like for @bassamsdata in the original post.

However, I have both additional_vim_regex_highlighting = false (not set to {"markdown"}) and my :Inspect output only lists the following syntax: img-2024-07-29-22-42-25

The only way I have found to get rid of this behaviour for now is to set a lower conceallevel for this plugin through the setup function, e.g. (using the lazy.nvim opts key):

opts = {
    file_types = { "markdown", "quarto" },
    win_options = {
        conceallevel = {
            rendered = 2,
        },
    },
}

Anyway, for now this works reasonably well for my purposes and maybe it can help somebody else out that stumbles into the issue.

Thanks you for the amazing plugin!

LJFRIESE commented 3 weeks ago

For whatever it's worth, I think there may be more going on with the highlighting for quarto: https://github.com/quarto-dev/quarto-nvim/issues/25

It looks light there is weirdness going on with highlighting in Quarto already, possibly because of how it integrates pandoc and other stuff. The maintainer is very responsive.