Community
    • Login

    custom syntax highlighting [JS]

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    13 Posts 2 Posters 10.5k Views
    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.
    • Claudia FrankC
      Claudia Frank
      last edited by

      Yes, in langs.xml add a new keywords tag with your keywords.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • Wolf WarW
        Wolf War
        last edited by

        @Claudia-Frank
        hmm I tried but without luck

        Claudia FrankC 1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank @Wolf War
          last edited by

          Hello @Wolf-War,

          as an example what I have done for python

          in langs.xml

              <Language name="python" ext="py pyw" commentLine="#">
                  <Keywords name="instre1">and as assert break class continue def del elif else except exec False finally for from global if import in is lambda None not or pass print raise return True try while with yield</Keywords>
                  <Keywords name="instre2">editor editor1 editor2 notepad console</Keywords>
              </Language>
          

          I added the a second keywords tag and named it instre2 with a given list of keywords.

          In Dark2012.xml (the theme that I use) I modified

              <LexerType name="python" desc="Python" ext="">
                  <WordsStyle name="DEFAULT" styleID="0" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="COMMENTLINE" styleID="1" fgColor="57A64A" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="NUMBER" styleID="2" fgColor="BD63C5" bgColor="1E1E1E" fontName="" fontStyle="1" fontSize="" />
                  <WordsStyle name="STRING" styleID="3" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="CHARACTER" styleID="4" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="KEYWORDS" styleID="5" fgColor="367DC6" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" keywordClass="instre1" />
                  <WordsStyle name="TRIPLE" styleID="6" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="TRIPLEDOUBLE" styleID="7" fgColor="C8C8C8" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="CLASSNAME" styleID="8" fgColor="8080FF" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="DEFNAME" styleID="9" fgColor="8080FF" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="OPERATOR" styleID="10" fgColor="FF8000" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="IDENTIFIER" styleID="11" fgColor="8DA6CE" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="COMMENTBLOCK" styleID="12" fgColor="57A64A" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="DECORATOR" styleID="13" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" />
                  <WordsStyle name="USERDEFINED" styleID="14" fgColor="D69D85" bgColor="1E1E1E" fontName="" fontStyle="0" fontSize="" keywordClass="instre2"/>
              </LexerType>
          

          the lexertype tag by adding a new word style with name USERDEFINED (can be any other name), styleID=14 (which was the next in row)
          and added keywordClass=“instre2” to reflect the changes in langs.xml.

          Did you do the same?

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • Wolf WarW
            Wolf War
            last edited by

            @Claudia-Frank
            thanx for your effort
            yes, I did that but in actual code there is not effect
            in Style Configurator everything is recognized (MY_KEYWORDS) but the words are not colored (green)

            Alt

            Claudia FrankC 1 Reply Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank @Wolf War
              last edited by

              @Wolf-War
              can you point me to the location from where you’ve downloaded the waher style?
              I would give it a try to test and see what the problem is.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              • Wolf WarW
                Wolf War
                last edited by

                @Claudia-Frank
                I’m not sure where I download it from, long time ago
                but here is the file that I’m using (uploaded to Gdrive)

                Claudia FrankC 1 Reply Last reply Reply Quote 0
                • Claudia FrankC
                  Claudia Frank @Wolf War
                  last edited by

                  @Wolf-War

                  you are right, it doesn’t work with javascript.
                  First I tried my python changes, which worked fine but changing the same for javascript doesn’t work.
                  As you said, we are seeing the new keywords but different coloring doesn’t happen.

                  Need to investigate this.

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • Wolf WarW
                    Wolf War
                    last edited by

                    @Claudia-Frank
                    thank you for confirming this

                    Claudia FrankC 1 Reply Last reply Reply Quote 0
                    • Claudia FrankC
                      Claudia Frank @Wolf War
                      last edited by

                      @Wolf-War

                      ok, short answer, javascript doesn’t support it.

                      Longer answer javascript doesn’t support all keyword class names, which would be

                      • instre1
                      • instre2
                      • type1
                      • type2
                      • type3
                      • type4
                      • type5

                      It only supports instre1, instre2 and type1 - hardcoded in source (),
                      the same applies to the styles names like number, word, keyword …
                      You can define a new style name but it never gets used.

                      Beside this, waher.xml has to name it javascript.js

                      <LexerType name="javascript.js" desc="JavaScript" ext="">
                      

                      as javascript has become the embedded one.

                      Cheers
                      Claudia

                      1 Reply Last reply Reply Quote 0
                      • Wolf WarW
                        Wolf War
                        last edited by

                        @Claudia-Frank
                        ok, tnx again
                        at least I didn’t screw it :)
                        cheers

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors