UDL 2.1: When an Operator is also a Delimeter
-
Hi all,
I’m writing a UDL that supports HTML tags and also uses “<” as an operator. You can see where this is going…
My goal is to highlight HTML tags, so I’ve included “<” and “>” as Delimiters. However, when I use “<” in an operation, it’s interpreted as a delimiter opening so everything following it is highlighted as if it were HTML, until it sees a closing “>”.
Here’s a screenshot of the UDL and how it renders:
I’ve searched through the forum and couldn’t find a direct resolution, so I’m thinking the solve is a bit more complex than what I can accomplish via the UDL GUI. To that end, could someone please point me in the right direction?
Cheers,
-Erin -
@Erin-D-Smale said in UDL 2.1: When an Operator is also a Delimeter:
I’m thinking the solve is a bit more complex than what I can accomplish via the UDL GUI.
I cannot think of an immediate way around it using the UDL itself.
However, you can add extra highlighting to anything in Notepad++ (whether using a builtin lexer or to a User Defined Language (UDL)) using regexes via the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo.So if you leave
<>
as the delimiter4 style in the UDL, you could use the PythonScript solution to search onr'\h[<>]\h'
(ie, search for less than or greater than as long as it has a horizontal space character (space or tab) to both the left and right of the operator) and apply a different color to those spaced-out instances of the angle-brackets (and you could make the PythonScript use the same color as your Operators’ Styler). -
@PeterJones - Thanks very much for the tip. I’ll give this a shot over the weekend and post results in case others have the same problem.
Cheers,
-Erin