Skip to content

Commit 0390e64

Browse files
Pug: Improved filter tokenization (#3258)
Co-authored-by: Jason Kurian <JaKXz@users.noreply.github.com>
1 parent 2334b4b commit 0390e64

File tree

12 files changed

+89
-69
lines changed

12 files changed

+89
-69
lines changed

components/prism-pug.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
'filter-name': {
3434
pattern: /^:[\w-]+/,
3535
alias: 'variable'
36-
}
36+
},
37+
'text': /\S[\s\S]*/,
3738
}
3839
},
3940

@@ -172,7 +173,11 @@
172173
pattern: /^:[\w-]+/,
173174
alias: 'variable'
174175
},
175-
rest: Prism.languages[filter.language]
176+
'text': {
177+
pattern: /\S[\s\S]*/,
178+
alias: [filter.language, 'language-' + filter.language],
179+
inside: Prism.languages[filter.language]
180+
}
176181
}
177182
};
178183
}

components/prism-pug.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/coffeescript+pug/coffeescript_inclusion.test

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
[
77
["filter-coffee", [
88
["filter-name", ":coffee"],
9-
["string", [
10-
"\"",
11-
["interpolation", "#{foo}"],
12-
"\""
9+
["text", [
10+
["string", [
11+
"\"",
12+
["interpolation", "#{foo}"],
13+
"\""
14+
]]
1315
]]
1416
]]
1517
]
1618

1719
----------------------------------------------------
1820

19-
Checks for coffee filter (CoffeeScript) in Jade.
21+
Checks for coffee filter (CoffeeScript) in pug.

tests/languages/ejs+pug/ejs_inclusion.test

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
[
77
["filter-ejs", [
88
["filter-name", ":ejs"],
9-
["language-javascript", [
10-
["operator", "<"],
11-
["operator", "%"],
12-
["keyword", "var"],
13-
" foo ",
14-
["operator", "="],
15-
["string", "''"],
16-
["punctuation", ","],
17-
" bar ",
18-
["operator", "="],
19-
["boolean", "false"],
20-
["punctuation", ";"]
21-
]],
22-
["delimiter", "%>"]
9+
["text", [
10+
["delimiter", "<%"],
11+
["language-javascript", [
12+
["keyword", "var"],
13+
" foo ",
14+
["operator", "="],
15+
["string", "''"],
16+
["punctuation", ","],
17+
" bar ",
18+
["operator", "="],
19+
["boolean", "false"],
20+
["punctuation", ";"]
21+
]],
22+
["delimiter", "%>"]
23+
]]
2324
]]
2425
]

tests/languages/handlebars+pug/handlebars_inclusion.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
[
77
["filter-handlebars", [
88
["filter-name", ":handlebars"],
9-
["comment", "{{!comment}}"]
9+
["text", [
10+
["comment", "{{!comment}}"]
11+
]]
1012
]]
1113
]
1214

1315
----------------------------------------------------
1416

15-
Checks for handlebars filter in Jade.
17+
Checks for handlebars filter in pug.

tests/languages/less+pug/less_inclusion.test

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
[
77
["filter-less", [
88
["filter-name", ":less"],
9-
["variable", [
10-
"@foo",
11-
["punctuation", ":"]
12-
]],
13-
" #123",
14-
["punctuation", ";"]
9+
["text", [
10+
["variable", [
11+
"@foo",
12+
["punctuation", ":"]
13+
]],
14+
" #123",
15+
["punctuation", ";"]
16+
]]
1517
]]
1618
]
1719

1820
----------------------------------------------------
1921

20-
Checks for less filter in Jade.
22+
Checks for less filter in pug.

tests/languages/livescript+pug/livescript_inclusion.test

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@
66
[
77
["filter-livescript", [
88
["filter-name", ":livescript"],
9-
["interpolated-string", [
10-
["string", "\""],
11-
["variable", "#foo"],
12-
["string", " "],
13-
["interpolation", [
14-
["interpolation-punctuation", "#{"],
15-
["keyword", "if"],
16-
["regex", "/test/"],
17-
["operator", "=="],
18-
["string", "'test'"],
19-
["keyword", "then"],
20-
["number", "3"],
21-
["keyword", "else"],
22-
["number", "4"],
23-
["interpolation-punctuation", "}"]
24-
]],
25-
["string", "\""]
9+
["text", [
10+
["interpolated-string", [
11+
["string", "\""],
12+
["variable", "#foo"],
13+
["string", " "],
14+
["interpolation", [
15+
["interpolation-punctuation", "#{"],
16+
["keyword", "if"],
17+
["regex", "/test/"],
18+
["operator", "=="],
19+
["string", "'test'"],
20+
["keyword", "then"],
21+
["number", "3"],
22+
["keyword", "else"],
23+
["number", "4"],
24+
["interpolation-punctuation", "}"]
25+
]],
26+
["string", "\""]
27+
]]
2628
]]
2729
]]
2830
]

tests/languages/markdown+pug/markdown_inclusion.test

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
[
77
["filter-markdown", [
88
["filter-name", ":markdown"],
9-
["title", [
10-
["punctuation", "#"],
11-
" title"
9+
["text", [
10+
["title", [
11+
["punctuation", "#"],
12+
" title"
13+
]]
1214
]]
1315
]]
1416
]
1517

1618
----------------------------------------------------
1719

18-
Checks for markdown filter in Jade.
20+
Checks for markdown filter in pug.

tests/languages/pug/filter_feature.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
[
77
["filter", [
88
["filter-name", ":language"],
9-
"\r\n\tcode"
9+
["text", "code"]
1010
]]
1111
]

tests/languages/scss+pug/scss_inclusion.test

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
[
77
["filter-sass", [
88
["filter-name", ":sass"],
9-
["keyword", "@extend"],
10-
" .foo",
11-
["punctuation", ";"]
9+
["text", [
10+
["keyword", "@extend"],
11+
" .foo",
12+
["punctuation", ";"]
13+
]]
1214
]]
1315
]
1416

1517
----------------------------------------------------
1618

17-
Checks for sass filter (Scss) in Jade.
19+
Checks for sass filter (Scss) in pug.

0 commit comments

Comments
 (0)