Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Style configuration not working

    Help wanted · · · – – – · · ·
    2
    3
    458
    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.
    • Mikel Cortés
      Mikel Cortés last edited by

      The word “getElementById” is defined as a keyword for JavaScript languaje (default configuration).
      But in my JavaScript files “getElementById” does not apply the style configuration if it is preceded by any word and a dot or followed by a dot.

      NotepadPlusPlus.png

      ¿How can this be solved?

      Thanks a lot!

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @Mikel Cortés last edited by

        @Mikel-Cortés ,

        Based on what you showed, you either have a really old Notepad++ (sharing ? menu, Debug Info would be helpful); or you used to have a really old Notepad++ and upgraded, but the styler and theme config files as well as langs.xml weren’t updated to match the newest version; or you have a fresh install of a recent version, but the Mikel theme (which doesn’t, AFAIK, ship with Notepad++) maybe hasn’t been updated to match the modern lexer libraries.

        I say this because your Language selector only shows JavaScript, it does not list both JavaScript and JavaScript (embeded), because they are implemented separately now. The “embeded” highlighting is used when you have an HTML file with a <script> tag. The non-embeded is when you have a .js file or similar, or otherwise set Language > J > JavaScript. Also, the modern langs.xml config file doesn’t have getElementById in the default list of keywords for either (which is odd, IMO).

        In my v7.9.2, if I add getElementById to the User-defined keywords list for the JavaScript > WINDOW INSTRUCTION, and have set Language > J > JavaScript, then it highlights as expected:
        443d8ff5-e08a-4c84-8114-dbdd9c3a6cdd-image.png
        If I set Language > H > HTML with adding getElementById to the User-defined keywords for JavaScript (embedded) > KEYWORD, and wrap the code in a <script> tag, then I get similar to what you showed:
        ae506dc3-38cd-43d6-bed3-d32552ce1e22-image.png

        So it looks like the embedded-JavaScript-in-HTML parser doesn’t handle all the normal situations for keywords; I would say that’s a bug you should report, but the bug would be in the HTML+embedded lexer that’s comes from the Scintilla library, so you’d have to report the bug to Scintilla first (and they seem to be focused on things other than the lexers), then they’d have to implement it and release it, then you’d have to ask Notepad++ developers to update the Scintilla component in Notepad++, and they’d have to decided to do it (which rarely happens – usually years between such upgrades, because it’s a lot of work on their part), and then you’d have to wait for them to do it, and… by then, you might not be programming in JavaScript anymore because AI’s have taken over. ;-)

        Anyway, as a workaround, you can add extra highlighting to a builtin lexer (like the HTML lexer) or to a User Defined Language (UDL) using regexes via the script EnhanceAnyLexer.py that @Ekopalypse shares in his github repo, which requires the PythonScript plugin. With that, you could add a regex for JavaScript (embedded) which will highlight getElementById (and similar) in the contexts that are missing from that lexer’s repertoire.

        1 Reply Last reply Reply Quote 1
        • Mikel Cortés
          Mikel Cortés last edited by

          Thanks for your reply @PeterJones

          I have reinstalled Notepad ++ last version and now “JavaScript (embedded)” appears on my list; but as you have said the issue continues.

          It seems that “.” is not considered as a word separator to identify keywords to apply the style configuration.

          NotepadPlusPlus.png

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors