diff --git a/components/prism-css-extras.js b/components/prism-css-extras.js index 766a5b0bb9..1b8571462b 100644 --- a/components/prism-css-extras.js +++ b/components/prism-css-extras.js @@ -4,7 +4,8 @@ Prism.languages.css.selector = { 'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/, 'pseudo-class': /:[-\w]+(?:\(.*\))?/, 'class': /\.[-:\.\w]+/, - 'id': /#[-:\.\w]+/ + 'id': /#[-:\.\w]+/, + 'attribute': /\[[^\]]+\]/ } }; diff --git a/components/prism-css-extras.min.js b/components/prism-css-extras.min.js index 0a753ea13e..d5ef4b643c 100644 --- a/components/prism-css-extras.min.js +++ b/components/prism-css-extras.min.js @@ -1 +1 @@ -Prism.languages.css.selector={pattern:/[^\{\}\s][^\{\}]*(?=\s*\{)/,inside:{"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,"pseudo-class":/:[-\w]+(?:\(.*\))?/,"class":/\.[-:\.\w]+/,id:/#[-:\.\w]+/}},Prism.languages.insertBefore("css","function",{hexcode:/#[\da-f]{3,6}/i,entity:/\\[\da-f]{1,8}/i,number:/[\d%\.]+/}); \ No newline at end of file +Prism.languages.css.selector={pattern:/[^\{\}\s][^\{\}]*(?=\s*\{)/,inside:{"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,"pseudo-class":/:[-\w]+(?:\(.*\))?/,"class":/\.[-:\.\w]+/,id:/#[-:\.\w]+/,attribute:/\[[^\]]+\]/}},Prism.languages.insertBefore("css","function",{hexcode:/#[\da-f]{3,6}/i,entity:/\\[\da-f]{1,8}/i,number:/[\d%\.]+/}); \ No newline at end of file diff --git a/tests/languages/css!+css-extras/selector_feature.test b/tests/languages/css!+css-extras/selector_feature.test index 475ed1b7c4..3931a66334 100644 --- a/tests/languages/css!+css-extras/selector_feature.test +++ b/tests/languages/css!+css-extras/selector_feature.test @@ -9,6 +9,8 @@ foo#bar { #foo > .bar:not(baz):after { +div[foo="bar"] { + ---------------------------------------------------- [ @@ -43,6 +45,11 @@ foo#bar { ["class", ".bar"], ["pseudo-class", ":not(baz)"], ["pseudo-element", ":after"] + ]], ["punctuation", "{"], + + ["selector", [ + "div", + ["attribute", "[foo=\"bar\"]"] ]], ["punctuation", "{"] ]