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 class and id in tag detection #2358

Merged
merged 2 commits into from May 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions components/prism-pug.js
Expand Up @@ -112,6 +112,14 @@
pattern: /(^[\t ]*)(?!-)[\w\-#.]*[\w\-](?:(?:&[^(]+)?\([^)]+\))*\/?:?/m,
lookbehind: true,
inside: {
'attr-id': {
pattern: /(^[\t ]*(?!-)[\w\-.]*)#[\w\-]+/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true
},
'attr-class': {
pattern: /(^[\t ]*(?!-)[\w\-#]*)\.[\w\-]+/,
lookbehind: true
},
'attributes': [
{
pattern: /&[^(]+\([^)]+\)/,
Expand Down
24 changes: 20 additions & 4 deletions tests/languages/pug/tag_feature.test
Expand Up @@ -13,6 +13,9 @@ a.button
a#main-link
#content

div#test-id.test-class1.test-class2
.test-class1#test-id.test-class2

a: span

----------------------------------------------------
Expand Down Expand Up @@ -83,10 +86,23 @@ a: span
]]
]],

["tag", ["a.button"]],
["tag", [".content"]],
["tag", ["a#main-link"]],
["tag", ["#content"]],
["tag", [
"a",
["attr-class", ".button"]]],
["tag", [["attr-class", ".content"]]],
["tag", [
"a",
["attr-id", "#main-link"]]],
["tag", [["attr-id", "#content"]]],
["tag", [
"div",
["attr-id", "#test-id"],
["attr-class", ".test-class1"],
["attr-class", ".test-class2"]]],
["tag", [
["attr-class", ".test-class1"],
["attr-id", "#test-id"],
["attr-class", ".test-class2"]]],

["tag", ["a", ["punctuation", ":"]]],
["tag", ["span"]]
Expand Down