From e98e956d887b4c7dc18e2d5150f998f1a8b716ca Mon Sep 17 00:00:00 2001 From: dutchenkoOleg Date: Thu, 18 Oct 2018 23:57:01 +0300 Subject: [PATCH 1/2] css token important --- components/prism-css.js | 4 ++-- components/prism-css.min.js | 2 +- examples/prism-css.html | 10 ++++++++-- prism.js | 4 ++-- tests/languages/css/important_feature.test | 8 +++++++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/components/prism-css.js b/components/prism-css.js index e6fdf6f6b8..38c77ca953 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -14,7 +14,7 @@ Prism.languages.css = { greedy: true }, 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, - 'important': /\B!important\b/i, + 'important': /!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, 'punctuation': /[(){};:]/ }; @@ -49,4 +49,4 @@ if (Prism.languages.markup) { alias: 'language-css' } }, Prism.languages.markup.tag); -} \ No newline at end of file +} diff --git a/components/prism-css.min.js b/components/prism-css.min.js index 3fe10c8004..c9f7507fac 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.css.atrule.inside.rest=Prism.languages.css,Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/()[\s\S]*?(?=<\/style>)/i,lookbehind:!0,inside:Prism.languages.css,alias:"language-css",greedy:!0}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.css.atrule.inside.rest=Prism.languages.css,Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/()[\s\S]*?(?=<\/style>)/i,lookbehind:!0,inside:Prism.languages.css,alias:"language-css",greedy:!0}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); diff --git a/examples/prism-css.html b/examples/prism-css.html index e211053efd..a36f196676 100644 --- a/examples/prism-css.html +++ b/examples/prism-css.html @@ -7,7 +7,13 @@

Simple rule

p { color: red; }

Important rule

-
p { color: red !important; }
+

+p {
+    color: red !important;
+    line-height: normal!important;
+}
+p{position:absolute!important}
+

@ rule

@media screen and (min-width: 100px) {}
@@ -25,4 +31,4 @@

String

content: 'foo';

URL

-
content: url(foo.png);
\ No newline at end of file +
content: url(foo.png);
diff --git a/prism.js b/prism.js index a60c2ceac4..89eaf85172 100644 --- a/prism.js +++ b/prism.js @@ -647,7 +647,7 @@ Prism.languages.css = { greedy: true }, 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, - 'important': /\B!important\b/i, + 'important': /!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, 'punctuation': /[(){};:]/ }; @@ -889,4 +889,4 @@ Prism.languages.js = Prism.languages.javascript; document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight); -})(); \ No newline at end of file +})(); diff --git a/tests/languages/css/important_feature.test b/tests/languages/css/important_feature.test index ad69c39a43..6d9402c23d 100644 --- a/tests/languages/css/important_feature.test +++ b/tests/languages/css/important_feature.test @@ -1,5 +1,6 @@ color: red !important; padding: 10px 20px 30px !important; +position:absolute!important; ---------------------------------------------------- @@ -12,10 +13,15 @@ padding: 10px 20px 30px !important; ["property", "padding"], ["punctuation", ":"], " 10px 20px 30px ", + ["important", "!important"], + ["punctuation", ";"], + ["property", "position"], + ["punctuation", ":"], + "absolute", ["important", "!important"], ["punctuation", ";"] ] ---------------------------------------------------- -Checks for !important rule. \ No newline at end of file +Checks for !important rule. From 84f12f1e304de7cb6b72b7325506d4d47b1a9075 Mon Sep 17 00:00:00 2001 From: dutchenkoOleg Date: Fri, 19 Oct 2018 00:01:01 +0300 Subject: [PATCH 2/2] indentation --- tests/languages/css/important_feature.test | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/languages/css/important_feature.test b/tests/languages/css/important_feature.test index 6d9402c23d..0f5c1409e9 100644 --- a/tests/languages/css/important_feature.test +++ b/tests/languages/css/important_feature.test @@ -11,15 +11,15 @@ position:absolute!important; ["important", "!important"], ["punctuation", ";"], ["property", "padding"], - ["punctuation", ":"], - " 10px 20px 30px ", - ["important", "!important"], + ["punctuation", ":"], + " 10px 20px 30px ", + ["important", "!important"], ["punctuation", ";"], - ["property", "position"], - ["punctuation", ":"], - "absolute", - ["important", "!important"], - ["punctuation", ";"] + ["property", "position"], + ["punctuation", ":"], + "absolute", + ["important", "!important"], + ["punctuation", ";"] ] ----------------------------------------------------