Community
    • Login

    Changing YAML Highlighting

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 13.4k 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.
    • CH4CodeC
      CH4Code
      last edited by

      Hi,
      a project I am contributing to uses YAML style files, but has some additional syntax and changed the indentation style (tabs instead of 4xspaces). So it’s yaml but not really yaml. Which messes up the highlighting in np++.

      1. Now, I tried to reproduce YAML syntax highlighting with notepad++s UDL, planning to then make the changes I need. After trying this for some time I’m asking myself if that is even possible or is YAML highlighting a special case and hardcoded into np++?

      2. Is there a way to export the existing highlighting rules for yaml from np++ to UDL?
        Alternatively: Do you know a source for xml highlighting rules for YAML which I then could use in langs.model.xml?

      3. langs.model.xml has a line tabSettings=“132” at the yaml definition which appears nowhere else. If I knew what to replace 132 with to get tabs instead of 4xSpace would also be very helpful as a workaround.

      4. If above are not possible how do I at least transfer the YAML highlighting from “default” to “bespin” styles?

      Thank you very much for your help!

      1 Reply Last reply Reply Quote 0
      • dailD
        dail
        last edited by

        1. … if that is even possible or is YAML highlighting a special case and hardcoded into np++?

        Technically all highlighting is “hardcoded” into N++ because they are written in C++. N++ does not contain any UDLs by default. I don’t use UDL often enough to know if creating a YAML-like language is possible.

        1. Is there a way to export the existing highlighting rules for yaml from np++ to UDL?

        No. The existing highlighting and UDLs work completely differently.

        1. langs.model.xml has a line tabSettings=“132”

        In hex this value is 0x84 which is a combination of 0x80 (which is a flag to indicate the use of spaces) and 0x02 which is the number of spaces to use. For example if you wanted to use a tab with a width of 4 you’d use a value of 0x04 which is to no surprise 4 in decimal.

        1. If above are not possible how do I at least transfer the YAML highlighting from “default” to “bespin” styles?

        You would have to add that information to the bespin.xml theme file. The default style looks like this (below), so you’d have to modify the colors manually and add it to the file.

        <LexerType name="yaml" desc="YAML" ext="">
            <WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            <WordsStyle name="IDENTIFIER" styleID="2" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
            <WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            <WordsStyle name="INSTRUCTION WORD" styleID="3" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
            <WordsStyle name="NUMBER" styleID="4" fgColor="FF8040" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            <WordsStyle name="REFERENCE" styleID="5" fgColor="804000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            <WordsStyle name="DOCUMENT" styleID="6" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            <WordsStyle name="TEXT" styleID="7" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
            <WordsStyle name="ERROR" styleID="8" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
        </LexerType>
        
        1 Reply Last reply Reply Quote 1
        • CH4CodeC
          CH4Code
          last edited by

          Thank you for your elaborate answer, however my problem remains.

          tabSetting seems to influnce the width of a tabulator. It does not switch between spaces and tabs as relevant for the syntax of the language, just the appearance. So that doesn’t help.

          I have no idea where that bespin.xml is saved, so I can’t manipulate it. Certainly not in the np++ folder or in MyDocuments. The bespin theme is also not metioned in any of the other xml files, no leads given…
          Edit: I have found Bespin.xml on npp github, but the location I need to put it into doesn’t exist on my machine…

          I think what I want is just out of scope for np++. Great editor nonetheless.

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