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

html syntax highlight misses on single tags #1196

Closed
jvvv opened this issue Jun 17, 2024 · 7 comments · Fixed by #1197
Closed

html syntax highlight misses on single tags #1196

jvvv opened this issue Jun 17, 2024 · 7 comments · Fixed by #1197

Comments

@jvvv
Copy link
Contributor

jvvv commented Jun 17, 2024

Single html tags like hr, input, and meta (etc) aren't getting highlighted.
My lua knowledge is pretty sparse, but here's a work-around that is working for me so far:

From 69243d5a88623f5e7d08eb79b827ad31aa893ece Mon Sep 17 00:00:00 2001
From: jvvv
Date: Mon, 17 Jun 2024 13:16:17 -0400
Subject: [PATCH] fix syntax highlight for html single tags

---
 lua/lexers/html.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lua/lexers/html.lua b/lua/lexers/html.lua
index 9146b63..a0ce2e7 100644
--- a/lua/lexers/html.lua
+++ b/lua/lexers/html.lua
@@ -16,7 +16,7 @@ lex:add_rule('doctype',
 
 -- Tags.
 local paired_tag = lex:tag(lexer.TAG, lex:word_match(lexer.TAG, true))
-local single_tag = lex:tag(lexer.TAG .. '.single', lex:word_match(lexer.TAG .. '.single', true))
+local single_tag = lex:tag(lexer.TAG, lex:word_match(lexer.TAG .. '.single', true))
 local known_tag = paired_tag + single_tag
 local unknown_tag = lex:tag(lexer.TAG .. '.unknown', (lexer.alnum + '-')^1)
 local tag = lex:tag(lexer.TAG .. '.chars', '<' * P('/')^-1) * (known_tag + unknown_tag) * -P(':')
-- 
2.45.2

I'm running vis built from git HEAD on alpinelinux edge.
I can also report this upstream to scintillua if that is desired.

@mcepl
Copy link
Contributor

mcepl commented Jun 18, 2024

vis is taking its lexers from https://github.com/orbitalquark/scintillua, please, file your issue report there, and we will take it from them (of course, you are more than welcome to initiate another round of synchronization with their code).

@rnpnr , I think, this could be closed.

@mcepl
Copy link
Contributor

mcepl commented Jun 18, 2024

Otherwise, added as a commit to https://git.cepl.eu/cgit/vis/vis/commit/?id=5629ca0091c2 and after testing, I will submit it upstream.

@jvvv
Copy link
Contributor Author

jvvv commented Jun 18, 2024

Just submitted: orbitalquark/scintillua#114

@rnpnr
Copy link
Collaborator

rnpnr commented Jun 18, 2024

This can stay open for now. We can bulk pull in the changes once its resolved upstream.

@jvvv
Copy link
Contributor Author

jvvv commented Jun 19, 2024

Ok, got some good help from orbitalquark. There are tags that handle this case here but are not in the themes. I will post a PR soon that will solve this issue more correctly, but might first spend some time looking for similar issues with tags in other lexers that are not handled by the themes. The patch I suggested when I opened this is not correct.

What is needed is something like this in the themes:

lexers.STYLE_TAG_SINGLE = lexers.STYLE_TAG
lexers.STYLE_TAG_DOCTYPE = lexers.STYLE_TAG

or

lexers.STYLE_TAG_UNKNOWN = 'fore:magenta'
lexers.STYLE_TAG_SINGLE = lexers.STYLE_TAG
lexers.STYLE_TAG_DOCTYPE = lexers.STYLE_TAG .. ',italics'

or how ever seems more appropriate.

These are just the ones that I noticed so far, mainly because both were not getting styled.
I included STYLE_TAG_UNKNOWN because that was what helped me get a clue about
how to translate the scintillua tag to style/theme language.

@rnpnr
Copy link
Collaborator

rnpnr commented Jun 19, 2024

Oh I see now; those should actually be available to style but are just not included in the default themes. This line:

vis/lua/vis.lua

Line 287 in a7aac10

local style = lexers['STYLE_' .. token_name:upper():gsub("%.", "_")] or ''

replaces the . in the names with a _. If you add something like lexers.STYLE_TAG_SINGLE = '...' to your theme it should just work.

I don't have a good way of indicating all possible combinations in the themes besides just adding them and letting people tweak for their own preferences.

@jvvv
Copy link
Contributor Author

jvvv commented Jul 5, 2024

I had hoped to prepare a more expansive set of changes. #1197 will have to do for now until I have more time.

@rnpnr rnpnr closed this as completed in 2dbe2ca Jul 26, 2024
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

Successfully merging a pull request may close this issue.

3 participants