Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pug: Improved filter tokenization #3258

Merged
merged 4 commits into from Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/prism-pug.js
Expand Up @@ -33,7 +33,8 @@
'filter-name': {
pattern: /^:[\w-]+/,
alias: 'variable'
}
},
'text': /\S[\s\S]*/,
}
},

Expand Down Expand Up @@ -172,7 +173,11 @@
pattern: /^:[\w-]+/,
alias: 'variable'
},
rest: Prism.languages[filter.language]
'text': {
pattern: /\S[\s\S]*/,
alias: [filter.language, 'language-' + filter.language],
inside: Prism.languages[filter.language]
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion components/prism-pug.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions tests/languages/coffeescript+pug/coffeescript_inclusion.test
Expand Up @@ -6,14 +6,16 @@
[
["filter-coffee", [
["filter-name", ":coffee"],
["string", [
"\"",
["interpolation", "#{foo}"],
"\""
["text", [
["string", [
"\"",
["interpolation", "#{foo}"],
"\""
]]
]]
]]
]

----------------------------------------------------

Checks for coffee filter (CoffeeScript) in Jade.
Checks for coffee filter (CoffeeScript) in pug.
29 changes: 15 additions & 14 deletions tests/languages/ejs+pug/ejs_inclusion.test
Expand Up @@ -6,19 +6,20 @@
[
["filter-ejs", [
["filter-name", ":ejs"],
["language-javascript", [
["operator", "<"],
["operator", "%"],
["keyword", "var"],
" foo ",
["operator", "="],
["string", "''"],
["punctuation", ","],
" bar ",
["operator", "="],
["boolean", "false"],
["punctuation", ";"]
]],
["delimiter", "%>"]
["text", [
["delimiter", "<%"],
["language-javascript", [
["keyword", "var"],
" foo ",
["operator", "="],
["string", "''"],
["punctuation", ","],
" bar ",
["operator", "="],
["boolean", "false"],
["punctuation", ";"]
]],
["delimiter", "%>"]
]]
]]
]
6 changes: 4 additions & 2 deletions tests/languages/handlebars+pug/handlebars_inclusion.test
Expand Up @@ -6,10 +6,12 @@
[
["filter-handlebars", [
["filter-name", ":handlebars"],
["comment", "{{!comment}}"]
["text", [
["comment", "{{!comment}}"]
]]
]]
]

----------------------------------------------------

Checks for handlebars filter in Jade.
Checks for handlebars filter in pug.
16 changes: 9 additions & 7 deletions tests/languages/less+pug/less_inclusion.test
Expand Up @@ -6,15 +6,17 @@
[
["filter-less", [
["filter-name", ":less"],
["variable", [
"@foo",
["punctuation", ":"]
]],
" #123",
["punctuation", ";"]
["text", [
["variable", [
"@foo",
["punctuation", ":"]
]],
" #123",
["punctuation", ";"]
]]
]]
]

----------------------------------------------------

Checks for less filter in Jade.
Checks for less filter in pug.
36 changes: 19 additions & 17 deletions tests/languages/livescript+pug/livescript_inclusion.test
Expand Up @@ -6,23 +6,25 @@
[
["filter-livescript", [
["filter-name", ":livescript"],
["interpolated-string", [
["string", "\""],
["variable", "#foo"],
["string", " "],
["interpolation", [
["interpolation-punctuation", "#{"],
["keyword", "if"],
["regex", "/test/"],
["operator", "=="],
["string", "'test'"],
["keyword", "then"],
["number", "3"],
["keyword", "else"],
["number", "4"],
["interpolation-punctuation", "}"]
]],
["string", "\""]
["text", [
["interpolated-string", [
["string", "\""],
["variable", "#foo"],
["string", " "],
["interpolation", [
["interpolation-punctuation", "#{"],
["keyword", "if"],
["regex", "/test/"],
["operator", "=="],
["string", "'test'"],
["keyword", "then"],
["number", "3"],
["keyword", "else"],
["number", "4"],
["interpolation-punctuation", "}"]
]],
["string", "\""]
]]
]]
]]
]
10 changes: 6 additions & 4 deletions tests/languages/markdown+pug/markdown_inclusion.test
Expand Up @@ -6,13 +6,15 @@
[
["filter-markdown", [
["filter-name", ":markdown"],
["title", [
["punctuation", "#"],
" title"
["text", [
["title", [
["punctuation", "#"],
" title"
]]
]]
]]
]

----------------------------------------------------

Checks for markdown filter in Jade.
Checks for markdown filter in pug.
2 changes: 1 addition & 1 deletion tests/languages/pug/filter_feature.test
Expand Up @@ -6,6 +6,6 @@
[
["filter", [
["filter-name", ":language"],
"\r\n\tcode"
["text", "code"]
]]
]
10 changes: 6 additions & 4 deletions tests/languages/scss+pug/scss_inclusion.test
Expand Up @@ -6,12 +6,14 @@
[
["filter-sass", [
["filter-name", ":sass"],
["keyword", "@extend"],
" .foo",
["punctuation", ";"]
["text", [
["keyword", "@extend"],
" .foo",
["punctuation", ";"]
]]
]]
]

----------------------------------------------------

Checks for sass filter (Scss) in Jade.
Checks for sass filter (Scss) in pug.
14 changes: 8 additions & 6 deletions tests/languages/stylus+pug/stylus_inclusion.test
Expand Up @@ -6,15 +6,17 @@
[
["filter-stylus", [
["filter-name", ":stylus"],
["variable-declaration", [
["variable", "font-size"],
["operator", "="],
["number", "14"],
["unit", "px"]
["text", [
["variable-declaration", [
["variable", "font-size"],
["operator", "="],
["number", "14"],
["unit", "px"]
]]
]]
]]
]

----------------------------------------------------

Checks for stylus filter in Jade.
Checks for stylus filter in pug.
12 changes: 6 additions & 6 deletions tests/languages/twig+pug/twig_inclusion.test
Expand Up @@ -6,14 +6,14 @@
[
["filter-atpl", [
["filter-name", ":atpl"],

["punctuation", "{"],
["punctuation", "{"],
["number", "42"],
["delimiter", "}}"]
["text", [
["delimiter", "{{"],
["number", "42"],
["delimiter", "}}"]
]]
]]
]

----------------------------------------------------

Checks for atpl filter (Twig) in Jade.
Checks for atpl filter (Twig) in pug.