Tagged: syntax highlighter
- AuthorPosts
- June 7, 2025 at 11:10 am #30274
Patrick C
ParticipantEmEditor’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?June 13, 2025 at 10:01 am #30280Yutaka Emura
KeymasterThis is currently by design, as ” and // are given higher priority than other general highlights.
June 14, 2025 at 10:09 am #30291Patrick C
ParticipantHello 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/2Same 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 - AuthorPosts
- You must be logged in to reply to this topic.