Community
    • Login

    Markdown UDL Help

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    markdown udl
    8 Posts 3 Posters 1.8k 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.
    • D
      dcog989
      last edited by PeterJones

      The default UDL / User Defined Language file for Markdown is incomplete and not formatting correctly for some elements - e.g. changing text color when it should only be bold.

      So, I have created an updated one which adds missing (e.g. ‘==highlighted text==’) formatting and corrects other issues. However, there’s a couple of issues I can’t correct - either because the UDL editor is lacking or I am.

      1. using ‘*’ to start an unordered list is incorrectly picking up italic from the content formatting of ‘*’

      2. the formatting for blockquote ‘>’ is being applied when ‘>’ is used in content - i.e. it should only apply when used at beginning of line

      I’d like to get these fixed before submitting this UDL as new default. Suggestions please?

      Test file and UDL - the forum won’t let me link to download file, sooo…

      D rdipardoR 3 Replies Last reply Reply Quote 1
      • D
        dcog989
        last edited by

        Markdown UDL:

        <NotepadPlus>
            <UserLang name="Markdown 2" ext="md markdown" udlVersion="2.1">
                <Settings>
                    <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="2" decimalSeparator="0" />
                    <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="yes" Keywords5="yes" Keywords6="yes" Keywords7="yes" Keywords8="yes" />
                </Settings>
                <KeywordLists>
                    <Keywords name="Comments">00# 01 02((EOL)) 03&gt; 04((EOL))</Keywords>
                    <Keywords name="Numbers, prefix1"></Keywords>
                    <Keywords name="Numbers, prefix2"></Keywords>
                    <Keywords name="Numbers, extras1"></Keywords>
                    <Keywords name="Numbers, extras2"></Keywords>
                    <Keywords name="Numbers, suffix1">.</Keywords>
                    <Keywords name="Numbers, suffix2">.</Keywords>
                    <Keywords name="Numbers, range"></Keywords>
                    <Keywords name="Operators1">@ &lt; &gt; \&lt; \&gt; \\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \! \~ \| |:-: |:--: |:---: | :-: :--: :---: :|: |: :|</Keywords>
                    <Keywords name="Operators2">- + :- :-- :--- :</Keywords>
                    <Keywords name="Folders in code1, open"></Keywords>
                    <Keywords name="Folders in code1, middle"></Keywords>
                    <Keywords name="Folders in code1, close"></Keywords>
                    <Keywords name="Folders in code2, open"></Keywords>
                    <Keywords name="Folders in code2, middle"></Keywords>
                    <Keywords name="Folders in code2, close"></Keywords>
                    <Keywords name="Folders in comment, open"></Keywords>
                    <Keywords name="Folders in comment, middle"></Keywords>
                    <Keywords name="Folders in comment, close"></Keywords>
                    <Keywords name="Keywords1">../ (../ http:// (http:// https:// (https:// mailto: (mailto: ftp:// (ftp:// ftps:// (ftps:// (/ /</Keywords>
                    <Keywords name="Keywords2">==== ----</Keywords>
                    <Keywords name="Keywords3">*** ___</Keywords>
                    <Keywords name="Keywords4">** __</Keywords>
                    <Keywords name="Keywords5">* _</Keywords>
                    <Keywords name="Keywords6">** __</Keywords>
                    <Keywords name="Keywords7">==</Keywords>
                    <Keywords name="Keywords8">~~</Keywords>
                    <Keywords name="Delimiters">00![ 00[ 01\ 02] 02] 03``` 03` 03~~~ 04\ 05``` 05((EOL `)) 05~~~ 06*** 07\ 08((EOL ***)) 09** 10\ 11((EOL **)) 12* 13\ 14((EOL *)) 15** 16\ 17((EOL **)) 18* 19\ 20((EOL *)) 21== 22\ 23((EOL ==))</Keywords>
                </KeywordLists>
                <Styles>
                    <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" colorStyle="0" fontStyle="0" nesting="0" />
                    <WordsStyle name="COMMENTS" fgColor="0080C0" bgColor="D5F1FF" fontStyle="0" nesting="0" />
                    <WordsStyle name="LINE COMMENTS" fgColor="FF8000" bgColor="FFFFFF" fontStyle="1" nesting="0" />
                    <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" colorStyle="0" fontStyle="0" nesting="0" />
                    <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="KEYWORDS2" fgColor="FF8000" bgColor="FFFFFF" fontStyle="1" nesting="0" />
                    <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontStyle="3" nesting="0" />
                    <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="1" nesting="0" />
                    <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="2" nesting="0" />
                    <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="3" nesting="0" />
                    <WordsStyle name="KEYWORDS7" fgColor="0080C0" bgColor="DBF3FF" fontStyle="0" nesting="0" />
                    <WordsStyle name="KEYWORDS8" fgColor="FF0000" bgColor="FFD7D7" fontStyle="4" nesting="0" />
                    <WordsStyle name="OPERATORS" fgColor="8080FF" bgColor="FFFFFF" fontStyle="1" nesting="0" />
                    <WordsStyle name="FOLDER IN CODE1" fgColor="333333" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="FOLDER IN CODE2" fgColor="333333" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="FOLDER IN COMMENT" fgColor="333333" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="DELIMITERS1" fgColor="8000FF" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="DELIMITERS2" fgColor="FF0080" bgColor="FFFFFF" fontStyle="0" nesting="0" />
                    <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" colorStyle="0" fontStyle="3" nesting="0" />
                    <WordsStyle name="DELIMITERS4" fgColor="000080" bgColor="FFFFFF" colorStyle="0" fontStyle="1" nesting="65600" />
                    <WordsStyle name="DELIMITERS5" fgColor="000080" bgColor="FFFFFF" colorStyle="0" fontStyle="2" nesting="32800" />
                    <WordsStyle name="DELIMITERS6" fgColor="000080" bgColor="FFFFFF" colorStyle="0" fontStyle="3" nesting="0" />
                    <WordsStyle name="DELIMITERS7" fgColor="000080" bgColor="FFFFFF" colorStyle="0" fontStyle="3" nesting="0" />
                    <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFF80" fontStyle="0" nesting="0" />
                </Styles>
            </UserLang>
        </NotepadPlus>
        
        
        1 Reply Last reply Reply Quote 0
        • D
          dcog989 @dcog989
          last edited by PeterJones

          Markdown test file:

          # H1 - Markdown Quick Ref
          
          ## H2 - headings should have blank lines before and after
          
          ### H3
          
          *Italics*, **bold**, and ***super important***! _Or_ __use__ ___underscores___. *Mixed for __emphasis__*. Be consistent - first use defines.
          
          You can ==highlight words==, ~~strikethrough~~, and line break with 2 spaces at end.  
          Use emoji :joy:? Or subscript H~2~O and superscript X^2^?
          
          A sentence with a footnote.[^1]
          [^1]: This is the footnote - but it can be placed anywhere.
          
          ----
          
          > blockquote
          
          ## Lists and Code {#lists}
          
          1. Ordered list
          2. Second item
          3. Third item
          
          - Unordered list
          - Second item
          - Third item
          
          * Unordered list
          
          + Unordered list
          
          `print('Code goes here!')`
          
          ```python
          {
          num1 = 1.234
          num2 = 3.142
          }
          ```
          
          ## Links
          
          An image - ![alt text](image.jpg).
          
          
          1 Reply Last reply Reply Quote 0
          • Mark OlsonM
            Mark Olson
            last edited by

            I think the core problem is that the UDL system is inherently buggy. When I make a UDL, I assume there will be bugs and figure that if I want something better, I will have to either write my own Lexilla lexer or use the EnhanceAnyLexer plugin.

            That’s not to say that what you’re looking for is impossible. It may be possible, but I’m just giving my hot take.

            D 1 Reply Last reply Reply Quote 0
            • rdipardoR
              rdipardo @dcog989
              last edited by rdipardo

              @dcog989 said in Markdown UDL Help:

              1. using ‘*’ to start an unordered list is incorrectly picking up italic from the content formatting of ‘*’

              Have a look at Underscore don’t work as it should in Markdown (sic); as in that case, the UDL looks for delimiters before it looks for keywords, and the first match prevails, so a * will always be taken for the opening * of a *...* span, matching the pattern 12* 13\ 14((EOL *)). You could remove the delimiter pattern to apply the keyword style instead, but you can’t have both.

              1. the formatting for blockquote ‘>’ is being applied when ‘>’ is used in content - i.e. it should only apply when used at beginning of line

              The blockquote marker (encoded as &gt;) appears to be grouped with “Operators1” keywords; that means it matches at any position, i.e. all surrounding whitespace is ignored . At most, you can suppress the blockquote style when > is touching other text by placing &gt; with “Operators2” instead, e.g.

              mrkdn-custom-udl.png

              There is currently no UDL specification that can match the start of a line. despite being a requested feature (see below).


              • ((BOL)) needed… UDL counterpart to ((EOL))

              • New feature’s request: ((BOL)) delimiter for UDL (or something like that)

              D 1 Reply Last reply Reply Quote 1
              • D
                dcog989 @Mark Olson
                last edited by

                @Mark-Olson

                It’s my first time playing with UDL and I did feel a bit like I was reinventing the wheel with just a rock and a stick to work with. Thanks for suggesting the additional lexer route but I’m not inclined to go down that rabbit hole - mainly due to lack of time and talent.

                1 Reply Last reply Reply Quote 0
                • D
                  dcog989 @rdipardo
                  last edited by

                  @rdipardo said in Markdown UDL Help:

                  but you can’t have both.

                  I guessed as much but thanks for ticket and confirmation.

                  placing > with “Operators2” instead

                  I tried that suggestion but no change in behavior. It’s a small edge case in an imperfect solution so I’m going to leave it as is.

                  Thanks for further info on where UDL is lacking - on the upside it justifies me spending more time in VS Code which is really growing on me.

                  1 Reply Last reply Reply Quote 1
                  • D
                    dcog989 @dcog989
                    last edited by

                    I can now post links - here is the UDL and test MD - https://drive.google.com/file/d/193FHJrGEL7MUIuy86khVorLLNW_HTg6P/view?usp=sharing

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