OLD | NEW |
1 Prism.languages.stylus = { | 1 (function (Prism) { |
2 » 'comment': { | 2 » var inside = { |
3 » » pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g, | 3 » » 'url': /url\((["']?).*?\1\)/i, |
4 » » lookbehind: true | 4 » » 'string': /("|')(?:[^\\\r\n]|\\(?:\r\n|[\s\S]))*?\1/, |
5 » }, | 5 » » 'interpolation': null, // See below |
6 » 'keyword': /(px|r?em|ex|ch|vw|vh|vmin|vmax|deg|grad|rad|turn|m?s|k?Hz|dp
i|dppx|dpcm)\b|\b(is|defined|not|isnt|and|or|unless|for|in)\b/g, | 6 » » 'func': null, // See below |
7 » 'atrule': /@[\w-]+(?=\s+\S+)/gi, | 7 » » 'important': /\B!(?:important|optional)\b/i, |
8 » 'url': /url\((["']?).*?\1\)/gi, | 8 » » 'keyword': { |
9 » 'variable': /^\s*([\w-]+)(?=\s*[+-\\]?=)/gm, | 9 » » » pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|
$)|@[\w-]+)/, |
10 » 'string': /("|')(\\\n|\\?.)*?\1/g, | 10 » » » lookbehind: true |
11 » 'important': /\B!important\b/gi, | 11 » » }, |
12 » 'hexcode': /#[\da-f]{3,6}/gi, | 12 » » 'hexcode': /#[\da-f]{3,6}/i, |
13 » 'entity': /\\[\da-f]{1,8}/gi, | 13 » » 'number': /\b\d+(?:\.\d+)?%?/, |
14 » 'number': /\d+\.?\d*%?/g, | 14 » » 'boolean': /\b(?:true|false)\b/, |
15 » 'selector': [ | 15 » » 'operator': [ |
16 » » { | 16 » » » // We want non-word chars around "-" because it is |
17 » » » pattern: /::?(after|before|first-letter|first-line|selec
tion)/g, | 17 » » » // accepted in property names. |
18 » » » alias: 'pseudo-element' | 18 » » » /~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.+|&&|\|\||\B-\B|\b(?:an
d|in|is(?: a| defined| not|nt)?|not|or)\b/ |
19 » » },{ | 19 » » ], |
20 » » » pattern: /:(?:active|checked|disabled|empty|enabled|firs
t-child|first-of-type|focus|hover|in-range|invalid|lang|last-child|last-of-type|
link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-of-type|only
-child|optional|out-of-range|read-only|read-write|required|root|target|valid|vis
ited)(?:\(.*\))?/g, | 20 » » 'punctuation': /[{}()\[\];:,]/ |
21 » » » alias:'pseudo-class' | 21 » }; |
22 » » },{ | 22 |
23 » » » pattern: /\[[\w-]+?\s*[*~$^|=]?(?:=\s*\S+)?\]/g, | 23 » inside['interpolation'] = { |
| 24 » » pattern: /\{[^\r\n}:]+\}/, |
| 25 » » alias: 'variable', |
| 26 » » inside: Prism.util.clone(inside) |
| 27 » }; |
| 28 » inside['func'] = { |
| 29 » » pattern: /[\w-]+\([^)]*\).*/, |
| 30 » » inside: { |
| 31 » » » 'function': /^[^(]+/, |
| 32 » » » rest: Prism.util.clone(inside) |
| 33 » » } |
| 34 » }; |
| 35 |
| 36 » Prism.languages.stylus = { |
| 37 » » 'comment': { |
| 38 » » » pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*)/, |
| 39 » » » lookbehind: true |
| 40 » » }, |
| 41 » » 'atrule-declaration': { |
| 42 » » » pattern: /(^\s*)@.+/m, |
| 43 » » » lookbehind: true, |
24 inside: { | 44 inside: { |
25 » » » » "attr-name": | 45 » » » » 'atrule': /^@[\w-]+/, |
26 » » » » { | 46 » » » » rest: inside |
27 » » » » » pattern: /(\[)([\w-]+)(?=\s*[*~$^|=]{0,2
})/g, | 47 » » » } |
28 » » » » » lookbehind: true | 48 » » }, |
| 49 » » 'variable-declaration': { |
| 50 » » » pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+
)|$)/m, |
| 51 » » » lookbehind: true, |
| 52 » » » inside: { |
| 53 » » » » 'variable': /^\S+/, |
| 54 » » » » rest: inside |
| 55 » » » } |
| 56 » » }, |
| 57 |
| 58 » » 'statement': { |
| 59 » » » pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+
/m, |
| 60 » » » lookbehind: true, |
| 61 » » » inside: { |
| 62 » » » » keyword: /^\S+/, |
| 63 » » » » rest: inside |
| 64 » » » } |
| 65 » » }, |
| 66 |
| 67 » » // A property/value pair cannot end with a comma or a brace |
| 68 » » // It cannot have indented content unless it ended with a semico
lon |
| 69 » » 'property-declaration': { |
| 70 » » » pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\
s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(\r?\n|\r)(?:\{|\2[ \t]+)))/m, |
| 71 » » » lookbehind: true, |
| 72 » » » inside: { |
| 73 » » » » 'property': { |
| 74 » » » » » pattern: /^[^\s:]+/, |
| 75 » » » » » inside: { |
| 76 » » » » » » 'interpolation': inside.interpol
ation |
| 77 » » » » » } |
29 }, | 78 }, |
30 » » » » "punctuation": /\[|\]/g, | 79 » » » » rest: inside |
31 » » » » "operator": /[*~$^|=]/g, | 80 » » » } |
32 » » » » "attr-value": { | |
33 » » » » » pattern: /\S+/ | |
34 » » » » }, | |
35 » » » }, | |
36 » » » alias: 'attr' | |
37 }, | 81 }, |
38 » » { | 82 |
39 » » » pattern: /\.[a-z-]+/i, | 83 |
40 » » » alias: 'class' | 84 |
| 85 » » // A selector can contain parentheses only as part of a pseudo-e
lement |
| 86 » » // It can span multiple lines. |
| 87 » » // It must end with a comma or an accolade or have indented cont
ent. |
| 88 » » 'selector': { |
| 89 » » » pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:
\([^)\r\n]*\))?|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?
[\w-]+(?:\([^)\r\n]*\))?|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t
]+)))/m, |
| 90 » » » lookbehind: true, |
| 91 » » » inside: { |
| 92 » » » » 'interpolation': inside.interpolation, |
| 93 » » » » 'punctuation': /[{},]/ |
| 94 » » » } |
41 }, | 95 }, |
42 » » { | 96 |
43 » » » pattern: /#[a-z-]+/i, | 97 » » 'func': inside.func, |
44 » » » alias: 'id' | 98 » » 'string': inside.string, |
45 » » }, | 99 » » 'interpolation': inside.interpolation, |
46 » » { | 100 » » 'punctuation': /[{}()\[\];:.]/ |
47 » » » pattern: /\b(html|head|title|base|link|meta|style|script
|noscript|template|body|section|nav|article|aside|h[1-6]|header|footer|address|m
ain|p|hr|pre|blockquote|ol|ul|li|dl|dt|dd|figure|figcaption|div|a|em|strong|smal
l|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bd
i|dbo|span|br|wbr|ins|del|image|iframe|embed|object|param|video|audio|source|tra
ck|canvas|map|area|sv|math|table|caption|colgroup|col|tbody|thead|tfoot|tr|td|th
|form|fieldset|legeng|label|input|button|select|datalist|optgroup|option|textare
a|keygen|output|progress|meter|details|summary|menuitem|menu)\b/g, | 101 » }; |
48 » » » alias: 'tag' | 102 }(Prism)); |
49 » » }, | |
50 » ], | |
51 » 'property': [ | |
52 » » /^\s*([a-z-]+)(?=\s+[\w\W]+|\s*:)(?!\s*\{|\r?\n)/mig, | |
53 » » { | |
54 » » » pattern: /(\(\s*)([a-z-]+)(?=\s*:)/ig, | |
55 » » » lookbehind: true | |
56 » » } | |
57 » ], | |
58 » 'function': /[-a-z0-9]+(?=\()/ig, | |
59 » 'punctuation': /[\{\};:]/g, | |
60 » 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/g | |
61 } | |
OLD | NEW |