UDL Delimiter after break and whitespace only
Ruby Goody last edited by
I’m trying to make a UDL for markdown and everything works, except when the character # is used in the middle of a text. Then suddenly the rest of the text becomes styled like a heading.
How can I make sure my # delimiter styling only happens when the character # only appears after newline and whitespace… I tried regexp before, but it doesn’t work or N++ uses other regexp here?
PeterJones last edited by PeterJones
Notepad++'s UDL system does not accept regexp.
Thus the UDL system as designed cannot differentiate between a # at the beginning of the line and one in the middle of the line for delimiters and operators. That is a limitation of the UDL system. But if you look at the Markdown (preinstalled) UDL that ships with Notepad++ (which you could be using, rather than defining your own, BTW), it uses the Comment line style for headers, and the Comment Line can require that the comment line only start at the beginning of the line, or only at the beginning of the line (with optional whitespace). So by using Comment Line instead of Operator or Delimiter, it should work as expected.
If that’s not sufficient, but you are willing to use a plugin to help things out, the EnhanceAnyLexer plugin will allow adding a layer where a regex is used to decide on the foreground color for individual built-in lexers or UDL languages. You can install that plugin from the Plugins Admin interface in Notepad++. To use that plugin, you would define your UDL without defining # for headers; then you would use Plugins > EnhanceAnyLexer > Enhance Current Language, and then add a line in the config file where the plugin started you, something like
0x0080FF = ^\h*#.*$
… which would convert the entire line to orange foreground if it starts with zero or more spaces or tabs followed by a #