[markdown] syntax color support for code blocks
-
Hi all,
I was able to add several custom markdown styles via Language > User Defined Language:
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:
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 ~
-
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++:
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:
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:
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.