|
(function (Prism) { |
|
var unit = { |
|
pattern: /(\b\d+)(?:%|[a-z]+)/, |
|
lookbehind: true |
|
}; |
|
|
|
var number = { |
|
pattern: /(^|[^\w.-])-?\d*\.?\d+/, |
|
lookbehind: true |
|
}; |
|
|
|
var inside = { |
|
'comment': { |
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/, |
|
lookbehind: true |
|
}, |
|
'url': { |
|
pattern: /url\((["']?).*?\1\)/i, |
|
greedy: true |
|
}, |
|
'string': { |
|
pattern: /("|')(?:(?!\1)[^\\\r\n]|\\(?:\r\n|[\s\S]))*\1/, |
|
greedy: true |
|
}, |
|
'interpolation': null, |
|
'func': null, |
|
'important': /\B!(?:important|optional)\b/i, |
|
'keyword': { |
|
pattern: /(^|\s+)(?:(?:if|else|for|return|unless)(?=\s+|$)|@[\w-]+)/, |
|
lookbehind: true |
|
}, |
|
'hexcode': /#[\da-f]{3,6}/i, |
|
'color': [ |
|
/\b(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b/i, |
|
{ |
|
pattern: /\b(?:rgb|hsl)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:rgb|hsl)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i, |
|
inside: { |
|
'unit': unit, |
|
'number': number, |
|
'function': /[\w-]+(?=\()/, |
|
'punctuation': /[(),]/ |
|
} |
|
} |
|
], |
|
'entity': /\\[\da-f]{1,8}/i, |
|
'unit': unit, |
|
'boolean': /\b(?:true|false)\b/, |
|
'operator': [ |
|
|
|
|
|
/~|[+!\/%<>?=]=?|[-:]=|\*[*=]?|\.{2,3}|&&|\|\||\B-\B|\b(?:and|in|is(?: a| defined| not|nt)?|not|or)\b/ |
|
], |
|
'number': number, |
|
'punctuation': /[{}()\[\];:,]/ |
|
}; |
|
|
|
inside['interpolation'] = { |
|
pattern: /\{[^\r\n}:]+\}/, |
|
alias: 'variable', |
|
inside: { |
|
'delimiter': { |
|
pattern: /^{|}$/, |
|
alias: 'punctuation' |
|
}, |
|
rest: inside |
|
} |
|
}; |
|
inside['func'] = { |
|
pattern: /[\w-]+\([^)]*\).*/, |
|
inside: { |
|
'function': /^[^(]+/, |
|
rest: inside |
|
} |
|
}; |
|
|
|
Prism.languages.stylus = { |
|
'atrule-declaration': { |
|
pattern: /(^\s*)@.+/m, |
|
lookbehind: true, |
|
inside: { |
|
'atrule': /^@[\w-]+/, |
|
rest: inside |
|
} |
|
}, |
|
'variable-declaration': { |
|
pattern: /(^[ \t]*)[\w$-]+\s*.?=[ \t]*(?:(?:\{[^}]*\}|.+)|$)/m, |
|
lookbehind: true, |
|
inside: { |
|
'variable': /^\S+/, |
|
rest: inside |
|
} |
|
}, |
|
|
|
'statement': { |
|
pattern: /(^[ \t]*)(?:if|else|for|return|unless)[ \t]+.+/m, |
|
lookbehind: true, |
|
inside: { |
|
'keyword': /^\S+/, |
|
rest: inside |
|
} |
|
}, |
|
|
|
|
|
|
|
'property-declaration': { |
|
pattern: /((?:^|\{)([ \t]*))(?:[\w-]|\{[^}\r\n]+\})+(?:\s*:\s*|[ \t]+)[^{\r\n]*(?:;|[^{\r\n,](?=$)(?!(?:\r?\n|\r)(?:\{|\2[ \t]+)))/m, |
|
lookbehind: true, |
|
inside: { |
|
'property': { |
|
pattern: /^[^\s:]+/, |
|
inside: { |
|
'interpolation': inside.interpolation |
|
} |
|
}, |
|
rest: inside |
|
} |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
'selector': { |
|
|
|
|
|
|
|
pattern: /(^[ \t]*)(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)(?:(?:\r?\n|\r)(?:\1(?:(?=\S)(?:[^{}\r\n:()]|::?[\w-]+(?:\([^)\r\n]*\)|(?![\w-]))|\{[^}\r\n]+\})+)))*(?:,$|\{|(?=(?:\r?\n|\r)(?:\{|\1[ \t]+)))/m, |
|
lookbehind: true, |
|
inside: { |
|
'interpolation': inside.interpolation, |
|
'comment': inside.comment, |
|
'punctuation': /[{},]/ |
|
} |
|
}, |
|
|
|
'func': inside.func, |
|
'string': inside.string, |
|
'comment': { |
|
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/, |
|
lookbehind: true, |
|
greedy: true |
|
}, |
|
'interpolation': inside.interpolation, |
|
'punctuation': /[{}()\[\];:.]/ |
|
}; |
|
}(Prism)); |
|
|