Skip to content

Commit

Permalink
Allow multiline CSS at-rules (#1676)
Browse files Browse the repository at this point in the history
Allows for CSS at-rules containing line breaks.
  • Loading branch information
valtlai authored and RunDevelopment committed Dec 24, 2018
1 parent b48c012 commit 4f6f3c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/prism-css.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Prism.languages.css = {
'comment': /\/\*[\s\S]*?\*\//,
'atrule': {
pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,
inside: {
'rule': /@[\w-]+/
// See rest below
Expand Down
2 changes: 1 addition & 1 deletion components/prism-css.min.js

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

2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ Prism.languages.svg = Prism.languages.markup;
Prism.languages.css = {
'comment': /\/\*[\s\S]*?\*\//,
'atrule': {
pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,
inside: {
'rule': /@[\w-]+/
// See rest below
Expand Down
28 changes: 23 additions & 5 deletions tests/languages/css/atrule_feature.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import url(foo.css);
@media print {}
@media (min-width: 640px) and (min-height: 1000px) {}
@supports (top: 50vmax)
or (top: 50vw) {}
@main-color: red;

----------------------------------------------------
Expand All @@ -26,13 +28,29 @@
["punctuation", ")"],
" and ",
["punctuation", "("],
["property", "min-height"],
["punctuation", ":"],
" 1000px",
["punctuation", ")"]
["property", "min-height"],
["punctuation", ":"],
" 1000px",
["punctuation", ")"]
]],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", "}"],
["atrule", [
["rule", "@supports"],
["punctuation", "("],
["property", "top"],
["punctuation", ":"],
" 50vmax",
["punctuation", ")"],
"\r\n\tor ",
["punctuation", "("],
["property", "top"],
["punctuation", ":"],
" 50vw",
["punctuation", ")"]
]],
["punctuation", "{"],
["punctuation", "}"],
["atrule", [
["rule", "@main-color"],
["punctuation", ":"],
Expand Down

0 comments on commit 4f6f3c7

Please sign in to comment.