Community
    • Login

    How to use characters like \t or others for style some lines?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    udl
    7 Posts 3 Posters 997 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.
    • Dogtor ColmilloD
      Dogtor Colmillo
      last edited by Dogtor Colmillo

      Hi! I am developing a standard to quickly and easily write a text file that can be converted into a word document with their respective formats and styles.

      The structure of the txt file is:
      For titles: Nlvl\tTitle. Ex: 1 The general title.
      For lists: \t*.A list item.
      For text with footnotes: \t*.This word^ has a footnote.
      For footnotes: ^\t*.This is the footnote.
      For default bold text: \tSomething in bold: And the rest in normal.
      For forced bold text: \tThe next *word* is bold.

      Marks for titles may be from 1 to 9, followed by a tab character.
      Other marks at the beginning of the line may be “?\t” for a paragraph highlighted in red, or “^\t” for footnotes in small size, and others.

      The style for words with delimiters can be *something* for bold, _something_ for underline, /something/ for italic, and others.

      With UDL can I do this? Or not?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Dogtor Colmillo
        last edited by

        @Dogtor-Colmillo ,

        With UDL can I do this? Or not?

        UDL by itself cannot use tab (\t) as a trigger/keyword or part of a symbol (like requiring integer followed by tab to be the start of a title/header).

        So no, UDL cannot handle that part.

        But it can easily handle *word* being the marker to show the text (and delimiters) as bold, by setting up */* as a Delimiter pair with the right Style settings.

        0d229311-c956-4ce2-b5c1-f8236726533a-image.png

        There is a plugin called EnhanceAnyLexer which can be used to change the font color of a piece of text based on a regular expression, so in the configuration for that plugin,

        [MyUDL]
        0xFF0000 = ^\d+\t.*$
        

        would make any line that starts with one or more integers followed by a tab colored dark blue.

        f975b489-7d3b-4a31-895a-ff2756f3f79c-image.png
        (I was showing an example with the default name of “User-Defined” in the Langauge menu, which uses [udf] as the section header; but if you have your UDL named MyUDL, then [MyUDL] or [myudl] will be the name of the section in the config file; the plugin will automatically name it correctly for you by using Plugins > Enhance Any Lexer > Enhance Current Language)

        I am developing a standard to quickly and easily write a text file that can be converted into a word document with their respective formats and styles.

        If you think you can do better than HTML or Markdown or MediaWiki Syntax or BBCode or … (in other words, I am pointing out that this is a problem that has been solved a gazillion times; are you sure it’s worth re-inventing the wheel on?)

        Dogtor ColmilloD 2 Replies Last reply Reply Quote 5
        • Dogtor ColmilloD
          Dogtor Colmillo @PeterJones
          last edited by Dogtor Colmillo

          @PeterJones thanks for the answer, is very helpful.

          No, I don’t think I can do better… but HTML and BBCode are very messy in terms of reading. I need to simply, naturally and cleanly read and write a txt file with some special characters (or pseudo-tags) that can be interpreted by a program made by me, to generate Docx documents and even (eventually) HTML documents.

          Vs Markdown, for example there are some alternatives such as “Something: other things.”, where Something in my markup rules would be considered bold, unless I use “Something\: other things.”.

          1 Reply Last reply Reply Quote 0
          • Dogtor ColmilloD
            Dogtor Colmillo @PeterJones
            last edited by

            @PeterJones excuse me a question, is there any plug-in with which I can do something similar to what EnhanceAnyLexer does, but that allows to change the font type and/or size?

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Dogtor Colmillo
              last edited by

              @Dogtor-Colmillo ,

              is there any plug-in with which I can do something similar to what EnhanceAnyLexer does, but that allows to change the font type and/or size?

              Not that I know of. EnhanceAnyLexer was the first plugin that I know of to try to be a generic lexer-enhancer, but it was written as simply as possible (just changing foreground color). If you know the V programming language, you could probably give Eko a PR that enhances it to adjust background and maybe font/size as well… or you could look back though the forum to find the original script version that ran in the PythonScript plugin, and customize that one using Python code to change other attributes. But it doesn’t currently exist that I know of.

              Dogtor ColmilloD 1 Reply Last reply Reply Quote 1
              • Dogtor ColmilloD
                Dogtor Colmillo @PeterJones
                last edited by Dogtor Colmillo

                @PeterJones thanks anyway, your help was very very helpful and I got a result very close to what I need:
                https://imgur.com/vGoTbKd

                1 Reply Last reply Reply Quote 1
                • EkopalypseE
                  Ekopalypse
                  last edited by

                  EnhanceAnyLexer uses indicators to highlight the text in question and these do not have access to font attributes. More precisely, as of today, indicators only have the possibility to change the foreground color. The reason why indicators are used is simple, lexers use styles and EnhanceAnyLexer should not compete with Lexers for this resource.

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