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

Subscript highlighted as strikethrough #122

Open
Aman9das opened this issue Mar 14, 2024 · 3 comments
Open

Subscript highlighted as strikethrough #122

Aman9das opened this issue Mar 14, 2024 · 3 comments

Comments

@Aman9das
Copy link

Aman9das commented Mar 14, 2024

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

@jmbuhr
Copy link
Collaborator

jmbuhr commented Mar 14, 2024

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.

@Aman9das
Copy link
Author

Aman9das commented Mar 14, 2024

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

jmbuhr added a commit to jmbuhr/quarto-nvim-kickstarter that referenced this issue Mar 14, 2024
@jmbuhr
Copy link
Collaborator

jmbuhr commented Mar 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants