Help fixing strange syntax highlighting with hocon grammar #6253
-
Hi, I've noticed the syntax highlighting of hocon on Github appears to be broken, but I can't reproduce the strange highlighting when I use the same grammar in an editor:
An even smaller case is: foo = "bar" ( the string should be highlighted) I was wondering if anyone had any thoughts on how this can be fixed, I'm more than happy to submit/suggest PRs upstream to the grammar repo if necessary. Unsure if this is relevant, but using https://umanghome.github.io/NovaLightshow/ with the grammar gives the error
Though converting the grammar from cson to json gives correct highlighting. For reference the grammar is located here: https://github.com/jacobwgillespie/language-hocon/blob/master/grammars/hocon.cson Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
The difference in behaviour is usually down to the use of Oniguruma-specific regexes. Atom uses Oniguruma (as does NovaLightShow) for the regex engine whilst GitHub uses PCRE for performance reasons. There's also the possibility there's an error which GitHub is less tolerant of than Atom. I'm rubbish with grammars, but maybe @Alhadis or @Nixinova can spot the problem. |
Beta Was this translation helpful? Give feedback.
-
The highlighting issues on NovaLightshow's end are from fabiospampinato/cson2json#1. I should look into switching packages to avoid that.
Hm, none of the regexes used have anything non agnostic to them. |
Beta Was this translation helpful? Give feedback.
-
I suspect this may have something to do with the malformed rule at lines 43-49: match: '(?:^[ \t]*([\\w-]+)\\s*?({|=|:))'
captures:
'1':
'name': 'entity.name.tag.hocon'
'2':
'name': 'punctuation.separator.key-value.hocon'
end: '(\\=|{)' You've specified an |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the input
👍 I've opened a PR for it here: jacobwgillespie/language-hocon#7 (comments welcome), let's see what the maintainer says. As an aside, is there a way to be sure the change will work prior to a new release? |
Beta Was this translation helpful? Give feedback.
I suspect this may have something to do with the malformed rule at lines 43-49:
You've specified an
end
pattern without an accompanyingbegin
pattern, and done so whilst including amatch
field (which is mutually exclusive to abegin
/end
pair). GitHub and Atom probably differ in their handling of malformed grammar rules, accounting for the discrepancy that you've witnessed.