Community
    • Login

    [markdown] syntax color support for code blocks

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    2 Posts 2 Posters 2.3k Views 2 Watching
    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.
    • Emanuel OliveiraE Offline
      Emanuel Oliveira
      last edited by

      Hi all,

      I was able to add several custom markdown styles via Language > User Defined Language:
      1 markdown color styles.png

      But all user defined languages I downloaded () don’t have support to the markdown 4 backticks <language>

      ```sql
      select 'hello world
      .```
      

      or python like following:
      2 code blocks all same color.png

      All code block have same color.

      I understand basics of how markdown as USer Defined Language done, but Ii don’t see easy way for me to add BNF syntax just inside code blocks ?

      Is this even possible to do ?

      Thanks so much, I been using Notepad++ for many years, and recently started creating markdown files, but I’m missing this color support inside code blocks.

      Thanks for suggesting if this possible (via User Defined Language) or via some plugin ?

      Cheers ~

      1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones
        last edited by

        The UDL can handle doing different colors for `single backticks` vs triple

        ```
        long code
        ```
        

        For example, here is a screenshot using the “markdown (preinstalled)” UDL that comes with Notepad++:
        5bee2f23-5331-485e-a948-783587fdf052-image.png

        Then, if I remove the single ticks from Delimiter 2 and move it to Delimiter 8 (which was empty before) and give 8 a different color, it works just fine:

        8df18d51-af9a-4f45-986a-aca6e6284a4d-image.png

        The one thing to keep in mind with making Delimiters for “triple” vs “single”: you have to put the triple before the single, otherwise when it’s doing it’s parsing, it will match on the single rule first. (It searches through the delimiters in the 1-8 order)

        And if you wanted to allow specific keywords (say keyword8) inside the triple quotes (delimiter 2), then you can go into the styler for delimiter2 and allow keyword8 inside:
        49f17867-6e52-4cdd-8d39-75f0f46c731b-image.png
        fc5ebe90-be88-4a3b-a81b-53b5a5ee8432-image.png

        I am not sure what you were trying to indicate with the “BNF” in your question: if you just meant keywords, then I’ve shown it works. But something like the @udtf(...) would be more difficult – at least with the way “markdown (preinstalled)” is defined. And getting full python highlighting inside of the code-block markdown is not possible, the way that UDL and N++ is implemented.

        But, at some point, based on the complexity you are describing, it might go beyond what UDL is capable of: UDL was meant for “simple” syntaxes, and if you wanted something more complicated, then the idea was that a lexer plugin could be the next step to bridge the gap between UDL and what N++ provides natively.

        1 Reply Last reply Reply Quote 2

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors