Community
    • Login

    User Defined Language

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 479 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Eileen LingE Offline
      Eileen Ling
      last edited by

      Hello, I am currently trying to make my User Defined Language highlight some words depending on the context using delimiters but one of my delimiters ended up overlapping the other. I wanted to make different styles based on the parenthesis, like () and [] is one style and (] and [) is another style. The words in these (), [], [) and (] would also turned into that color based on the parenthesis. Therefore, I could not get the result I wanted. Is there a way to get what I am trying to achieve?

      What I am trying to achieve:

      [words] or (words) => would be in orange color
      0ffc25c8-b126-44d1-aa45-0a71bbf9b981-image.png
      (words] or [words) => would be in green color
      83f1a37a-ff0e-4ab2-9ee0-917ef166468d-image.png
      But the result i got was

      (words] or [words] ended up being orange color
      [words] and (words) were not affected
      e8117dd7-c63c-4ae4-b750-9b98a15c537a-image.png

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Online
        PeterJones @Eileen Ling
        last edited by PeterJones

        @Eileen-Ling ,

        With just the User Defined Language (UDL) syntax, what you want is probably not achievable.

        However, if you install the EnhanceAnyLexer plugin (using Plugins > Admin tool), then you can make sure your file has the right UDL active, then use Plugins > EnhanceAnyLexer > Enhance Current Language to edit the plugin’s config file. You can then define foreground color changes using “0xBBGGRR = regex” pairs.

        32d726da-3676-466c-b50b-0f889bb555b6-image.png

        [udf]
        ; color each word, 0x66ad1 is the color used, see the description above for more information on the color coding.
        0x0080FF = \([^)\\]]*?\)
        0x0080FF = \\[[^)\\]]*?\\]
        0x00FF80 = \([^)\\]]*?\\]
        0x00FF80 = \\[[^)\\]]*?\)
        ; check in the respective styler xml if the following IDs are valid
        excluded_styles = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23
        

        In my example, I defined four regular expressions: two will match the balanced `` and (...); the other two match the imbalanced [...) and (...]

        If you don’t want it to match multiline, change each of those four regex to have \r\n right after the ^, so that it doesn’t look for parenthesized text that spans across newline characters.

        note: mine used [udf] as the header, because I was in an unnamed UDL. If you follow my instructions above, yours will have [YourUdlNameHere] instead.

        1 Reply Last reply Reply Quote 3

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors