Skip to content

Commit de372c9

Browse files
authored
Merge pull request #49 from scripthunter7/master
Adblock agent support, modifier separator fix
2 parents 6e56ca1 + 1c8db08 commit de372c9

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 0.0.27
4+
5+
- Added support for adblock agents
6+
- Fix redundant modifier detection: #25
7+
38
## 0.0.26
49

510
- Added support for cosmetic rules modifiers: #47

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "adblock",
33
"displayName": "Adblock/AdGuard/uBlock filters grammar",
44
"description": "VS code extension that adds support for ad blocking rules syntax.",
5-
"version": "0.0.26",
5+
"version": "0.0.27",
66
"publisher": "adguard",
77
"icon": "images/icon.png",
88
"engines": {

syntaxes/adblock.tmLanguage.json

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
33
"name": "Adblock",
44
"patterns": [
5+
{
6+
"include": "#adblockAgent"
7+
},
58
{
69
"include": "#preprocessor"
710
},
@@ -37,6 +40,51 @@
3740
}
3841
],
3942
"repository": {
43+
"adblockAgent": {
44+
"patterns": [
45+
{
46+
"match": "^(\\[)([^\\]]+)(\\])\\s*$",
47+
"captures": {
48+
"1": {
49+
"name": "punctuation.definition.array.start.ablock.agent"
50+
},
51+
"2": {
52+
"patterns": [
53+
{
54+
"include": "#adblockData"
55+
},
56+
{
57+
"match": ";",
58+
"name": "punctuation.separator"
59+
},
60+
{
61+
"name": "invalid.illegal",
62+
"match": ".*"
63+
}
64+
]
65+
},
66+
"3": {
67+
"name": "punctuation.definition.array.end.ablock.agent"
68+
}
69+
}
70+
}
71+
]
72+
},
73+
"adblockData": {
74+
"patterns": [
75+
{
76+
"match": "(?:\\s*)([Aa]d[Bb]lock(?:\\s[Pp]lus)?|u[Bb]lock(?:\\s[Oo]rigin)?|[Aa]d[Gg]uard)(?:\\s+(\\d+(?:\\.\\d+)*+\\+?))?(?:\\s*)",
77+
"captures": {
78+
"1": {
79+
"name": "constant.language.agent.adblocker.name"
80+
},
81+
"2": {
82+
"name": "constant.numeric.decimal"
83+
}
84+
}
85+
}
86+
]
87+
},
4088
"preprocessor": {
4189
"patterns": [
4290
{
@@ -142,10 +190,6 @@
142190
"name": "comment.line",
143191
"match": "^!.*"
144192
},
145-
{
146-
"name": "comment.line.header",
147-
"match": "^\\[Adblock.*"
148-
},
149193
{
150194
"name": "comment.line.batch-style",
151195
"match": "^# .*"
@@ -405,7 +449,7 @@
405449
"basicRules": {
406450
"patterns": [
407451
{
408-
"match": "^(.+?)((\\$)(.*))?$",
452+
"match": "^(.+?)((\\$(?!\\/))(.*))?$",
409453
"captures": {
410454
"1": {
411455
"patterns": [
@@ -658,6 +702,10 @@
658702
{
659703
"match": ",",
660704
"name": "punctuation.definition.adblock"
705+
},
706+
{
707+
"match": "\\$",
708+
"name": "invalid.illegal.redundant.modifier.separator"
661709
}
662710
]
663711
},

test_rules.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[Adblock Plus 3.1; AdGuard]
2+
[AdGuard; Invalid Name 2.0]
13
!
24
! Test rules for the syntax highlighter
35
!
@@ -308,4 +310,10 @@ $removeheader=location,domain=zannn.top|innal.top
308310
!
309311
! Cosmetic rules modifiers, invalid modifiers
310312
!
311-
[$randommodifier=test]##banner
313+
[$randommodifier=test]##banner
314+
315+
! https://github.com/ameshkov/VscodeAdblockSyntax/issues/25
316+
/^https:\/\/.*?\/v2\/0\/[a-zA-Z0-9_-]{30,}$/$third-party,script,$domain=~example.org
317+
||example.com/example.js^$script,$third-party,$domain=example.org
318+
||example.com/example.js^$script,$~third-party,$domain=example.org
319+
||example.com/example.js^$script,third-party,$domain=example.org|example.net

0 commit comments

Comments
 (0)