EmEditor syntax highlighter matching priority / precedence: Flawed?
EmEditor’s highlighter would allow full customisation by using regex matches.
→ Emphasis on would.
Example 1: Javascript template string literal.
Regex: ‵.*?‵
→ Strings and comments in the regex result in the regex being ignored 😧
Example 2: Same as example 1, but with custom double quoted string detection.
Template string regex: ‵.*?‵
Double quoted string regex: ".*?"
→ Same flaw 😞
Example 3: Same as example 2, but with custom string and comment detection.
Template string regex: ‵.*?‵
Double quoted string regex: ".*?"
Line comment regex: //.*$
→ Same flaw 😭
Is this intended?
Did I miss a setting in the options?
How could I achieve the desired effect?
This is currently by design, as " and // are given higher priority than other general highlights.
Hello Yutaka,
Thank you for your feedback so far!
This is currently by design, as ” and // are given higher priority than other general highlights.Perhaps you missed my last example, where
" and // are disabled and only regex highlighting is used (guess I posted too many examples).
Motivated by your response, I've now looked into this a bit deeper and narrowed down the cause.
The problem arises when a regex matches multiple characters, i.e. when using * or + or {3,} etc.
The following is an updated example, putting aside " and //:
Two regex matches are active, all string and comment matches are disabled.
″.*?″ regex match 1/2
%%.*$ regex match 2/2
Same problem:
EmEditor stops matching ″.*?″ as soon as it encounters %%.*$, even though the regex match for ″.*?″ has not yet been completed.
Would this be difficult to fix?
Because it is a serious limitation. One could write much more accurate highlighters than what is currently possible.
Your help is greatly appreciated.
Many thanks!
Patrick
3 posts in this topic