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

CSS Extra: (1) rename attr-name, attr-value (2) change pseudo-class token pattern (3) add tag, selector-list, combinator token #2373

Merged
merged 16 commits into from May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ac26293
pug: Improved class(named "attr-class") and id(named "attr-id") in ta…
dev-itsheng May 3, 2020
c48d654
pug: rewrite the better code, run "npx gulp" and commit ".min.js"
dev-itsheng May 3, 2020
0d7da48
Merge remote-tracking branch 'upstream/master'
dev-itsheng May 4, 2020
a882579
Stylus: Fix comment-like grammar(/**/ or //) in property url() and st…
dev-itsheng May 4, 2020
c3da26f
Stylus: replace the `comment` in the `inside` object
dev-itsheng May 4, 2020
eb73dbb
Merge remote-tracking branch 'upstream/master'
dev-itsheng May 6, 2020
2cb260f
Stylus: Add `color`, `entity`, `unit`, change `number` and `operator`…
dev-itsheng May 6, 2020
2d162ff
Stylus: remove extra `|` in `number` property and add relative tests.
dev-itsheng May 7, 2020
eee68e7
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng May 7, 2020
a37cd5e
Stylus: Put the `comment` token behind the `string` token and set the…
dev-itsheng May 7, 2020
ea3f3ff
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng May 8, 2020
49a6eda
CSS Extra: (1) rename `attr-name`, `attr-value` (2) change `pseudo-cl…
dev-itsheng May 8, 2020
fb011be
CSS Extra: add `?:` in regex to pass the test.
dev-itsheng May 8, 2020
4848fda
CSS Extra: restore `pseudo-class` tokenize, put the `combinator` and …
dev-itsheng May 8, 2020
c500ca3
CSS Extra: rewrite the `combinator` regex and add relative tests to t…
dev-itsheng May 8, 2020
61920bc
CSS Extra: remove `tag` token but left comment describing this history
dev-itsheng May 8, 2020
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
12 changes: 9 additions & 3 deletions components/prism-css-extras.js
Expand Up @@ -27,11 +27,11 @@
'punctuation': /\|$/
}
},
'attribute': {
'attr-name': {
pattern: /^(\s*)[-\w\xA0-\uFFFF]+/,
lookbehind: true
},
'value': [
'attr-value': [
string,
{
pattern: /(=\s*)[-\w\xA0-\uFFFF]+(?=\s*$)/,
Expand All @@ -55,7 +55,13 @@
lookbehind: true
}
],
'punctuation': /[()]/
'combinator': />|\+|~|\|\|/,

// the `tag` token has been existed and removed.
// because we can't find a perfect tokenize to match it.
// if you want to add it, please read https://github.com/PrismJS/prism/pull/2373 first.

'punctuation': /[(),]/,
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/prism-css-extras.min.js

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

70 changes: 35 additions & 35 deletions tests/languages/css!+css-extras/selector_attribute_feature.test
Expand Up @@ -28,7 +28,7 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["punctuation", "]"]
]]
]],
Expand All @@ -38,9 +38,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -50,9 +50,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "\"val\""],
["attr-value", "\"val\""],
["punctuation", "]"]
]]
]],
Expand All @@ -62,9 +62,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "'val'"],
["attr-value", "'val'"],
["punctuation", "]"]
]]
]],
Expand All @@ -74,9 +74,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "|="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -86,9 +86,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "~="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -98,9 +98,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "|="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -110,9 +110,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "^="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -122,9 +122,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "$="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -134,9 +134,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "*="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -150,7 +150,7 @@
"foo",
["punctuation", "|"]
]],
["attribute", "attr"],
["attr-name", "attr"],
["punctuation", "]"]
]],
["attribute", [
Expand All @@ -159,15 +159,15 @@
"*",
["punctuation", "|"]
]],
["attribute", "attr"],
["attr-name", "attr"],
["punctuation", "]"]
]],
["attribute", [
["punctuation", "["],
["namespace", [
["punctuation", "|"]
]],
["attribute", "attr"],
["attr-name", "attr"],
["punctuation", "]"]
]]
]],
Expand All @@ -181,9 +181,9 @@
"foo",
["punctuation", "|"]
]],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "|="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -193,9 +193,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "val"],
["attr-value", "val"],
["case-sensitivity", "i"],
["punctuation", "]"]
]]
Expand All @@ -206,9 +206,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "\"val\""],
["attr-value", "\"val\""],
["case-sensitivity", "S"],
["punctuation", "]"]
]]
Expand All @@ -219,7 +219,7 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["punctuation", "]"]
]]
]],
Expand All @@ -229,9 +229,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "val"],
["attr-value", "val"],
["punctuation", "]"]
]]
]],
Expand All @@ -241,9 +241,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "val"],
["attr-value", "val"],
["case-sensitivity", "i"],
["punctuation", "]"]
]]
Expand All @@ -254,9 +254,9 @@
["selector", [
["attribute", [
["punctuation", "["],
["attribute", "attr"],
["attr-name", "attr"],
["operator", "="],
["value", "\"i#m :not(a.class)\""],
["attr-value", "\"i#m :not(a.class)\""],
["punctuation", "]"]
]]
]],
Expand Down
34 changes: 33 additions & 1 deletion tests/languages/css!+css-extras/selector_feature.test
Expand Up @@ -7,6 +7,14 @@ foo#bar {

#foo > .bar:hover:after {

span,
div {

div > p,
.css-li ~ .css-li,
.previous-selector + .selector,
.selected || td {

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

[
Expand All @@ -32,10 +40,34 @@ foo#bar {

["selector", [
["id", "#foo"],
" > ",
["combinator", ">"],
["class", ".bar"],
["pseudo-class", ":hover"],
["pseudo-element", ":after"]
]], ["punctuation", "{"],

["selector", [
"span",
["punctuation", ","],
"\r\ndiv"
]], ["punctuation", "{"],

["selector", [
"div ",
["combinator", ">"],
" p",
["punctuation", ","],
["class", ".css-li"],
["combinator", "~"],
["class", ".css-li"],
["punctuation", ","],
["class", ".previous-selector"],
["combinator", "+"],
["class", ".selector"],
["punctuation", ","],
["class", ".selected"],
["combinator", "||"],
" td"
]], ["punctuation", "{"]
]

Expand Down