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
Regex fix to not match font name "Crimson Text". #158
base: master
Are you sure you want to change the base?
Conversation
I understand the annoyance aspect but I really don’t like the idea of patching in exceptions for specific phrases in this way. This looks reasonable now when there are no other workarounds, but the list of exceptions is completely open-ended; what would the code look like after a couple dozen? I’d be more interested in a patch that makes CSS Color never highlight things in the value of a This may not be too hard, either. In some sample code like this: foo {
color: bar;
background: bar;
font: bar;
} … the CSS syntax recognises the But it might be possible to restrict this plugin’s If it is, your problem with Crimson Text would go away, but so would every other inappropriate highlighting, without any exceptions specific to any particular font names or other strings. |
Yes, that is a way better solution, thank you for the thoughtful response. The main reason I thought this would perhaps be acceptable is because I saw that it had already been done in file: But in any case I don't think I have the kind of knowledge of css to be of much (or any) help regarding which groups can contain color names or other identifiers in meaningful ways (as opposed to being written there in error), and though I have written some vim code and regex, and would like to help, I haven't figured out where this sort of matching is done or how. I've been looking mainly at the create_syn_match function, and understand some of it, but... Do you have a breakdown written somewhere that I could take a look at? One last thing: could this possibly be done, I ask as a css novice, by only matching when the color name is immediately followed by any of these: [,;}\n] ? and maybe also when there is a space and then any of those, for safety? |
Yes, that’s well spotted. I hadn’t thought of it in a long time. I put that in reluctantly, but the impetus for it is the And it could finally be removed if the matching was more context-sensitive. That’s a very good point.
That won’t fly due to properties like
Not really. But the least straightforward parts of that code as such are ① that it expects to be called from the replacement string of a The actually non-straightforward part isn’t in the code for The real work then happens in the Vim syntax highlighting engine. And the trick to that part is In the case of So no matter what highlights Sooo… The question at hand is then: is it possible to tell Vim not to just limit matching Maybe not directly; it’s possible that Or… something. I don’t know yet. But the upshot is that the place to start is not so much this plugin’s own code but ⓐ how a syntax is defined in the Vim syntax highlight engine in general and ⓑ what the built-in (To be frank, this would be a bit of a rainy-day enterprise on my end. But I’d very much love to see it happen. The key principle of this plugin and its biggest distinction over all comparable ones is specificity in what it highlights, so that it won’t over-highlight. I’m very much interested in ratcheting that up further.)
|
I don't know if the regex is as good as it could be, but this fixed an annoyance for me so I'm at least offering it.