(function (Prism) { var id = /(?:\B-|\b_|\b)[A-Za-z][\w-]*(?![\w-])/.source; var type = '(?:' + /\b(?:unsigned\s+)?long\s+long(?![\w-])/.source + '|' + /\b(?:unrestricted|unsigned)\s+[a-z]+(?![\w-])/.source + '|' + /(?!(?:unrestricted|unsigned)\b)/.source + id + /(?:\s*<(?:[^<>]|<[^<>]*>)*>)?/.source + ')' + /(?:\s*\?)?/.source; var typeInside = {}; Prism.languages['web-idl'] = { comment: { pattern: /\/\/.*|\/\*[\s\S]*?\*\//, greedy: true, }, string: { pattern: /"[^"]*"/, greedy: true, }, namespace: { pattern: RegExp(/(\bnamespace\s+)/.source + id), lookbehind: true, }, 'class-name': [ { pattern: /(^|[^\w-])(?:iterable|maplike|setlike)\s*<(?:[^<>]|<[^<>]*>)*>/, lookbehind: true, inside: typeInside, }, { pattern: RegExp( /(\b(?:attribute|const|deleter|getter|optional|setter)\s+)/.source + type ), lookbehind: true, inside: typeInside, }, { // callback return type pattern: RegExp( '(' + /\bcallback\s+/.source + id + /\s*=\s*/.source + ')' + type ), lookbehind: true, inside: typeInside, }, { // typedef pattern: RegExp(/(\btypedef\b\s*)/.source + type), lookbehind: true, inside: typeInside, }, { pattern: RegExp( /(\b(?:callback|dictionary|enum|interface(?:\s+mixin)?)\s+)(?!(?:interface|mixin)\b)/ .source + id ), lookbehind: true, }, { // inheritance pattern: RegExp(/(:\s*)/.source + id), lookbehind: true, }, // includes and implements RegExp(id + /(?=\s+(?:implements|includes)\b)/.source), { pattern: RegExp(/(\b(?:implements|includes)\s+)/.source + id), lookbehind: true, }, { // function return type, parameter types, and dictionary members pattern: RegExp( type + '(?=' + /\s*(?:\.{3}\s*)?/.source + id + /\s*[(),;=]/.source + ')' ), inside: typeInside, }, ], builtin: /\b(?:ArrayBuffer|BigInt64Array|BigUint64Array|ByteString|DOMString|DataView|Float32Array|Float64Array|FrozenArray|Int16Array|Int32Array|Int8Array|ObservableArray|Promise|USVString|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray)\b/, keyword: [ /\b(?:async|attribute|callback|const|constructor|deleter|dictionary|enum|getter|implements|includes|inherit|interface|mixin|namespace|null|optional|or|partial|readonly|required|setter|static|stringifier|typedef|unrestricted)\b/, // type keywords /\b(?:any|bigint|boolean|byte|double|float|iterable|long|maplike|object|octet|record|sequence|setlike|short|symbol|undefined|unsigned|void)\b/, ], boolean: /\b(?:false|true)\b/, number: { pattern: /(^|[^\w-])-?(?:0x[0-9a-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|NaN|Infinity)(?![\w-])/i, lookbehind: true, }, operator: /\.{3}|[=:?<>-]/, punctuation: /[(){}[\].,;]/, }; for (var key in Prism.languages['web-idl']) { if (key !== 'class-name') { typeInside[key] = Prism.languages['web-idl'][key]; } } Prism.languages['webidl'] = Prism.languages['web-idl']; })(Prism); >2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
Prism.languages.scss = Prism.languages.extend('css', {
comment: {
pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
lookbehind: true,
},
atrule: {
pattern: /@[\w-](?:\([^()]+\)|[^()\s]|\s+(?!\s))*?(?=\s+[{;])/,
inside: {
rule: /@[\w-]+/,
// See rest below
},
},
// url, compassified
url: /(?:[-a-z]+-)?url(?=\()/i,
// CSS selector regex is not appropriate for Sass
// since there can be lot more things (var, @ directive, nesting..)
// a selector must start at the end of a property or after a brace (end of other rules or nesting)
// it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
// the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var
// can "pass" as a selector- e.g: proper#{$erty})
// this one was hard to do, so please be careful if you edit this one :)
selector: {
// Initial look-ahead is used to prevent matching of blank selectors
pattern:
/(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/,
inside: {
parent: {
pattern: /&/,
alias: 'important',
},
placeholder: /%[-\w]+/,
variable: /\$[-\w]+|#\{\$[-\w]+\}/,
},
},
property: {
pattern: /(?:[-\w]|\$[-\w]|#\{\$[-\w]+\})+(?=\s*:)/,
inside: {
variable: /\$[-\w]+|#\{\$[-\w]+\}/,
},
},
});
Prism.languages.insertBefore('scss', 'atrule', {
keyword: [
/@(?:content|debug|each|else(?: if)?|extend|for|forward|function|if|import|include|mixin|return|use|warn|while)\b/i,
{
pattern: /( )(?:from|through)(?= )/,
lookbehind: true,
},
],
});
Prism.languages.insertBefore('scss', 'important', {
// var and interpolated vars
variable: /\$[-\w]+|#\{\$[-\w]+\}/,
});
Prism.languages.insertBefore('scss', 'function', {
'module-modifier': {
pattern: /\b(?:as|hide|show|with)\b/i,
alias: 'keyword',
},
placeholder: {
pattern: /%[-\w]+/,
alias: 'selector',
},
statement: {
pattern: /\B!(?:default|optional)\b/i,
alias: 'keyword',
},
boolean: /\b(?:false|true)\b/,
null: {
pattern: /\bnull\b/,
alias: 'keyword',
},
operator: {
pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|not|or)(?=\s)/,
lookbehind: true,
},
});
Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;