CSS: Improved url and added keywords (#2432)
This commit is contained in:
parent
22eb5cadf1
commit
964de5a1e1
|
@ -12,16 +12,25 @@
|
|||
pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,
|
||||
lookbehind: true,
|
||||
alias: 'selector'
|
||||
},
|
||||
'keyword': {
|
||||
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
||||
lookbehind: true
|
||||
}
|
||||
// See rest below
|
||||
}
|
||||
},
|
||||
'url': {
|
||||
pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
|
||||
// https://drafts.csswg.org/css-values-3/#urls
|
||||
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
||||
greedy: true,
|
||||
inside: {
|
||||
'function': /^url/i,
|
||||
'punctuation': /^\(|\)$/
|
||||
'punctuation': /^\(|\)$/,
|
||||
'string': {
|
||||
pattern: RegExp('^' + string.source + '$'),
|
||||
alias: 'url'
|
||||
}
|
||||
}
|
||||
},
|
||||
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
|
||||
|
|
|
@ -1 +1 @@
|
|||
!function(s){var e=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,lookbehind:!0,alias:"selector"}}},url:{pattern:RegExp("url\\((?:"+e.source+"|[^\n\r()]*)\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/}},selector:RegExp("[^{}\\s](?:[^{};\"']|"+e.source+")*?(?=\\s*\\{)"),string:{pattern:e,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var t=s.languages.markup;t&&(t.tag.addInlined("style","css"),s.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:t.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:s.languages.css}},alias:"language-css"}},t.tag))}(Prism);
|
||||
!function(e){var s=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+s.source+"|(?:[^\\\\\r\n()\"']|\\\\[^])*)\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+s.source+"$"),alias:"url"}}},selector:RegExp("[^{}\\s](?:[^{};\"']|"+s.source+")*?(?=\\s*\\{)"),string:{pattern:s,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var t=e.languages.markup;t&&(t.tag.addInlined("style","css"),e.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:t.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:e.languages.css}},alias:"language-css"}},t.tag))}(Prism);
|
13
prism.js
13
prism.js
|
@ -1329,16 +1329,25 @@ Prism.languages.rss = Prism.languages.xml;
|
|||
pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,
|
||||
lookbehind: true,
|
||||
alias: 'selector'
|
||||
},
|
||||
'keyword': {
|
||||
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
||||
lookbehind: true
|
||||
}
|
||||
// See rest below
|
||||
}
|
||||
},
|
||||
'url': {
|
||||
pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
|
||||
// https://drafts.csswg.org/css-values-3/#urls
|
||||
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
||||
greedy: true,
|
||||
inside: {
|
||||
'function': /^url/i,
|
||||
'punctuation': /^\(|\)$/
|
||||
'punctuation': /^\(|\)$/,
|
||||
'string': {
|
||||
pattern: RegExp('^' + string.source + '$'),
|
||||
alias: 'url'
|
||||
}
|
||||
}
|
||||
},
|
||||
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
["punctuation", ":"],
|
||||
" 640px",
|
||||
["punctuation", ")"],
|
||||
" and ",
|
||||
["keyword", "and"],
|
||||
["punctuation", "("],
|
||||
["property", "min-height"],
|
||||
["punctuation", ":"],
|
||||
|
@ -47,7 +47,7 @@
|
|||
["punctuation", ":"],
|
||||
" 50vmax",
|
||||
["punctuation", ")"],
|
||||
"\r\n\tor ",
|
||||
["keyword", "or"],
|
||||
["punctuation", "("],
|
||||
["property", "top"],
|
||||
["punctuation", ":"],
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
url(foo.png)
|
||||
url(close\)parens)
|
||||
url('foo.png')
|
||||
url("foo.png")
|
||||
url('foo\
|
||||
|
@ -21,25 +22,31 @@ bar.png")
|
|||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"'foo.png'",
|
||||
"close\\)parens",
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"\"foo.png\"",
|
||||
["string", "'foo.png'"],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"'foo\\\r\nbar.png'",
|
||||
["string", "\"foo.png\""],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"\"foo\\\r\nbar.png\"",
|
||||
["string", "'foo\\\r\nbar.png'"],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
["string", "\"foo\\\r\nbar.png\""],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["atrule", [
|
||||
|
@ -47,7 +54,7 @@ bar.png")
|
|||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"\"https://cdn.jsdelivr.net/npm/prismj1.19.0/themes/prism-dark.css\"",
|
||||
["string", "\"https://cdn.jsdelivr.net/npm/prismj1.19.0/themes/prism-dark.css\""],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["punctuation", ";"]
|
||||
|
@ -57,7 +64,7 @@ bar.png")
|
|||
["url", [
|
||||
["function", "url"],
|
||||
["punctuation", "("],
|
||||
"\"https://cdn.jsdelivr.net/npm/prismjs/themes/prism-dark.css\"",
|
||||
["string", "\"https://cdn.jsdelivr.net/npm/prismjs/themes/prism-dark.css\""],
|
||||
["punctuation", ")"]
|
||||
]],
|
||||
["punctuation", ";"]
|
||||
|
|
Loading…
Reference in New Issue