Custom Styles for 'Special' Comments



  • I have html code which has special tags embedded in comments which I would like to display in a custom style in Notepad++. I’ve tried adding these special tags to keywords or operators/delimiters in the UDL, but the comments style seems to have precedence.

    Is there any way to do this?

    Thanks,

    Tom



  • @Thomas-Benedict said in Custom Styles for 'Special' Comments:

    I have html code which has special tags embedded in comments which I would like to display in a custom style in Notepad++. I’ve tried adding these special tags to keywords or operators/delimiters in the UDL

    So I see a conflict: do you want to use a UDL (Language > Define Your Language) for styling HTML, or the builtin HTML lexer (Settings > Style Configurator > HTML)? The two don’t mix: you can have only one active lexer at a time.

    If as a UDL, there are nuances that you will lose, but you can define any keywords you want, in multiple groups. And you can set the comment syntax so that it allows nesting of other keyword groups that you want. See the UDL section in the usermanual

    If using the builtin HTML lexer, unfortunately Settings > Style Configurator > HTML dialog doesn’t seem to list any styles that have user-defined keywords. And even if you could, I think comments would override that.

    However, there are workarounds:

    • you can add extra highlighting to a builtin lexer (like the HTML lexer) using regexes via the script EnhanceAnyBuiltinLexer.py that @Ekopalypse shares, in this linked post
    • you can add extra highlighting to a UDL language using regexes via the script EnhanceUDLLexer.py that @Ekopalypse shares in this linked post


  • @PeterJones said in Custom Styles for 'Special' Comments:

    So I see a conflict: do you want to use a UDL ([Language > Define Your Language](https://npp-user-manual.org/docs/user-
    If using the builtin HTML lexer, unfortunately Settings > Style Configurator > HTML dialog doesn’t seem to list any styles that have user-defined keywords. And even if you could, I think comments would override that.

    I was hoping to simply modify the built in HTML lexer. Thanks for confirming that that is not possible.

    However, there are workarounds:

    • you can add extra highlighting to a builtin lexer (like the HTML lexer) using regexes via the script EnhanceAnyBuiltinLexer.py that @Ekopalypse shares, in this linked post
    • you can add extra highlighting to a UDL language using regexes via the script EnhanceUDLLexer.py that @Ekopalypse shares in this linked post

    I will check these out, but regex is usually challenging for me. I’ll give it a go.

    Thanks again,

    Tom Benedict



  • This post is deleted!

Log in to reply