Skip to content

Commit

Permalink
CSS Extras: Optimized class and id patterns (#2359)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed May 18, 2020
1 parent b526e8c commit fdbc447
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
4 changes: 2 additions & 2 deletions components/prism-css-extras.js
Expand Up @@ -8,8 +8,8 @@
inside: selectorInside = {
'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
'pseudo-class': /:[-\w]+/,
'class': /\.[-:.\w]+/,
'id': /#[-:.\w]+/,
'class': /\.[-\w]+/,
'id': /#[-\w]+/,
'attribute': {
pattern: RegExp('\\[(?:[^[\\]"\']|' + string.source + ')*\\]'),
greedy: true,
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.

42 changes: 6 additions & 36 deletions tests/languages/css!+css-extras/selector_feature.test
@@ -1,20 +1,12 @@
foo:after {
foo::first-letter {

foo.bar {
foo.bar.baz {

foo#bar {
foo#bar.baz {

#foo > .bar:hover:after {

span,
div {

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

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

[
Expand All @@ -30,12 +22,14 @@ div > p,

["selector", [
"foo",
["class", ".bar"]
["class", ".bar"],
["class", ".baz"]
]], ["punctuation", "{"],

["selector", [
"foo",
["id", "#bar"]
["id", "#bar"],
["class", ".baz"]
]], ["punctuation", "{"],

["selector", [
Expand All @@ -44,30 +38,6 @@ div > p,
["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

0 comments on commit fdbc447

Please sign in to comment.