quarto-nvim icon indicating copy to clipboard operation
quarto-nvim copied to clipboard

Subscript highlighted as strikethrough

Open Aman9das opened this issue 1 year ago • 3 comments

In quarto markdown format, subscript~1~ creates subscript₁

But in the syntax highlighting, image is shown.

ref: https://quarto.org/docs/authoring/markdown-basics.html#text-formatting

Aman9das avatar Mar 14 '24 06:03 Aman9das

That's a limitation of using the treesitter markdown grammar also for quarto. You can overwrite the highlighting by taking the query file from https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/markdown_inline/highlights.scm , adding it to your own config at queries/markdown_inline/highlights.scm and replacing:

(strikethrough) @markup.strikethrough

with

(strikethrough
(emphasis_delimiter) 
(strikethrough 
  (emphasis_delimiter) 
  (emphasis_delimiter)) 
(emphasis_delimiter))@markup.strikethrough 

such that only double ~~ cause a strikethrough highlight.

jmbuhr avatar Mar 14 '24 10:03 jmbuhr

Can this be implemented only for quarto files. Like inside ftplugin.

Also I saw this about overriding queries, but didn't understand properly where to put what: https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries

Aman9das avatar Mar 14 '24 11:03 Aman9das

I got it to work half-way (see commit to my config linked above): On quarto files the window highlighting is overwritten such that strikethrough is no longer strikethrough and only the additional highlight group (should answer your question about where to put those) with two tildes is strikethrough.

Caveat: The highlight group namespace is set per window, not per buffer i.e. if you open a markdown file in the same window as the quarto file it will get the same treatment.

jmbuhr avatar Mar 14 '24 15:03 jmbuhr