# Web Sources Framework: Syntax Highlighting for Notepad++

**URL:** https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863
**Category:** Web Sources Discussion
**Created:** [January 12, 2022, 8:56am UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863 "2022-01-12T08:56:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 12, 2022, 8:56am UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/1 "2022-01-12T08:56:37Z")

</div>

## Mp3tag Web Sources syntax highlighting for Notepad++

If you develop a Web Sources Script for Mp3tag you may find it useful to highlight your commands and syntax in specific colours. In addition Notepad++ allows code folding. For example, with `if` , `else` , and `endif` , it will define fold regions so that you can fold from `if` to `else` , from `else` to `endif` , and (assuming there is no `else` clause) from `if` to `endif`.

Notepad++ provides a so called **U** ser **D** efined **L** anguage system. The UDL interface allows the user to define rules for formatting normal text, keywords, comments, numbers, folding...

## Requirements

[Notepad++](https://notepad-plus-plus.org/downloads/)  
`Mp3tag Language Definition Export.xml` v1.30  
_compressed in this downloadable file from May 2024:_  
[Mp3tag Language Definition Export v1.3.zip](https://community.mp3tag.de/uploads/short-url/81t0zE4d0CnNpBhMmsITNw4Y62V.zip) (1,3 KB)

Previous version from January 2022:  
[Mp3tag Language Definition Export v1.2.zip](https://community.mp3tag.de/uploads/short-url/uxdBVc7atmNL7YbeOS8zxLz80d3.zip) (1,2 KB)

This UDL defintion file contains all the known commands from the [Mp3tag Web Sources Framework](https://docs.mp3tag.de/tag-sources) as of 30.05.2024.

## Instructions

1. Extract the XML from the above ZIP file.
2. [Import](https://npp-user-manual.org/docs/user-defined-language-system/#import-a-udl) the `Mp3tag Language Definition Export.xml`

I suggest to use the Notepad++ menu **Language** -\> **User Defined Language** -\> **Define Your Language** and there the **Import…** button. Navigate to the source XML file `Mp3tag Language Definition Export.xml`, click Open and this UDL for Mp3tag will be available after a Notepad++ restart and reload of already opened content.

If you load a \*.src or \*.inc text file, the colours and folding will be applied automatically. You can change the UDL Language at any time using the Notepad++ **Language** menu.

## How does it look?

 ![NP++ Mp3tag Language Definition Export](https://community.mp3tag.de/uploads/default/original/2X/0/00d076bc91454aa23d54433ef0616788db39f34f.png)

## Can I adjust the colours?

Sure. Use the Notepad++ menu **Language** -\> **User Defined Language** -\> **Define Your Language** and there choose the User language: **Mp3tag src inc** from the drop down box.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/7/73e26fe645f369008b8c346ab053838df6c63d91.png)

Click on the Tab where you want to change the colour for your commands  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/f/f917f3129d078bc3a4434c1431b2ac834b99e435.png)

and then on the **Styler** button

 ![image](https://community.mp3tag.de/uploads/default/original/2X/1/11a2d43310814829ed81b3549975f6c87a6a023c.png)

You can choose whatever colour you like.

## Version History

2024-05-30: v1.3 - Added the new WSS Parser Commands, details see [here](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/9)  
2022-02-22: v1.2 - One change, details see [here](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/2)  
2022-02-07: v1.1 - Internal changes only  
2022-01-12: v1.0 - First Public Release

## Feedback

Please let me know if you find any error or inconsistency with this UDL definition.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 22, 2022, 3:20pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/2 "2022-02-22T15:20:19Z")

</div>

2022-02-22 - Update v1.2

- CHG: Position of "IfNot" in "Folders in code1, open" changed, to better detect the longer word "IfNotOutput" first (and completely).

---

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [February 24, 2022, 4:59pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/3 "2022-02-24T16:59:33Z")

</div>

Thanks for this great idea. I have been working with this UDL definition for some time and have found a small inconsistency. Under Operators & Delimiter the Delimiter 1, that has Open: " and Close: " also needs under Escape: \ to be defined, because without that the syntax highlighting will stop at \" that is often used in regular expressions, e.g. in the WS script MusicBrainz.src.

Also a second delimiter with Open: [and Close:] could be defined and seems to me to be a replacement for the keywords in square brackets in the 2nd group of the keywors list. This list is not complete, it misses the (undocumented) [PreviewUrl] .

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 24, 2022, 5:06pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/4 "2022-02-24T17:06:20Z")

</div>

Thank you for your feedback @yorickausyps

`[PreviewUrl]` will be added to the second keyword list.

Then do you ask for changes like this?  
(I'm not sure if I fully understand your request)

 ![image](https://community.mp3tag.de/uploads/default/original/2X/1/1bc8799c6c8f92a18672033e33fb6ea286736b61.png)

Could you please provide some test strings to see the difference?

For the first change I see the result:  
 ![BackSlash](https://community.mp3tag.de/uploads/default/original/2X/6/6f1e27a9a8435dec07e63a1e80242ef65c9ef0d1.gif)

But for the second one with the `[]` ?

---

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [February 24, 2022, 5:33pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/5 "2022-02-24T17:33:14Z")

</div>

please use the following excerpt from Discogs Release ID.src to try the second change with [...]

[Name]=[Discogs.com](http://Discogs.com)  
[BasedOn]=[www.discogs.com](http://www.discogs.com)  
[PreviewUrl]=http://www.discogs.com/release/%s  
[AlbumUrl]=https://api.discogs.com/releases/%s  
[WordSeparator]=%20  
[SearchBy]=Discogs ID||$if2(%DISCOGS\_RELEASE\_ID%,$if2(%DISCOGS\_RELEASE\_ID%,$if2(%DISCOGSID%,%DISCOGS-ID%)))||%s  
[UserAgent]=1  
[Encoding]=url-utf-8

[ParserScriptIndex]=...

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 24, 2022, 5:41pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/6 "2022-02-24T17:41:46Z")

</div>

Thank you very much for you quick reply!

Do you prefer to see all the defined keywords (and following text) from the "keywords group #2" in black color like this?  
 ![EckigeKlammern](https://community.mp3tag.de/uploads/default/original/2X/3/327a2f418b9dfd4dff84b432ccb3df7742aba60c.gif)

You say that this does not affect other occurrences of `[]` as in regular expressions?

@yorickausyps  
Could you please have a look at this side effect for values in apostrophes `'[` and `]'`  
(it is only really visible if you set the foreground color of the "Delimiter 2 style" to Bold:)  
 ![Apostrophe](https://community.mp3tag.de/uploads/default/original/2X/3/3c13d55f86e15253a1b37fb9db7696856fadb941.gif)

What do you think?

---

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [February 24, 2022, 9:32pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/7 "2022-02-24T21:32:04Z")

</div>

As I prefer to use the dark mode I had to set all background colors to black (or a dark color) and most foregrounds to a bright color.

The code example from MusicBrainz shows, that if the square brackets are used as delimiters in the UDL the Escape: \ must also be set, to find the corresponding brackets in the Searchby expression.  
So far I did not find another example where the [] affect highlighting, because most regular expressions are surrounded by quotes:

`sayregexp "(?<= id=\")[-0-9a-y]{34,40}(?=\")" ", " "<title>"`

It seems to me that the outer quotes have precedence over the inner brackets and therefore the quotes define the highlighting. I think I should read the manual.

---

<div class="post-metadata">

### Author: ![Romano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/romano/32/7465_2.png) [@Romano](https://community.mp3tag.de/u/Romano)
#### Post date: [July 2, 2023, 7:49am UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/8 "2023-07-02T07:49:35Z")

</div>

Thank you for this @LyricsLover

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [May 30, 2024, 1:08pm UTC](https://community.mp3tag.de/t/web-sources-framework-syntax-highlighting-for-notepad/55863/9 "2024-05-30T13:08:32Z")

</div>

2024-05-30 - Update v1.3

- ADD: Added the new WSS Parser Commands like` IfVar, IfNotVar, json_foreach_reverse, json_foreach_counter, json_select_many_count, SayDate, SayDuration, [MinAppVersionWin], [MinAppVersionMac], [Settings]`

From the [complete overview](https://docs.mp3tag.de/tag-sources/development/) with Parameters and Description.
