History

Update prism.js to use spaces instead of tabs like it is now

Jasper van Merle committed 7 years ago

Commit f2a38db1 parent 0574de61 file · +2568 −2568Browse files

Showing the changes to assets/javascripts (1 of 1 file). Show all

Unified · Split

assets/javascripts/vendor/prism.js+2568−2568
@@ -1,12 +1,12 @@
11 /* PrismJS 1.17.1
22 https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+markup-templating+elixir+erlang+go+groovy+java+php+json+julia+kotlin+crystal+lua+django+matlab+typescript+nginx+nim+perl+sql+scss+python+jsx+rust+yaml */
33 var _self = (typeof window !== 'undefined')
4− ? window // if in browser
5− : (
6− (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
7− ? self // if in worker
8− : {} // if in node js
9− );
4+ ? window // if in browser
5+ : (
6+ (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
7+ ? self // if in worker
8+ : {} // if in node js
9+ );
1010
1111 /**
1212 * Prism: Lightweight, robust, elegant syntax highlighting
@@ -17,635 +17,635 @@ var _self = (typeof window !== 'undefined') · 4 unmodified lines
1717 var Prism = (function (_self){
1818
1919 // Private helper vars
20−var lang = /\blang(?:uage)?-([\w-]+)\b/i;
21−var uniqueId = 0;
22−
23−var _ = {
24− manual: _self.Prism && _self.Prism.manual,
25− disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
26− util: {
27− encode: function (tokens) {
28− if (tokens instanceof Token) {
29− return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
30− } else if (Array.isArray(tokens)) {
31− return tokens.map(_.util.encode);
32− } else {
33− return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
34− }
35− },
36−
37− type: function (o) {
38− return Object.prototype.toString.call(o).slice(8, -1);
39− },
40−
41− objId: function (obj) {
42− if (!obj['__id']) {
43− Object.defineProperty(obj, '__id', { value: ++uniqueId });
44− }
45− return obj['__id'];
46− },
47−
48− // Deep clone a language definition (e.g. to extend it)
49− clone: function deepClone(o, visited) {
50− var clone, id, type = _.util.type(o);
51− visited = visited || {};
52−
53− switch (type) {
54− case 'Object':
55− id = _.util.objId(o);
56− if (visited[id]) {
57− return visited[id];
58− }
59− clone = {};
60− visited[id] = clone;
61−
62− for (var key in o) {
63− if (o.hasOwnProperty(key)) {
64− clone[key] = deepClone(o[key], visited);
65− }
66− }
67−
68− return clone;
69−
70− case 'Array':
71− id = _.util.objId(o);
72− if (visited[id]) {
73− return visited[id];
74− }
75− clone = [];
76− visited[id] = clone;
77−
78− o.forEach(function (v, i) {
79− clone[i] = deepClone(v, visited);
80− });
81−
82− return clone;
83−
84− default:
85− return o;
86− }
87− }
88− },
89−
90− languages: {
91− extend: function (id, redef) {
92− var lang = _.util.clone(_.languages[id]);
93−
94− for (var key in redef) {
95− lang[key] = redef[key];
96− }
97−
98− return lang;
99− },
100−
101− /**
102− * Insert a token before another token in a language literal
103− * As this needs to recreate the object (we cannot actually insert before keys in object literals),
104− * we cannot just provide an object, we need an object and a key.
105− * @param inside The key (or language id) of the parent
106− * @param before The key to insert before.
107− * @param insert Object with the key/value pairs to insert
108− * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
109− */
110− insertBefore: function (inside, before, insert, root) {
111− root = root || _.languages;
112− var grammar = root[inside];
113− var ret = {};
114−
115− for (var token in grammar) {
116− if (grammar.hasOwnProperty(token)) {
117−
118− if (token == before) {
119− for (var newToken in insert) {
120− if (insert.hasOwnProperty(newToken)) {
121− ret[newToken] = insert[newToken];
122− }
123− }
124− }
125−
126− // Do not insert token which also occur in insert. See #1525
127− if (!insert.hasOwnProperty(token)) {
128− ret[token] = grammar[token];
129− }
130− }
131− }
132−
133− var old = root[inside];
134− root[inside] = ret;
135−
136− // Update references in other language definitions
137− _.languages.DFS(_.languages, function(key, value) {
138− if (value === old && key != inside) {
139− this[key] = ret;
140− }
141− });
142−
143− return ret;
144− },
145−
146− // Traverse a language definition with Depth First Search
147− DFS: function DFS(o, callback, type, visited) {
148− visited = visited || {};
149−
150− var objId = _.util.objId;
151−
152− for (var i in o) {
153− if (o.hasOwnProperty(i)) {
154− callback.call(o, i, o[i], type || i);
155−
156− var property = o[i],
157− propertyType = _.util.type(property);
158−
159− if (propertyType === 'Object' && !visited[objId(property)]) {
160− visited[objId(property)] = true;
161− DFS(property, callback, null, visited);
162− }
163− else if (propertyType === 'Array' && !visited[objId(property)]) {
164− visited[objId(property)] = true;
165− DFS(property, callback, i, visited);
166− }
167− }
168− }
169− }
170− },
171− plugins: {},
172−
173− highlightAll: function(async, callback) {
174− _.highlightAllUnder(document, async, callback);
175− },
176−
177− highlightAllUnder: function(container, async, callback) {
178− var env = {
179− callback: callback,
180− selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
181− };
182−
183− _.hooks.run('before-highlightall', env);
184−
185− var elements = container.querySelectorAll(env.selector);
186−
187− for (var i=0, element; element = elements[i++];) {
188− _.highlightElement(element, async === true, env.callback);
189− }
190− },
191−
192− highlightElement: function(element, async, callback) {
193− // Find language
194− var language = 'none', grammar, parent = element;
195−
196− while (parent && !lang.test(parent.className)) {
197− parent = parent.parentNode;
198− }
199−
200− if (parent) {
201− language = (parent.className.match(lang) || [,'none'])[1].toLowerCase();
202− grammar = _.languages[language];
203− }
204−
205− // Set language on the element, if not present
206− element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
207−
208− if (element.parentNode) {
209− // Set language on the parent, for styling
210− parent = element.parentNode;
211−
212− if (/pre/i.test(parent.nodeName)) {
213− parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
214− }
215− }
216−
217− var code = element.textContent;
218−
219− var env = {
220− element: element,
221− language: language,
222− grammar: grammar,
223− code: code
224− };
225−
226− var insertHighlightedCode = function (highlightedCode) {
227− env.highlightedCode = highlightedCode;
228−
229− _.hooks.run('before-insert', env);
230−
231− env.element.innerHTML = env.highlightedCode;
232−
233− _.hooks.run('after-highlight', env);
234− _.hooks.run('complete', env);
235− callback && callback.call(env.element);
236− }
237−
238− _.hooks.run('before-sanity-check', env);
239−
240− if (!env.code) {
241− _.hooks.run('complete', env);
242− return;
243− }
244−
245− _.hooks.run('before-highlight', env);
246−
247− if (!env.grammar) {
248− insertHighlightedCode(_.util.encode(env.code));
249− return;
250− }
251−
252− if (async && _self.Worker) {
253− var worker = new Worker(_.filename);
254−
255− worker.onmessage = function(evt) {
256− insertHighlightedCode(evt.data);
257− };
258−
259− worker.postMessage(JSON.stringify({
260− language: env.language,
261− code: env.code,
262− immediateClose: true
263− }));
264− }
265− else {
266− insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
267− }
268− },
269−
270− highlight: function (text, grammar, language) {
271− var env = {
272− code: text,
273− grammar: grammar,
274− language: language
275− };
276− _.hooks.run('before-tokenize', env);
277− env.tokens = _.tokenize(env.code, env.grammar);
278− _.hooks.run('after-tokenize', env);
279− return Token.stringify(_.util.encode(env.tokens), env.language);
280− },
281−
282− matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
283− for (var token in grammar) {
284− if(!grammar.hasOwnProperty(token) || !grammar[token]) {
285− continue;
286− }
287−
288− if (token == target) {
289− return;
290− }
291−
292− var patterns = grammar[token];
293− patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
294−
295− for (var j = 0; j < patterns.length; ++j) {
296− var pattern = patterns[j],
297− inside = pattern.inside,
298− lookbehind = !!pattern.lookbehind,
299− greedy = !!pattern.greedy,
300− lookbehindLength = 0,
301− alias = pattern.alias;
302−
303− if (greedy && !pattern.pattern.global) {
304− // Without the global flag, lastIndex won't work
305− var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
306− pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
307− }
308−
309− pattern = pattern.pattern || pattern;
310−
311− // Don’t cache length as it changes during the loop
312− for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
313−
314− var str = strarr[i];
315−
316− if (strarr.length > text.length) {
317− // Something went terribly wrong, ABORT, ABORT!
318− return;
319− }
320−
321− if (str instanceof Token) {
322− continue;
323− }
324−
325− if (greedy && i != strarr.length - 1) {
326− pattern.lastIndex = pos;
327− var match = pattern.exec(text);
328− if (!match) {
329− break;
330− }
331−
332− var from = match.index + (lookbehind ? match[1].length : 0),
333− to = match.index + match[0].length,
334− k = i,
335− p = pos;
336−
337− for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
338− p += strarr[k].length;
339− // Move the index i to the element in strarr that is closest to from
340− if (from >= p) {
341− ++i;
342− pos = p;
343− }
344− }
345−
346− // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
347− if (strarr[i] instanceof Token) {
348− continue;
349− }
350−
351− // Number of tokens to delete and replace with the new match
352− delNum = k - i;
353− str = text.slice(pos, p);
354− match.index -= pos;
355− } else {
356− pattern.lastIndex = 0;
357−
358− var match = pattern.exec(str),
359− delNum = 1;
360− }
361−
362− if (!match) {
363− if (oneshot) {
364− break;
365− }
366−
367− continue;
368− }
369−
370− if(lookbehind) {
371− lookbehindLength = match[1] ? match[1].length : 0;
372− }
373−
374− var from = match.index + lookbehindLength,
375− match = match[0].slice(lookbehindLength),
376− to = from + match.length,
377− before = str.slice(0, from),
378− after = str.slice(to);
379−
380− var args = [i, delNum];
20+ var lang = /\blang(?:uage)?-([\w-]+)\b/i;
21+ var uniqueId = 0;
22+
23+ var _ = {
24+ manual: _self.Prism && _self.Prism.manual,
25+ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
26+ util: {
27+ encode: function (tokens) {
28+ if (tokens instanceof Token) {
29+ return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
30+ } else if (Array.isArray(tokens)) {
31+ return tokens.map(_.util.encode);
32+ } else {
33+ return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
34+ }
35+ },
36+
37+ type: function (o) {
38+ return Object.prototype.toString.call(o).slice(8, -1);
39+ },
40+
41+ objId: function (obj) {
42+ if (!obj['__id']) {
43+ Object.defineProperty(obj, '__id', { value: ++uniqueId });
44+ }
45+ return obj['__id'];
46+ },
47+
48+ // Deep clone a language definition (e.g. to extend it)
49+ clone: function deepClone(o, visited) {
50+ var clone, id, type = _.util.type(o);
51+ visited = visited || {};
52+
53+ switch (type) {
54+ case 'Object':
55+ id = _.util.objId(o);
56+ if (visited[id]) {
57+ return visited[id];
58+ }
59+ clone = {};
60+ visited[id] = clone;
61+
62+ for (var key in o) {
63+ if (o.hasOwnProperty(key)) {
64+ clone[key] = deepClone(o[key], visited);
65+ }
66+ }
67+
68+ return clone;
69+
70+ case 'Array':
71+ id = _.util.objId(o);
72+ if (visited[id]) {
73+ return visited[id];
74+ }
75+ clone = [];
76+ visited[id] = clone;
77+
78+ o.forEach(function (v, i) {
79+ clone[i] = deepClone(v, visited);
80+ });
81+
82+ return clone;
83+
84+ default:
85+ return o;
86+ }
87+ }
88+ },
89+
90+ languages: {
91+ extend: function (id, redef) {
92+ var lang = _.util.clone(_.languages[id]);
93+
94+ for (var key in redef) {
95+ lang[key] = redef[key];
96+ }
97+
98+ return lang;
99+ },
100+
101+ /**
102+ * Insert a token before another token in a language literal
103+ * As this needs to recreate the object (we cannot actually insert before keys in object literals),
104+ * we cannot just provide an object, we need an object and a key.
105+ * @param inside The key (or language id) of the parent
106+ * @param before The key to insert before.
107+ * @param insert Object with the key/value pairs to insert
108+ * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
109+ */
110+ insertBefore: function (inside, before, insert, root) {
111+ root = root || _.languages;
112+ var grammar = root[inside];
113+ var ret = {};
114+
115+ for (var token in grammar) {
116+ if (grammar.hasOwnProperty(token)) {
117+
118+ if (token == before) {
119+ for (var newToken in insert) {
120+ if (insert.hasOwnProperty(newToken)) {
121+ ret[newToken] = insert[newToken];
122+ }
123+ }
124+ }
125+
126+ // Do not insert token which also occur in insert. See #1525
127+ if (!insert.hasOwnProperty(token)) {
128+ ret[token] = grammar[token];
129+ }
130+ }
131+ }
132+
133+ var old = root[inside];
134+ root[inside] = ret;
135+
136+ // Update references in other language definitions
137+ _.languages.DFS(_.languages, function(key, value) {
138+ if (value === old && key != inside) {
139+ this[key] = ret;
140+ }
141+ });
142+
143+ return ret;
144+ },
145+
146+ // Traverse a language definition with Depth First Search
147+ DFS: function DFS(o, callback, type, visited) {
148+ visited = visited || {};
149+
150+ var objId = _.util.objId;
151+
152+ for (var i in o) {
153+ if (o.hasOwnProperty(i)) {
154+ callback.call(o, i, o[i], type || i);
155+
156+ var property = o[i],
157+ propertyType = _.util.type(property);
158+
159+ if (propertyType === 'Object' && !visited[objId(property)]) {
160+ visited[objId(property)] = true;
161+ DFS(property, callback, null, visited);
162+ }
163+ else if (propertyType === 'Array' && !visited[objId(property)]) {
164+ visited[objId(property)] = true;
165+ DFS(property, callback, i, visited);
166+ }
167+ }
168+ }
169+ }
170+ },
171+ plugins: {},
172+
173+ highlightAll: function(async, callback) {
174+ _.highlightAllUnder(document, async, callback);
175+ },
176+
177+ highlightAllUnder: function(container, async, callback) {
178+ var env = {
179+ callback: callback,
180+ selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
181+ };
182+
183+ _.hooks.run('before-highlightall', env);
184+
185+ var elements = container.querySelectorAll(env.selector);
186+
187+ for (var i=0, element; element = elements[i++];) {
188+ _.highlightElement(element, async === true, env.callback);
189+ }
190+ },
191+
192+ highlightElement: function(element, async, callback) {
193+ // Find language
194+ var language = 'none', grammar, parent = element;
195+
196+ while (parent && !lang.test(parent.className)) {
197+ parent = parent.parentNode;
198+ }
199+
200+ if (parent) {
201+ language = (parent.className.match(lang) || [,'none'])[1].toLowerCase();
202+ grammar = _.languages[language];
203+ }
204+
205+ // Set language on the element, if not present
206+ element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
207+
208+ if (element.parentNode) {
209+ // Set language on the parent, for styling
210+ parent = element.parentNode;
211+
212+ if (/pre/i.test(parent.nodeName)) {
213+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
214+ }
215+ }
216+
217+ var code = element.textContent;
218+
219+ var env = {
220+ element: element,
221+ language: language,
222+ grammar: grammar,
223+ code: code
224+ };
225+
226+ var insertHighlightedCode = function (highlightedCode) {
227+ env.highlightedCode = highlightedCode;
228+
229+ _.hooks.run('before-insert', env);
230+
231+ env.element.innerHTML = env.highlightedCode;
232+
233+ _.hooks.run('after-highlight', env);
234+ _.hooks.run('complete', env);
235+ callback && callback.call(env.element);
236+ }
237+
238+ _.hooks.run('before-sanity-check', env);
239+
240+ if (!env.code) {
241+ _.hooks.run('complete', env);
242+ return;
243+ }
244+
245+ _.hooks.run('before-highlight', env);
246+
247+ if (!env.grammar) {
248+ insertHighlightedCode(_.util.encode(env.code));
249+ return;
250+ }
251+
252+ if (async && _self.Worker) {
253+ var worker = new Worker(_.filename);
254+
255+ worker.onmessage = function(evt) {
256+ insertHighlightedCode(evt.data);
257+ };
258+
259+ worker.postMessage(JSON.stringify({
260+ language: env.language,
261+ code: env.code,
262+ immediateClose: true
263+ }));
264+ }
265+ else {
266+ insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
267+ }
268+ },
269+
270+ highlight: function (text, grammar, language) {
271+ var env = {
272+ code: text,
273+ grammar: grammar,
274+ language: language
275+ };
276+ _.hooks.run('before-tokenize', env);
277+ env.tokens = _.tokenize(env.code, env.grammar);
278+ _.hooks.run('after-tokenize', env);
279+ return Token.stringify(_.util.encode(env.tokens), env.language);
280+ },
281+
282+ matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
283+ for (var token in grammar) {
284+ if(!grammar.hasOwnProperty(token) || !grammar[token]) {
285+ continue;
286+ }
287+
288+ if (token == target) {
289+ return;
290+ }
291+
292+ var patterns = grammar[token];
293+ patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
294+
295+ for (var j = 0; j < patterns.length; ++j) {
296+ var pattern = patterns[j],
297+ inside = pattern.inside,
298+ lookbehind = !!pattern.lookbehind,
299+ greedy = !!pattern.greedy,
300+ lookbehindLength = 0,
301+ alias = pattern.alias;
302+
303+ if (greedy && !pattern.pattern.global) {
304+ // Without the global flag, lastIndex won't work
305+ var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
306+ pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
307+ }
308+
309+ pattern = pattern.pattern || pattern;
310+
311+ // Don’t cache length as it changes during the loop
312+ for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
313+
314+ var str = strarr[i];
315+
316+ if (strarr.length > text.length) {
317+ // Something went terribly wrong, ABORT, ABORT!
318+ return;
319+ }
320+
321+ if (str instanceof Token) {
322+ continue;
323+ }
324+
325+ if (greedy && i != strarr.length - 1) {
326+ pattern.lastIndex = pos;
327+ var match = pattern.exec(text);
328+ if (!match) {
329+ break;
330+ }
331+
332+ var from = match.index + (lookbehind ? match[1].length : 0),
333+ to = match.index + match[0].length,
334+ k = i,
335+ p = pos;
336+
337+ for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
338+ p += strarr[k].length;
339+ // Move the index i to the element in strarr that is closest to from
340+ if (from >= p) {
341+ ++i;
342+ pos = p;
343+ }
344+ }
345+
346+ // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
347+ if (strarr[i] instanceof Token) {
348+ continue;
349+ }
350+
351+ // Number of tokens to delete and replace with the new match
352+ delNum = k - i;
353+ str = text.slice(pos, p);
354+ match.index -= pos;
355+ } else {
356+ pattern.lastIndex = 0;
357+
358+ var match = pattern.exec(str),
359+ delNum = 1;
360+ }
361+
362+ if (!match) {
363+ if (oneshot) {
364+ break;
365+ }
366+
367+ continue;
368+ }
369+
370+ if(lookbehind) {
371+ lookbehindLength = match[1] ? match[1].length : 0;
372+ }
373+
374+ var from = match.index + lookbehindLength,
375+ match = match[0].slice(lookbehindLength),
376+ to = from + match.length,
377+ before = str.slice(0, from),
378+ after = str.slice(to);
379+
380+ var args = [i, delNum];
381+
382+ if (before) {
383+ ++i;
384+ pos += before.length;
385+ args.push(before);
386+ }
387+
388+ var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
389+
390+ args.push(wrapped);
391+
392+ if (after) {
393+ args.push(after);
394+ }
395+
396+ Array.prototype.splice.apply(strarr, args);
397+
398+ if (delNum != 1)
399+ _.matchGrammar(text, strarr, grammar, i, pos, true, token);
400+
401+ if (oneshot)
402+ break;
403+ }
404+ }
405+ }
406+ },
407+
408+ tokenize: function(text, grammar) {
409+ var strarr = [text];
410+
411+ var rest = grammar.rest;
412+
413+ if (rest) {
414+ for (var token in rest) {
415+ grammar[token] = rest[token];
416+ }
417+
418+ delete grammar.rest;
419+ }
420+
421+ _.matchGrammar(text, strarr, grammar, 0, 0, false);
422+
423+ return strarr;
424+ },
425+
426+ hooks: {
427+ all: {},
428+
429+ add: function (name, callback) {
430+ var hooks = _.hooks.all;
431+
432+ hooks[name] = hooks[name] || [];
433+
434+ hooks[name].push(callback);
435+ },
436+
437+ run: function (name, env) {
438+ var callbacks = _.hooks.all[name];
439+
440+ if (!callbacks || !callbacks.length) {
441+ return;
442+ }
381443
382− if (before) {
383− ++i;
384− pos += before.length;
385− args.push(before);
386− }
444+ for (var i=0, callback; callback = callbacks[i++];) {
445+ callback(env);
446+ }
447+ }
448+ },
387449
388− var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
450+ Token: Token
451+ };
389452
390− args.push(wrapped);
453+ _self.Prism = _;
391454
392− if (after) {
393− args.push(after);
394− }
395−
396− Array.prototype.splice.apply(strarr, args);
455+ function Token(type, content, alias, matchedStr, greedy) {
456+ this.type = type;
457+ this.content = content;
458+ this.alias = alias;
459+ // Copy of the full string this token was created from
460+ this.length = (matchedStr || "").length|0;
461+ this.greedy = !!greedy;
462+ }
397463
398− if (delNum != 1)
399− _.matchGrammar(text, strarr, grammar, i, pos, true, token);
464+ Token.stringify = function(o, language) {
465+ if (typeof o == 'string') {
466+ return o;
467+ }
400468
401− if (oneshot)
402− break;
403− }
404− }
405− }
406− },
469+ if (Array.isArray(o)) {
470+ return o.map(function(element) {
471+ return Token.stringify(element, language);
472+ }).join('');
473+ }
407474
408− tokenize: function(text, grammar) {
409− var strarr = [text];
410−
411− var rest = grammar.rest;
412−
413− if (rest) {
414− for (var token in rest) {
415− grammar[token] = rest[token];
416− }
417−
418− delete grammar.rest;
419− }
420−
421− _.matchGrammar(text, strarr, grammar, 0, 0, false);
422−
423− return strarr;
424− },
425−
426− hooks: {
427− all: {},
475+ var env = {
476+ type: o.type,
477+ content: Token.stringify(o.content, language),
478+ tag: 'span',
479+ classes: ['token', o.type],
480+ attributes: {},
481+ language: language
482+ };
428483
429− add: function (name, callback) {
430− var hooks = _.hooks.all;
484+ if (o.alias) {
485+ var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
486+ Array.prototype.push.apply(env.classes, aliases);
487+ }
431488
432− hooks[name] = hooks[name] || [];
489+ _.hooks.run('wrap', env);
433490
434− hooks[name].push(callback);
435− },
491+ var attributes = Object.keys(env.attributes).map(function(name) {
492+ return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
493+ }).join(' ');
436494
437− run: function (name, env) {
438− var callbacks = _.hooks.all[name];
495+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
496+ };
439497
440− if (!callbacks || !callbacks.length) {
441− return;
442− }
498+ if (!_self.document) {
499+ if (!_self.addEventListener) {
500+ // in Node.js
501+ return _;
502+ }
443503
444− for (var i=0, callback; callback = callbacks[i++];) {
445− callback(env);
446− }
447− }
448− },
504+ if (!_.disableWorkerMessageHandler) {
505+ // In worker
506+ _self.addEventListener('message', function (evt) {
507+ var message = JSON.parse(evt.data),
508+ lang = message.language,
509+ code = message.code,
510+ immediateClose = message.immediateClose;
449511
450− Token: Token
451−};
512+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
513+ if (immediateClose) {
514+ _self.close();
515+ }
516+ }, false);
517+ }
452518
453−_self.Prism = _;
454−
455−function Token(type, content, alias, matchedStr, greedy) {
456− this.type = type;
457− this.content = content;
458− this.alias = alias;
459− // Copy of the full string this token was created from
460− this.length = (matchedStr || "").length|0;
461− this.greedy = !!greedy;
462−}
463−
464−Token.stringify = function(o, language) {
465− if (typeof o == 'string') {
466− return o;
467− }
468−
469− if (Array.isArray(o)) {
470− return o.map(function(element) {
471− return Token.stringify(element, language);
472− }).join('');
473− }
474−
475− var env = {
476− type: o.type,
477− content: Token.stringify(o.content, language),
478− tag: 'span',
479− classes: ['token', o.type],
480− attributes: {},
481− language: language
482− };
483−
484− if (o.alias) {
485− var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
486− Array.prototype.push.apply(env.classes, aliases);
487− }
488−
489− _.hooks.run('wrap', env);
490−
491− var attributes = Object.keys(env.attributes).map(function(name) {
492− return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
493− }).join(' ');
494−
495− return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
496−};
497−
498−if (!_self.document) {
499− if (!_self.addEventListener) {
500− // in Node.js
501− return _;
502− }
503−
504− if (!_.disableWorkerMessageHandler) {
505− // In worker
506− _self.addEventListener('message', function (evt) {
507− var message = JSON.parse(evt.data),
508− lang = message.language,
509− code = message.code,
510− immediateClose = message.immediateClose;
511−
512− _self.postMessage(_.highlight(code, _.languages[lang], lang));
513− if (immediateClose) {
514− _self.close();
515− }
516− }, false);
517− }
518−
519− return _;
520−}
519+ return _;
520+ }
521521
522522 //Get current script and highlight
523−var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
524−
525−if (script) {
526− _.filename = script.src;
527−
528− if (!_.manual && !script.hasAttribute('data-manual')) {
529− if(document.readyState !== "loading") {
530− if (window.requestAnimationFrame) {
531− window.requestAnimationFrame(_.highlightAll);
532− } else {
533− window.setTimeout(_.highlightAll, 16);
534− }
535− }
536− else {
537− document.addEventListener('DOMContentLoaded', _.highlightAll);
538− }
539− }
540−}
541−
542−return _;
523+ var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
524+
525+ if (script) {
526+ _.filename = script.src;
527+
528+ if (!_.manual && !script.hasAttribute('data-manual')) {
529+ if(document.readyState !== "loading") {
530+ if (window.requestAnimationFrame) {
531+ window.requestAnimationFrame(_.highlightAll);
532+ } else {
533+ window.setTimeout(_.highlightAll, 16);
534+ }
535+ }
536+ else {
537+ document.addEventListener('DOMContentLoaded', _.highlightAll);
538+ }
539+ }
540+ }
541+
542+ return _;
543543
544544 })(_self);
545545
546546 if (typeof module !== 'undefined' && module.exports) {
547− module.exports = Prism;
547+ module.exports = Prism;
548548 }
549549
550550 // hack for components to work correctly in node.js
551551 if (typeof global !== 'undefined') {
552− global.Prism = Prism;
552+ global.Prism = Prism;
553553 }
554554 ;
555555 Prism.languages.markup = {
556− 'comment': /<!--[\s\S]*?-->/,
557− 'prolog': /<\?[\s\S]+?\?>/,
558− 'doctype': /<!DOCTYPE[\s\S]+?>/i,
559− 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
560− 'tag': {
561− pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
562− greedy: true,
563− inside: {
564− 'tag': {
565− pattern: /^<\/?[^\s>\/]+/i,
566− inside: {
567− 'punctuation': /^<\/?/,
568− 'namespace': /^[^\s>\/:]+:/
569− }
570− },
571− 'attr-value': {
572− pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
573− inside: {
574− 'punctuation': [
575− /^=/,
576− {
577− pattern: /^(\s*)["']|["']$/,
578− lookbehind: true
579− }
580− ]
581− }
582− },
583− 'punctuation': /\/?>/,
584− 'attr-name': {
585− pattern: /[^\s>\/]+/,
586− inside: {
587− 'namespace': /^[^\s>\/:]+:/
588− }
589− }
590−
591− }
592− },
593− 'entity': /&#?[\da-z]{1,8};/i
556+ 'comment': /<!--[\s\S]*?-->/,
557+ 'prolog': /<\?[\s\S]+?\?>/,
558+ 'doctype': /<!DOCTYPE[\s\S]+?>/i,
559+ 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
560+ 'tag': {
561+ pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
562+ greedy: true,
563+ inside: {
564+ 'tag': {
565+ pattern: /^<\/?[^\s>\/]+/i,
566+ inside: {
567+ 'punctuation': /^<\/?/,
568+ 'namespace': /^[^\s>\/:]+:/
569+ }
570+ },
571+ 'attr-value': {
572+ pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
573+ inside: {
574+ 'punctuation': [
575+ /^=/,
576+ {
577+ pattern: /^(\s*)["']|["']$/,
578+ lookbehind: true
579+ }
580+ ]
581+ }
582+ },
583+ 'punctuation': /\/?>/,
584+ 'attr-name': {
585+ pattern: /[^\s>\/]+/,
586+ inside: {
587+ 'namespace': /^[^\s>\/:]+:/
588+ }
589+ }
590+
591+ }
592+ },
593+ 'entity': /&#?[\da-z]{1,8};/i
594594 };
595595
596596 Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
597− Prism.languages.markup['entity'];
597+ Prism.languages.markup['entity'];
598598
599599 // Plugin to make entity title show the real entity, idea by Roman Komarov
600600 Prism.hooks.add('wrap', function(env) {
601601
602− if (env.type === 'entity') {
603− env.attributes['title'] = env.content.replace(/&amp;/, '&');
604− }
602+ if (env.type === 'entity') {
603+ env.attributes['title'] = env.content.replace(/&amp;/, '&');
604+ }
605605 });
606606
607607 Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
608− /**
609− * Adds an inlined language to markup.
610− *
611− * An example of an inlined language is CSS with `<style>` tags.
612− *
613− * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
614− * case insensitive.
615− * @param {string} lang The language key.
616− * @example
617− * addInlined('style', 'css');
618− */
619− value: function addInlined(tagName, lang) {
620− var includedCdataInside = {};
621− includedCdataInside['language-' + lang] = {
622− pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
623− lookbehind: true,
624− inside: Prism.languages[lang]
625− };
626− includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
627−
628− var inside = {
629− 'included-cdata': {
630− pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
631− inside: includedCdataInside
632− }
633− };
634− inside['language-' + lang] = {
635− pattern: /[\s\S]+/,
636− inside: Prism.languages[lang]
637− };
638−
639− var def = {};
640− def[tagName] = {
641− pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
642− lookbehind: true,
643− greedy: true,
644− inside: inside
645− };
646−
647− Prism.languages.insertBefore('markup', 'cdata', def);
648− }
608+ /**
609+ * Adds an inlined language to markup.
610+ *
611+ * An example of an inlined language is CSS with `<style>` tags.
612+ *
613+ * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
614+ * case insensitive.
615+ * @param {string} lang The language key.
616+ * @example
617+ * addInlined('style', 'css');
618+ */
619+ value: function addInlined(tagName, lang) {
620+ var includedCdataInside = {};
621+ includedCdataInside['language-' + lang] = {
622+ pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
623+ lookbehind: true,
624+ inside: Prism.languages[lang]
625+ };
626+ includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
627+
628+ var inside = {
629+ 'included-cdata': {
630+ pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
631+ inside: includedCdataInside
632+ }
633+ };
634+ inside['language-' + lang] = {
635+ pattern: /[\s\S]+/,
636+ inside: Prism.languages[lang]
637+ };
638+
639+ var def = {};
640+ def[tagName] = {
641+ pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
642+ lookbehind: true,
643+ greedy: true,
644+ inside: inside
645+ };
646+
647+ Prism.languages.insertBefore('markup', 'cdata', def);
648+ }
649649 });
650650
651651 Prism.languages.xml = Prism.languages.extend('markup', {});
@@ -655,533 +655,533 @@ Prism.languages.svg = Prism.languages.markup; · 3 unmodified lines
655655
656656 (function (Prism) {
657657
658− var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
659−
660− Prism.languages.css = {
661− 'comment': /\/\*[\s\S]*?\*\//,
662− 'atrule': {
663− pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
664− inside: {
665− 'rule': /@[\w-]+/
666− // See rest below
667− }
668− },
669− 'url': {
670− pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
671− inside: {
672− 'function': /^url/i,
673− 'punctuation': /^\(|\)$/
674− }
675− },
676− 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
677− 'string': {
678− pattern: string,
679− greedy: true
680− },
681− 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
682− 'important': /!important\b/i,
683− 'function': /[-a-z0-9]+(?=\()/i,
684− 'punctuation': /[(){};:,]/
685− };
686−
687− Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
688−
689− var markup = Prism.languages.markup;
690− if (markup) {
691− markup.tag.addInlined('style', 'css');
692−
693− Prism.languages.insertBefore('inside', 'attr-value', {
694− 'style-attr': {
695− pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
696− inside: {
697− 'attr-name': {
698− pattern: /^\s*style/i,
699− inside: markup.tag.inside
700− },
701− 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
702− 'attr-value': {
703− pattern: /.+/i,
704− inside: Prism.languages.css
705− }
706− },
707− alias: 'language-css'
708− }
709− }, markup.tag);
710− }
658+ var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
659+
660+ Prism.languages.css = {
661+ 'comment': /\/\*[\s\S]*?\*\//,
662+ 'atrule': {
663+ pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
664+ inside: {
665+ 'rule': /@[\w-]+/
666+ // See rest below
667+ }
668+ },
669+ 'url': {
670+ pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
671+ inside: {
672+ 'function': /^url/i,
673+ 'punctuation': /^\(|\)$/
674+ }
675+ },
676+ 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
677+ 'string': {
678+ pattern: string,
679+ greedy: true
680+ },
681+ 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
682+ 'important': /!important\b/i,
683+ 'function': /[-a-z0-9]+(?=\()/i,
684+ 'punctuation': /[(){};:,]/
685+ };
686+
687+ Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
688+
689+ var markup = Prism.languages.markup;
690+ if (markup) {
691+ markup.tag.addInlined('style', 'css');
692+
693+ Prism.languages.insertBefore('inside', 'attr-value', {
694+ 'style-attr': {
695+ pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
696+ inside: {
697+ 'attr-name': {
698+ pattern: /^\s*style/i,
699+ inside: markup.tag.inside
700+ },
701+ 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
702+ 'attr-value': {
703+ pattern: /.+/i,
704+ inside: Prism.languages.css
705+ }
706+ },
707+ alias: 'language-css'
708+ }
709+ }, markup.tag);
710+ }
711711
712712 }(Prism));
713713
714714 Prism.languages.clike = {
715− 'comment': [
716− {
717− pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
718− lookbehind: true
719− },
720− {
721− pattern: /(^|[^\\:])\/\/.*/,
722− lookbehind: true,
723− greedy: true
724− }
725− ],
726− 'string': {
727− pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
728− greedy: true
729− },
730− 'class-name': {
731− pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
732− lookbehind: true,
733− inside: {
734− punctuation: /[.\\]/
735− }
736− },
737− 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
738− 'boolean': /\b(?:true|false)\b/,
739− 'function': /\w+(?=\()/,
740− 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
741− 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
742− 'punctuation': /[{}[\];(),.:]/
715+ 'comment': [
716+ {
717+ pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
718+ lookbehind: true
719+ },
720+ {
721+ pattern: /(^|[^\\:])\/\/.*/,
722+ lookbehind: true,
723+ greedy: true
724+ }
725+ ],
726+ 'string': {
727+ pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
728+ greedy: true
729+ },
730+ 'class-name': {
731+ pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
732+ lookbehind: true,
733+ inside: {
734+ punctuation: /[.\\]/
735+ }
736+ },
737+ 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
738+ 'boolean': /\b(?:true|false)\b/,
739+ 'function': /\w+(?=\()/,
740+ 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
741+ 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
742+ 'punctuation': /[{}[\];(),.:]/
743743 };
744744
745745 Prism.languages.javascript = Prism.languages.extend('clike', {
746− 'class-name': [
747− Prism.languages.clike['class-name'],
748− {
749− pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
750− lookbehind: true
751− }
752− ],
753− 'keyword': [
754− {
755− pattern: /((?:^|})\s*)(?:catch|finally)\b/,
756− lookbehind: true
757− },
758− {
759− pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
760− lookbehind: true
761− },
762− ],
763− 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
764− // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
765− 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
766− 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
746+ 'class-name': [
747+ Prism.languages.clike['class-name'],
748+ {
749+ pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
750+ lookbehind: true
751+ }
752+ ],
753+ 'keyword': [
754+ {
755+ pattern: /((?:^|})\s*)(?:catch|finally)\b/,
756+ lookbehind: true
757+ },
758+ {
759+ pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
760+ lookbehind: true
761+ },
762+ ],
763+ 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
764+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
765+ 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
766+ 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
767767 });
768768
769769 Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
770770
771771 Prism.languages.insertBefore('javascript', 'keyword', {
772− 'regex': {
773− pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
774− lookbehind: true,
775− greedy: true
776− },
777− // This must be declared before keyword because we use "function" inside the look-forward
778− 'function-variable': {
779− pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
780− alias: 'function'
781− },
782− 'parameter': [
783− {
784− pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
785− lookbehind: true,
786− inside: Prism.languages.javascript
787− },
788− {
789− pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
790− inside: Prism.languages.javascript
791− },
792− {
793− pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
794− lookbehind: true,
795− inside: Prism.languages.javascript
796− },
797− {
798− pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
799− lookbehind: true,
800− inside: Prism.languages.javascript
801− }
802− ],
803− 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
772+ 'regex': {
773+ pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
774+ lookbehind: true,
775+ greedy: true
776+ },
777+ // This must be declared before keyword because we use "function" inside the look-forward
778+ 'function-variable': {
779+ pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
780+ alias: 'function'
781+ },
782+ 'parameter': [
783+ {
784+ pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
785+ lookbehind: true,
786+ inside: Prism.languages.javascript
787+ },
788+ {
789+ pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
790+ inside: Prism.languages.javascript
791+ },
792+ {
793+ pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
794+ lookbehind: true,
795+ inside: Prism.languages.javascript
796+ },
797+ {
798+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
799+ lookbehind: true,
800+ inside: Prism.languages.javascript
801+ }
802+ ],
803+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
804804 });
805805
806806 Prism.languages.insertBefore('javascript', 'string', {
807− 'template-string': {
808− pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
809− greedy: true,
810− inside: {
811− 'template-punctuation': {
812− pattern: /^`|`$/,
813− alias: 'string'
814− },
815− 'interpolation': {
816− pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
817− lookbehind: true,
818− inside: {
819− 'interpolation-punctuation': {
820− pattern: /^\${|}$/,
821− alias: 'punctuation'
822− },
823− rest: Prism.languages.javascript
824− }
825− },
826− 'string': /[\s\S]+/
827− }
828− }
807+ 'template-string': {
808+ pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
809+ greedy: true,
810+ inside: {
811+ 'template-punctuation': {
812+ pattern: /^`|`$/,
813+ alias: 'string'
814+ },
815+ 'interpolation': {
816+ pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
817+ lookbehind: true,
818+ inside: {
819+ 'interpolation-punctuation': {
820+ pattern: /^\${|}$/,
821+ alias: 'punctuation'
822+ },
823+ rest: Prism.languages.javascript
824+ }
825+ },
826+ 'string': /[\s\S]+/
827+ }
828+ }
829829 });
830830
831831 if (Prism.languages.markup) {
832− Prism.languages.markup.tag.addInlined('script', 'javascript');
832+ Prism.languages.markup.tag.addInlined('script', 'javascript');
833833 }
834834
835835 Prism.languages.js = Prism.languages.javascript;
836836
837837 Prism.languages.c = Prism.languages.extend('clike', {
838− 'class-name': {
839− pattern: /(\b(?:enum|struct)\s+)\w+/,
840− lookbehind: true
841− },
842− 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
843− 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
844− 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
838+ 'class-name': {
839+ pattern: /(\b(?:enum|struct)\s+)\w+/,
840+ lookbehind: true
841+ },
842+ 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
843+ 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
844+ 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
845845 });
846846
847847 Prism.languages.insertBefore('c', 'string', {
848− 'macro': {
849− // allow for multiline macro definitions
850− // spaces after the # character compile fine with gcc
851− pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
852− lookbehind: true,
853− alias: 'property',
854− inside: {
855− // highlight the path of the include statement as a string
856− 'string': {
857− pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
858− lookbehind: true
859− },
860− // highlight macro directives as keywords
861− 'directive': {
862− pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
863− lookbehind: true,
864− alias: 'keyword'
865− }
866− }
867− },
868− // highlight predefined macros as constants
869− 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
848+ 'macro': {
849+ // allow for multiline macro definitions
850+ // spaces after the # character compile fine with gcc
851+ pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
852+ lookbehind: true,
853+ alias: 'property',
854+ inside: {
855+ // highlight the path of the include statement as a string
856+ 'string': {
857+ pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
858+ lookbehind: true
859+ },
860+ // highlight macro directives as keywords
861+ 'directive': {
862+ pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
863+ lookbehind: true,
864+ alias: 'keyword'
865+ }
866+ }
867+ },
868+ // highlight predefined macros as constants
869+ 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
870870 });
871871
872872 delete Prism.languages.c['boolean'];
873873
874874 (function(Prism) {
875− // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
876− // + LC_ALL, RANDOM, REPLY, SECONDS.
877− // + make sure PS1..4 are here as they are not always set,
878− // - some useless things.
879− var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
880− var insideString = {
881− 'environment': {
882− pattern: RegExp("\\$" + envVars),
883− alias: 'constant'
884− },
885− 'variable': [
886− // [0]: Arithmetic Environment
887− {
888− pattern: /\$?\(\([\s\S]+?\)\)/,
889− greedy: true,
890− inside: {
891− // If there is a $ sign at the beginning highlight $(( and )) as variable
892− 'variable': [
893− {
894− pattern: /(^\$\(\([\s\S]+)\)\)/,
895− lookbehind: true
896− },
897− /^\$\(\(/
898− ],
899− 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
900− // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
901− 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
902− // If there is no $ sign at the beginning highlight (( and )) as punctuation
903− 'punctuation': /\(\(?|\)\)?|,|;/
904− }
905− },
906− // [1]: Command Substitution
907− {
908− pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
909− greedy: true,
910− inside: {
911− 'variable': /^\$\(|^`|\)$|`$/
912− }
913− },
914− // [2]: Brace expansion
915− {
916− pattern: /\$\{[^}]+\}/,
917− greedy: true,
918− inside: {
919− 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
920− 'punctuation': /[\[\]]/,
921− 'environment': {
922− pattern: RegExp("(\\{)" + envVars),
923− lookbehind: true,
924− alias: 'constant'
925− }
926− }
927− },
928− /\$(?:\w+|[#?*!@$])/
929− ],
930− // Escape sequences from echo and printf's manuals, and escaped quotes.
931− 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
932− };
933−
934− Prism.languages.bash = {
935− 'shebang': {
936− pattern: /^#!\s*\/.*/,
937− alias: 'important'
938− },
939− 'comment': {
940− pattern: /(^|[^"{\\$])#.*/,
941− lookbehind: true
942− },
943− 'function-name': [
944− // a) function foo {
945− // b) foo() {
946− // c) function foo() {
947− // but not “foo {”
948− {
949− // a) and c)
950− pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
951− lookbehind: true,
952− alias: 'function'
953− },
954− {
955− // b)
956− pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
957− alias: 'function'
958− }
959− ],
960− // Highlight variable names as variables in for and select beginnings.
961− 'for-or-select': {
962− pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
963− alias: 'variable',
964− lookbehind: true
965− },
966− // Highlight variable names as variables in the left-hand part
967− // of assignments (“=” and “+=”).
968− 'assign-left': {
969− pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
970− inside: {
971− 'environment': {
972− pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
973− lookbehind: true,
974− alias: 'constant'
975− }
976− },
977− alias: 'variable',
978− lookbehind: true
979− },
980− 'string': [
981− // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
982− {
983− pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,
984− lookbehind: true,
985− greedy: true,
986− inside: insideString
987− },
988− // Here-document with quotes around the tag
989− // → No expansion (so no “inside”).
990− {
991− pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,
992− lookbehind: true,
993− greedy: true
994− },
995− // “Normal” string
996− {
997− pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
998− greedy: true,
999− inside: insideString
1000− }
1001− ],
1002− 'environment': {
1003− pattern: RegExp("\\$?" + envVars),
1004− alias: 'constant'
1005− },
1006− 'variable': insideString.variable,
1007− 'function': {
1008− pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1009− lookbehind: true
1010− },
1011− 'keyword': {
1012− pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
1013− lookbehind: true
1014− },
1015− // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1016− 'builtin': {
1017− pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
1018− lookbehind: true,
1019− // Alias added to make those easier to distinguish from strings.
1020− alias: 'class-name'
1021− },
1022− 'boolean': {
1023− pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
1024− lookbehind: true
1025− },
1026− 'file-descriptor': {
1027− pattern: /\B&\d\b/,
1028− alias: 'important'
1029− },
1030− 'operator': {
1031− // Lots of redirections here, but not just that.
1032− pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
1033− inside: {
1034− 'file-descriptor': {
1035− pattern: /^\d/,
1036− alias: 'important'
1037− }
1038− }
1039− },
1040− 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1041− 'number': {
1042− pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1043− lookbehind: true
1044− }
1045− };
1046−
1047− /* Patterns in command substitution. */
1048− var toBeCopied = [
1049− 'comment',
1050− 'function-name',
1051− 'for-or-select',
1052− 'assign-left',
1053− 'string',
1054− 'environment',
1055− 'function',
1056− 'keyword',
1057− 'builtin',
1058− 'boolean',
1059− 'file-descriptor',
1060− 'operator',
1061− 'punctuation',
1062− 'number'
1063− ];
1064− var inside = insideString.variable[1].inside;
1065− for(var i = 0; i < toBeCopied.length; i++) {
1066− inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
1067− }
1068−
1069− Prism.languages.shell = Prism.languages.bash;
875+ // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
876+ // + LC_ALL, RANDOM, REPLY, SECONDS.
877+ // + make sure PS1..4 are here as they are not always set,
878+ // - some useless things.
879+ var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
880+ var insideString = {
881+ 'environment': {
882+ pattern: RegExp("\\$" + envVars),
883+ alias: 'constant'
884+ },
885+ 'variable': [
886+ // [0]: Arithmetic Environment
887+ {
888+ pattern: /\$?\(\([\s\S]+?\)\)/,
889+ greedy: true,
890+ inside: {
891+ // If there is a $ sign at the beginning highlight $(( and )) as variable
892+ 'variable': [
893+ {
894+ pattern: /(^\$\(\([\s\S]+)\)\)/,
895+ lookbehind: true
896+ },
897+ /^\$\(\(/
898+ ],
899+ 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
900+ // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
901+ 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
902+ // If there is no $ sign at the beginning highlight (( and )) as punctuation
903+ 'punctuation': /\(\(?|\)\)?|,|;/
904+ }
905+ },
906+ // [1]: Command Substitution
907+ {
908+ pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
909+ greedy: true,
910+ inside: {
911+ 'variable': /^\$\(|^`|\)$|`$/
912+ }
913+ },
914+ // [2]: Brace expansion
915+ {
916+ pattern: /\$\{[^}]+\}/,
917+ greedy: true,
918+ inside: {
919+ 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
920+ 'punctuation': /[\[\]]/,
921+ 'environment': {
922+ pattern: RegExp("(\\{)" + envVars),
923+ lookbehind: true,
924+ alias: 'constant'
925+ }
926+ }
927+ },
928+ /\$(?:\w+|[#?*!@$])/
929+ ],
930+ // Escape sequences from echo and printf's manuals, and escaped quotes.
931+ 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
932+ };
933+
934+ Prism.languages.bash = {
935+ 'shebang': {
936+ pattern: /^#!\s*\/.*/,
937+ alias: 'important'
938+ },
939+ 'comment': {
940+ pattern: /(^|[^"{\\$])#.*/,
941+ lookbehind: true
942+ },
943+ 'function-name': [
944+ // a) function foo {
945+ // b) foo() {
946+ // c) function foo() {
947+ // but not “foo {”
948+ {
949+ // a) and c)
950+ pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
951+ lookbehind: true,
952+ alias: 'function'
953+ },
954+ {
955+ // b)
956+ pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
957+ alias: 'function'
958+ }
959+ ],
960+ // Highlight variable names as variables in for and select beginnings.
961+ 'for-or-select': {
962+ pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
963+ alias: 'variable',
964+ lookbehind: true
965+ },
966+ // Highlight variable names as variables in the left-hand part
967+ // of assignments (“=” and “+=”).
968+ 'assign-left': {
969+ pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
970+ inside: {
971+ 'environment': {
972+ pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
973+ lookbehind: true,
974+ alias: 'constant'
975+ }
976+ },
977+ alias: 'variable',
978+ lookbehind: true
979+ },
980+ 'string': [
981+ // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
982+ {
983+ pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,
984+ lookbehind: true,
985+ greedy: true,
986+ inside: insideString
987+ },
988+ // Here-document with quotes around the tag
989+ // → No expansion (so no “inside”).
990+ {
991+ pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,
992+ lookbehind: true,
993+ greedy: true
994+ },
995+ // “Normal” string
996+ {
997+ pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
998+ greedy: true,
999+ inside: insideString
1000+ }
1001+ ],
1002+ 'environment': {
1003+ pattern: RegExp("\\$?" + envVars),
1004+ alias: 'constant'
1005+ },
1006+ 'variable': insideString.variable,
1007+ 'function': {
1008+ pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1009+ lookbehind: true
1010+ },
1011+ 'keyword': {
1012+ pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
1013+ lookbehind: true
1014+ },
1015+ // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
1016+ 'builtin': {
1017+ pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
1018+ lookbehind: true,
1019+ // Alias added to make those easier to distinguish from strings.
1020+ alias: 'class-name'
1021+ },
1022+ 'boolean': {
1023+ pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
1024+ lookbehind: true
1025+ },
1026+ 'file-descriptor': {
1027+ pattern: /\B&\d\b/,
1028+ alias: 'important'
1029+ },
1030+ 'operator': {
1031+ // Lots of redirections here, but not just that.
1032+ pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
1033+ inside: {
1034+ 'file-descriptor': {
1035+ pattern: /^\d/,
1036+ alias: 'important'
1037+ }
1038+ }
1039+ },
1040+ 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
1041+ 'number': {
1042+ pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
1043+ lookbehind: true
1044+ }
1045+ };
1046+
1047+ /* Patterns in command substitution. */
1048+ var toBeCopied = [
1049+ 'comment',
1050+ 'function-name',
1051+ 'for-or-select',
1052+ 'assign-left',
1053+ 'string',
1054+ 'environment',
1055+ 'function',
1056+ 'keyword',
1057+ 'builtin',
1058+ 'boolean',
1059+ 'file-descriptor',
1060+ 'operator',
1061+ 'punctuation',
1062+ 'number'
1063+ ];
1064+ var inside = insideString.variable[1].inside;
1065+ for(var i = 0; i < toBeCopied.length; i++) {
1066+ inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
1067+ }
1068+
1069+ Prism.languages.shell = Prism.languages.bash;
10701070 })(Prism);
10711071
10721072 Prism.languages.cpp = Prism.languages.extend('c', {
1073− 'class-name': {
1074− pattern: /(\b(?:class|enum|struct)\s+)\w+/,
1075− lookbehind: true
1076− },
1077− 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
1078− 'number': {
1079− pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
1080− greedy: true
1081− },
1082− 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
1083− 'boolean': /\b(?:true|false)\b/
1073+ 'class-name': {
1074+ pattern: /(\b(?:class|enum|struct)\s+)\w+/,
1075+ lookbehind: true
1076+ },
1077+ 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
1078+ 'number': {
1079+ pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
1080+ greedy: true
1081+ },
1082+ 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
1083+ 'boolean': /\b(?:true|false)\b/
10841084 });
10851085
10861086 Prism.languages.insertBefore('cpp', 'string', {
1087− 'raw-string': {
1088− pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
1089− alias: 'string',
1090− greedy: true
1091− }
1087+ 'raw-string': {
1088+ pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
1089+ alias: 'string',
1090+ greedy: true
1091+ }
10921092 });
10931093
10941094 (function(Prism) {
10951095
10961096 // Ignore comments starting with { to privilege string interpolation highlighting
1097−var comment = /#(?!\{).+/,
1097+ var comment = /#(?!\{).+/,
10981098 interpolation = {
1099− pattern: /#\{[^}]+\}/,
1100− alias: 'variable'
1099+ pattern: /#\{[^}]+\}/,
1100+ alias: 'variable'
11011101 };
11021102
1103−Prism.languages.coffeescript = Prism.languages.extend('javascript', {
1104− 'comment': comment,
1105− 'string': [
1106−
1107− // Strings are multiline
1108− {
1109− pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1110− greedy: true
1111− },
1112−
1113− {
1114− // Strings are multiline
1115− pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1116− greedy: true,
1117− inside: {
1118− 'interpolation': interpolation
1119− }
1120− }
1121− ],
1122− 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
1123− 'class-member': {
1124− pattern: /@(?!\d)\w+/,
1125− alias: 'variable'
1126− }
1127−});
1128−
1129−Prism.languages.insertBefore('coffeescript', 'comment', {
1130− 'multiline-comment': {
1131− pattern: /###[\s\S]+?###/,
1132− alias: 'comment'
1133− },
1134−
1135− // Block regexp can contain comments and interpolation
1136− 'block-regex': {
1137− pattern: /\/{3}[\s\S]*?\/{3}/,
1138− alias: 'regex',
1139− inside: {
1140− 'comment': comment,
1141− 'interpolation': interpolation
1142− }
1143− }
1144−});
1145−
1146−Prism.languages.insertBefore('coffeescript', 'string', {
1147− 'inline-javascript': {
1148− pattern: /`(?:\\[\s\S]|[^\\`])*`/,
1149− inside: {
1150− 'delimiter': {
1151− pattern: /^`|`$/,
1152− alias: 'punctuation'
1153− },
1154− rest: Prism.languages.javascript
1155− }
1156− },
1157−
1158− // Block strings
1159− 'multiline-string': [
1160− {
1161− pattern: /'''[\s\S]*?'''/,
1162− greedy: true,
1163− alias: 'string'
1164− },
1165− {
1166− pattern: /"""[\s\S]*?"""/,
1167− greedy: true,
1168− alias: 'string',
1169− inside: {
1170− interpolation: interpolation
1171− }
1172− }
1173− ]
1174−
1175−});
1176−
1177−Prism.languages.insertBefore('coffeescript', 'keyword', {
1178− // Object property
1179− 'property': /(?!\d)\w+(?=\s*:(?!:))/
1180−});
1181−
1182−delete Prism.languages.coffeescript['template-string'];
1183−
1184−Prism.languages.coffee = Prism.languages.coffeescript;
1103+ Prism.languages.coffeescript = Prism.languages.extend('javascript', {
1104+ 'comment': comment,
1105+ 'string': [
1106+
1107+ // Strings are multiline
1108+ {
1109+ pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1110+ greedy: true
1111+ },
1112+
1113+ {
1114+ // Strings are multiline
1115+ pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1116+ greedy: true,
1117+ inside: {
1118+ 'interpolation': interpolation
1119+ }
1120+ }
1121+ ],
1122+ 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
1123+ 'class-member': {
1124+ pattern: /@(?!\d)\w+/,
1125+ alias: 'variable'
1126+ }
1127+ });
1128+
1129+ Prism.languages.insertBefore('coffeescript', 'comment', {
1130+ 'multiline-comment': {
1131+ pattern: /###[\s\S]+?###/,
1132+ alias: 'comment'
1133+ },
1134+
1135+ // Block regexp can contain comments and interpolation
1136+ 'block-regex': {
1137+ pattern: /\/{3}[\s\S]*?\/{3}/,
1138+ alias: 'regex',
1139+ inside: {
1140+ 'comment': comment,
1141+ 'interpolation': interpolation
1142+ }
1143+ }
1144+ });
1145+
1146+ Prism.languages.insertBefore('coffeescript', 'string', {
1147+ 'inline-javascript': {
1148+ pattern: /`(?:\\[\s\S]|[^\\`])*`/,
1149+ inside: {
1150+ 'delimiter': {
1151+ pattern: /^`|`$/,
1152+ alias: 'punctuation'
1153+ },
1154+ rest: Prism.languages.javascript
1155+ }
1156+ },
1157+
1158+ // Block strings
1159+ 'multiline-string': [
1160+ {
1161+ pattern: /'''[\s\S]*?'''/,
1162+ greedy: true,
1163+ alias: 'string'
1164+ },
1165+ {
1166+ pattern: /"""[\s\S]*?"""/,
1167+ greedy: true,
1168+ alias: 'string',
1169+ inside: {
1170+ interpolation: interpolation
1171+ }
1172+ }
1173+ ]
1174+
1175+ });
1176+
1177+ Prism.languages.insertBefore('coffeescript', 'keyword', {
1178+ // Object property
1179+ 'property': /(?!\d)\w+(?=\s*:(?!:))/
1180+ });
1181+
1182+ delete Prism.languages.coffeescript['template-string'];
1183+
1184+ Prism.languages.coffee = Prism.languages.coffeescript;
11851185 }(Prism));
11861186 /**
11871187 * Original by Samuel Flores
@@ -1190,621 +1190,621 @@ Prism.languages.coffee = Prism.languages.coffeescript; · 2 unmodified lines
11901190 * constant, builtin, variable, symbol, regex
11911191 */
11921192 (function(Prism) {
1193− Prism.languages.ruby = Prism.languages.extend('clike', {
1194− 'comment': [
1195− /#.*/,
1196− {
1197− pattern: /^=begin\s[\s\S]*?^=end/m,
1198− greedy: true
1199− }
1200− ],
1201− 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
1202− });
1203−
1204− var interpolation = {
1205− pattern: /#\{[^}]+\}/,
1206− inside: {
1207− 'delimiter': {
1208− pattern: /^#\{|\}$/,
1209− alias: 'tag'
1210− },
1211− rest: Prism.languages.ruby
1212− }
1213− };
1214−
1215− delete Prism.languages.ruby.function;
1216−
1217− Prism.languages.insertBefore('ruby', 'keyword', {
1218− 'regex': [
1219− {
1220− pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/,
1221− greedy: true,
1222− inside: {
1223− 'interpolation': interpolation
1224− }
1225− },
1226− {
1227− pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
1228− greedy: true,
1229− inside: {
1230− 'interpolation': interpolation
1231− }
1232− },
1233− {
1234− // Here we need to specifically allow interpolation
1235− pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
1236− greedy: true,
1237− inside: {
1238− 'interpolation': interpolation
1239− }
1240− },
1241− {
1242− pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
1243− greedy: true,
1244− inside: {
1245− 'interpolation': interpolation
1246− }
1247− },
1248− {
1249− pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
1250− greedy: true,
1251− inside: {
1252− 'interpolation': interpolation
1253− }
1254− },
1255− {
1256− pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
1257− lookbehind: true,
1258− greedy: true
1259− }
1260− ],
1261− 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
1262− 'symbol': {
1263− pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
1264− lookbehind: true
1265− },
1266− 'method-definition': {
1267− pattern: /(\bdef\s+)[\w.]+/,
1268− lookbehind: true,
1269− inside: {
1270− 'function': /\w+$/,
1271− rest: Prism.languages.ruby
1272− }
1273− }
1274− });
1275−
1276− Prism.languages.insertBefore('ruby', 'number', {
1277− 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
1278− 'constant': /\b[A-Z]\w*(?:[?!]|\b)/
1279− });
1280−
1281− Prism.languages.ruby.string = [
1282− {
1283− pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1284− greedy: true,
1285− inside: {
1286− 'interpolation': interpolation
1287− }
1288− },
1289− {
1290− pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
1291− greedy: true,
1292− inside: {
1293− 'interpolation': interpolation
1294− }
1295− },
1296− {
1297− // Here we need to specifically allow interpolation
1298− pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
1299− greedy: true,
1300− inside: {
1301− 'interpolation': interpolation
1302− }
1303− },
1304− {
1305− pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
1306− greedy: true,
1307− inside: {
1308− 'interpolation': interpolation
1309− }
1310− },
1311− {
1312− pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
1313− greedy: true,
1314− inside: {
1315− 'interpolation': interpolation
1316− }
1317− },
1318− {
1319− pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1320− greedy: true,
1321− inside: {
1322− 'interpolation': interpolation
1323− }
1324− }
1325− ];
1326−
1327− Prism.languages.rb = Prism.languages.ruby;
1193+ Prism.languages.ruby = Prism.languages.extend('clike', {
1194+ 'comment': [
1195+ /#.*/,
1196+ {
1197+ pattern: /^=begin\s[\s\S]*?^=end/m,
1198+ greedy: true
1199+ }
1200+ ],
1201+ 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
1202+ });
1203+
1204+ var interpolation = {
1205+ pattern: /#\{[^}]+\}/,
1206+ inside: {
1207+ 'delimiter': {
1208+ pattern: /^#\{|\}$/,
1209+ alias: 'tag'
1210+ },
1211+ rest: Prism.languages.ruby
1212+ }
1213+ };
1214+
1215+ delete Prism.languages.ruby.function;
1216+
1217+ Prism.languages.insertBefore('ruby', 'keyword', {
1218+ 'regex': [
1219+ {
1220+ pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/,
1221+ greedy: true,
1222+ inside: {
1223+ 'interpolation': interpolation
1224+ }
1225+ },
1226+ {
1227+ pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
1228+ greedy: true,
1229+ inside: {
1230+ 'interpolation': interpolation
1231+ }
1232+ },
1233+ {
1234+ // Here we need to specifically allow interpolation
1235+ pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
1236+ greedy: true,
1237+ inside: {
1238+ 'interpolation': interpolation
1239+ }
1240+ },
1241+ {
1242+ pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
1243+ greedy: true,
1244+ inside: {
1245+ 'interpolation': interpolation
1246+ }
1247+ },
1248+ {
1249+ pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
1250+ greedy: true,
1251+ inside: {
1252+ 'interpolation': interpolation
1253+ }
1254+ },
1255+ {
1256+ pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
1257+ lookbehind: true,
1258+ greedy: true
1259+ }
1260+ ],
1261+ 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
1262+ 'symbol': {
1263+ pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
1264+ lookbehind: true
1265+ },
1266+ 'method-definition': {
1267+ pattern: /(\bdef\s+)[\w.]+/,
1268+ lookbehind: true,
1269+ inside: {
1270+ 'function': /\w+$/,
1271+ rest: Prism.languages.ruby
1272+ }
1273+ }
1274+ });
1275+
1276+ Prism.languages.insertBefore('ruby', 'number', {
1277+ 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
1278+ 'constant': /\b[A-Z]\w*(?:[?!]|\b)/
1279+ });
1280+
1281+ Prism.languages.ruby.string = [
1282+ {
1283+ pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1284+ greedy: true,
1285+ inside: {
1286+ 'interpolation': interpolation
1287+ }
1288+ },
1289+ {
1290+ pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
1291+ greedy: true,
1292+ inside: {
1293+ 'interpolation': interpolation
1294+ }
1295+ },
1296+ {
1297+ // Here we need to specifically allow interpolation
1298+ pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
1299+ greedy: true,
1300+ inside: {
1301+ 'interpolation': interpolation
1302+ }
1303+ },
1304+ {
1305+ pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
1306+ greedy: true,
1307+ inside: {
1308+ 'interpolation': interpolation
1309+ }
1310+ },
1311+ {
1312+ pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
1313+ greedy: true,
1314+ inside: {
1315+ 'interpolation': interpolation
1316+ }
1317+ },
1318+ {
1319+ pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1320+ greedy: true,
1321+ inside: {
1322+ 'interpolation': interpolation
1323+ }
1324+ }
1325+ ];
1326+
1327+ Prism.languages.rb = Prism.languages.ruby;
13281328 }(Prism));
13291329
13301330 Prism.languages.d = Prism.languages.extend('clike', {
1331− 'string': [
1332− // r"", x""
1333− /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/,
1334− // q"[]", q"()", q"<>", q"{}"
1335− /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/,
1336− // q"IDENT
1337− // ...
1338− // IDENT"
1339− /\bq"([_a-zA-Z][_a-zA-Z\d]*)(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\1"/,
1340− // q"//", q"||", etc.
1341− /\bq"(.)[\s\S]*?\1"/,
1342− // Characters
1343− /'(?:\\'|\\?[^']+)'/,
1344−
1345− /(["`])(?:\\[\s\S]|(?!\1)[^\\])*\1[cwd]?/
1346− ],
1347−
1348− 'number': [
1349− // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
1350− // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
1351− /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i,
1352− {
1353− pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i,
1354− lookbehind: true
1355− }
1356− ],
1357−
1358− // In order: $, keywords and special tokens, globally defined symbols
1359− 'keyword': /\$|\b(?:abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|false|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|inout|int|interface|invariant|ireal|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|static|struct|super|switch|synchronized|template|this|throw|true|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__(?:(?:FILE|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__|gshared|traits|vector|parameters)|string|wstring|dstring|size_t|ptrdiff_t)\b/,
1360− 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
1331+ 'string': [
1332+ // r"", x""
1333+ /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/,
1334+ // q"[]", q"()", q"<>", q"{}"
1335+ /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/,
1336+ // q"IDENT
1337+ // ...
1338+ // IDENT"
1339+ /\bq"([_a-zA-Z][_a-zA-Z\d]*)(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\1"/,
1340+ // q"//", q"||", etc.
1341+ /\bq"(.)[\s\S]*?\1"/,
1342+ // Characters
1343+ /'(?:\\'|\\?[^']+)'/,
1344+
1345+ /(["`])(?:\\[\s\S]|(?!\1)[^\\])*\1[cwd]?/
1346+ ],
1347+
1348+ 'number': [
1349+ // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
1350+ // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
1351+ /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i,
1352+ {
1353+ pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i,
1354+ lookbehind: true
1355+ }
1356+ ],
1357+
1358+ // In order: $, keywords and special tokens, globally defined symbols
1359+ 'keyword': /\$|\b(?:abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|false|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|inout|int|interface|invariant|ireal|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|static|struct|super|switch|synchronized|template|this|throw|true|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__(?:(?:FILE|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__|gshared|traits|vector|parameters)|string|wstring|dstring|size_t|ptrdiff_t)\b/,
1360+ 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
13611361 });
13621362
13631363
13641364 Prism.languages.d.comment = [
1365− // Shebang
1366− /^\s*#!.+/,
1367− // /+ +/
1368− {
1369− // Allow one level of nesting
1370− pattern: /(^|[^\\])\/\+(?:\/\+[\s\S]*?\+\/|[\s\S])*?\+\//,
1371− lookbehind: true
1372− }
1365+ // Shebang
1366+ /^\s*#!.+/,
1367+ // /+ +/
1368+ {
1369+ // Allow one level of nesting
1370+ pattern: /(^|[^\\])\/\+(?:\/\+[\s\S]*?\+\/|[\s\S])*?\+\//,
1371+ lookbehind: true
1372+ }
13731373 ].concat(Prism.languages.d.comment);
13741374
13751375 Prism.languages.insertBefore('d', 'comment', {
1376− 'token-string': {
1377− // Allow one level of nesting
1378− pattern: /\bq\{(?:\{[^}]*\}|[^}])*\}/,
1379− alias: 'string'
1380− }
1376+ 'token-string': {
1377+ // Allow one level of nesting
1378+ pattern: /\bq\{(?:\{[^}]*\}|[^}])*\}/,
1379+ alias: 'string'
1380+ }
13811381 });
13821382
13831383 Prism.languages.insertBefore('d', 'keyword', {
1384− 'property': /\B@\w*/
1384+ 'property': /\B@\w*/
13851385 });
13861386
13871387 Prism.languages.insertBefore('d', 'function', {
1388− 'register': {
1389− // Iasm registers
1390− pattern: /\b(?:[ABCD][LHX]|E[ABCD]X|E?(?:BP|SP|DI|SI)|[ECSDGF]S|CR[0234]|DR[012367]|TR[3-7]|X?MM[0-7]|R[ABCD]X|[BS]PL|R[BS]P|[DS]IL|R[DS]I|R(?:[89]|1[0-5])[BWD]?|XMM(?:[89]|1[0-5])|YMM(?:1[0-5]|\d))\b|\bST(?:\([0-7]\)|\b)/,
1391− alias: 'variable'
1392− }
1388+ 'register': {
1389+ // Iasm registers
1390+ pattern: /\b(?:[ABCD][LHX]|E[ABCD]X|E?(?:BP|SP|DI|SI)|[ECSDGF]S|CR[0234]|DR[012367]|TR[3-7]|X?MM[0-7]|R[ABCD]X|[BS]PL|R[BS]P|[DS]IL|R[DS]I|R(?:[89]|1[0-5])[BWD]?|XMM(?:[89]|1[0-5])|YMM(?:1[0-5]|\d))\b|\bST(?:\([0-7]\)|\b)/,
1391+ alias: 'variable'
1392+ }
13931393 });
13941394 Prism.languages.dart = Prism.languages.extend('clike', {
1395− 'string': [
1396− {
1397− pattern: /r?("""|''')[\s\S]*?\1/,
1398− greedy: true
1399− },
1400− {
1401− pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
1402− greedy: true
1403− }
1404− ],
1405− 'keyword': [
1406− /\b(?:async|sync|yield)\*/,
1407− /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
1408− ],
1409− 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
1395+ 'string': [
1396+ {
1397+ pattern: /r?("""|''')[\s\S]*?\1/,
1398+ greedy: true
1399+ },
1400+ {
1401+ pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
1402+ greedy: true
1403+ }
1404+ ],
1405+ 'keyword': [
1406+ /\b(?:async|sync|yield)\*/,
1407+ /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
1408+ ],
1409+ 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
14101410 });
14111411
14121412 Prism.languages.insertBefore('dart','function',{
1413− 'metadata': {
1414− pattern: /@\w+/,
1415− alias: 'symbol'
1416− }
1413+ 'metadata': {
1414+ pattern: /@\w+/,
1415+ alias: 'symbol'
1416+ }
14171417 });
14181418 (function (Prism) {
14191419
1420− /**
1421− * Returns the placeholder for the given language id and index.
1422− *
1423− * @param {string} language
1424− * @param {string|number} index
1425− * @returns {string}
1426− */
1427− function getPlaceholder(language, index) {
1428− return '___' + language.toUpperCase() + index + '___';
1429− }
1430−
1431− Object.defineProperties(Prism.languages['markup-templating'] = {}, {
1432− buildPlaceholders: {
1433− /**
1434− * Tokenize all inline templating expressions matching `placeholderPattern`.
1435− *
1436− * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
1437− * `true` will be replaced.
1438− *
1439− * @param {object} env The environment of the `before-tokenize` hook.
1440− * @param {string} language The language id.
1441− * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
1442− * @param {(match: string) => boolean} [replaceFilter]
1443− */
1444− value: function (env, language, placeholderPattern, replaceFilter) {
1445− if (env.language !== language) {
1446− return;
1447− }
1448−
1449− var tokenStack = env.tokenStack = [];
1450−
1451− env.code = env.code.replace(placeholderPattern, function (match) {
1452− if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1453− return match;
1454− }
1455− var i = tokenStack.length;
1456− var placeholder;
1457−
1458− // Check for existing strings
1459− while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
1460− ++i;
1461−
1462− // Create a sparse array
1463− tokenStack[i] = match;
1464−
1465− return placeholder;
1466− });
1467−
1468− // Switch the grammar to markup
1469− env.grammar = Prism.languages.markup;
1470− }
1471− },
1472− tokenizePlaceholders: {
1473− /**
1474− * Replace placeholders with proper tokens after tokenizing.
1475− *
1476− * @param {object} env The environment of the `after-tokenize` hook.
1477− * @param {string} language The language id.
1478− */
1479− value: function (env, language) {
1480− if (env.language !== language || !env.tokenStack) {
1481− return;
1482− }
1483−
1484− // Switch the grammar back
1485− env.grammar = Prism.languages[language];
1486−
1487− var j = 0;
1488− var keys = Object.keys(env.tokenStack);
1489−
1490− function walkTokens(tokens) {
1491− for (var i = 0; i < tokens.length; i++) {
1492− // all placeholders are replaced already
1493− if (j >= keys.length) {
1494− break;
1495− }
1496−
1497− var token = tokens[i];
1498− if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1499− var k = keys[j];
1500− var t = env.tokenStack[k];
1501− var s = typeof token === 'string' ? token : token.content;
1502− var placeholder = getPlaceholder(language, k);
1503−
1504− var index = s.indexOf(placeholder);
1505− if (index > -1) {
1506− ++j;
1507−
1508− var before = s.substring(0, index);
1509− var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
1510− var after = s.substring(index + placeholder.length);
1511−
1512− var replacement = [];
1513− if (before) {
1514− replacement.push.apply(replacement, walkTokens([before]));
1515− }
1516− replacement.push(middle);
1517− if (after) {
1518− replacement.push.apply(replacement, walkTokens([after]));
1519− }
1520−
1521− if (typeof token === 'string') {
1522− tokens.splice.apply(tokens, [i, 1].concat(replacement));
1523− } else {
1524− token.content = replacement;
1525− }
1526− }
1527− } else if (token.content /* && typeof token.content !== 'string' */) {
1528− walkTokens(token.content);
1529− }
1530− }
1531−
1532− return tokens;
1533− }
1534−
1535− walkTokens(env.tokens);
1536− }
1537− }
1538− });
1420+ /**
1421+ * Returns the placeholder for the given language id and index.
1422+ *
1423+ * @param {string} language
1424+ * @param {string|number} index
1425+ * @returns {string}
1426+ */
1427+ function getPlaceholder(language, index) {
1428+ return '___' + language.toUpperCase() + index + '___';
1429+ }
1430+
1431+ Object.defineProperties(Prism.languages['markup-templating'] = {}, {
1432+ buildPlaceholders: {
1433+ /**
1434+ * Tokenize all inline templating expressions matching `placeholderPattern`.
1435+ *
1436+ * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
1437+ * `true` will be replaced.
1438+ *
1439+ * @param {object} env The environment of the `before-tokenize` hook.
1440+ * @param {string} language The language id.
1441+ * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
1442+ * @param {(match: string) => boolean} [replaceFilter]
1443+ */
1444+ value: function (env, language, placeholderPattern, replaceFilter) {
1445+ if (env.language !== language) {
1446+ return;
1447+ }
1448+
1449+ var tokenStack = env.tokenStack = [];
1450+
1451+ env.code = env.code.replace(placeholderPattern, function (match) {
1452+ if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1453+ return match;
1454+ }
1455+ var i = tokenStack.length;
1456+ var placeholder;
1457+
1458+ // Check for existing strings
1459+ while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
1460+ ++i;
1461+
1462+ // Create a sparse array
1463+ tokenStack[i] = match;
1464+
1465+ return placeholder;
1466+ });
1467+
1468+ // Switch the grammar to markup
1469+ env.grammar = Prism.languages.markup;
1470+ }
1471+ },
1472+ tokenizePlaceholders: {
1473+ /**
1474+ * Replace placeholders with proper tokens after tokenizing.
1475+ *
1476+ * @param {object} env The environment of the `after-tokenize` hook.
1477+ * @param {string} language The language id.
1478+ */
1479+ value: function (env, language) {
1480+ if (env.language !== language || !env.tokenStack) {
1481+ return;
1482+ }
1483+
1484+ // Switch the grammar back
1485+ env.grammar = Prism.languages[language];
1486+
1487+ var j = 0;
1488+ var keys = Object.keys(env.tokenStack);
1489+
1490+ function walkTokens(tokens) {
1491+ for (var i = 0; i < tokens.length; i++) {
1492+ // all placeholders are replaced already
1493+ if (j >= keys.length) {
1494+ break;
1495+ }
1496+
1497+ var token = tokens[i];
1498+ if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1499+ var k = keys[j];
1500+ var t = env.tokenStack[k];
1501+ var s = typeof token === 'string' ? token : token.content;
1502+ var placeholder = getPlaceholder(language, k);
1503+
1504+ var index = s.indexOf(placeholder);
1505+ if (index > -1) {
1506+ ++j;
1507+
1508+ var before = s.substring(0, index);
1509+ var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
1510+ var after = s.substring(index + placeholder.length);
1511+
1512+ var replacement = [];
1513+ if (before) {
1514+ replacement.push.apply(replacement, walkTokens([before]));
1515+ }
1516+ replacement.push(middle);
1517+ if (after) {
1518+ replacement.push.apply(replacement, walkTokens([after]));
1519+ }
1520+
1521+ if (typeof token === 'string') {
1522+ tokens.splice.apply(tokens, [i, 1].concat(replacement));
1523+ } else {
1524+ token.content = replacement;
1525+ }
1526+ }
1527+ } else if (token.content /* && typeof token.content !== 'string' */) {
1528+ walkTokens(token.content);
1529+ }
1530+ }
1531+
1532+ return tokens;
1533+ }
1534+
1535+ walkTokens(env.tokens);
1536+ }
1537+ }
1538+ });
15391539
15401540 }(Prism));
15411541
15421542 Prism.languages.elixir = {
1543− 'comment': /#.*/m,
1544− // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
1545− 'regex': {
1546− pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1547− greedy: true
1548− },
1549− 'string': [
1550− {
1551− // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
1552− pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
1553− greedy: true,
1554− inside: {
1555− // See interpolation below
1556− }
1557− },
1558− {
1559− pattern: /("""|''')[\s\S]*?\1/,
1560− greedy: true,
1561− inside: {
1562− // See interpolation below
1563− }
1564− },
1565− {
1566− // Multi-line strings are allowed
1567− pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1568− greedy: true,
1569− inside: {
1570− // See interpolation below
1571− }
1572− }
1573− ],
1574− 'atom': {
1575− // Look-behind prevents bad highlighting of the :: operator
1576− pattern: /(^|[^:]):\w+/,
1577− lookbehind: true,
1578− alias: 'symbol'
1579− },
1580− // Look-ahead prevents bad highlighting of the :: operator
1581− 'attr-name': /\w+:(?!:)/,
1582− 'capture': {
1583− // Look-behind prevents bad highlighting of the && operator
1584− pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
1585− lookbehind: true,
1586− alias: 'function'
1587− },
1588− 'argument': {
1589− // Look-behind prevents bad highlighting of the && operator
1590− pattern: /(^|[^&])&\d+/,
1591− lookbehind: true,
1592− alias: 'variable'
1593− },
1594− 'attribute': {
1595− pattern: /@\w+/,
1596− alias: 'variable'
1597− },
1598− 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
1599− 'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|exception|impl|module|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|require|rescue|try|unless|use|when)\b/,
1600− 'boolean': /\b(?:true|false|nil)\b/,
1601− 'operator': [
1602− /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
1603− {
1604− // We don't want to match <<
1605− pattern: /([^<])<(?!<)/,
1606− lookbehind: true
1607− },
1608− {
1609− // We don't want to match >>
1610− pattern: /([^>])>(?!>)/,
1611− lookbehind: true
1612− }
1613− ],
1614− 'punctuation': /<<|>>|[.,%\[\]{}()]/
1543+ 'comment': /#.*/m,
1544+ // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
1545+ 'regex': {
1546+ pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1547+ greedy: true
1548+ },
1549+ 'string': [
1550+ {
1551+ // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
1552+ pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
1553+ greedy: true,
1554+ inside: {
1555+ // See interpolation below
1556+ }
1557+ },
1558+ {
1559+ pattern: /("""|''')[\s\S]*?\1/,
1560+ greedy: true,
1561+ inside: {
1562+ // See interpolation below
1563+ }
1564+ },
1565+ {
1566+ // Multi-line strings are allowed
1567+ pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
1568+ greedy: true,
1569+ inside: {
1570+ // See interpolation below
1571+ }
1572+ }
1573+ ],
1574+ 'atom': {
1575+ // Look-behind prevents bad highlighting of the :: operator
1576+ pattern: /(^|[^:]):\w+/,
1577+ lookbehind: true,
1578+ alias: 'symbol'
1579+ },
1580+ // Look-ahead prevents bad highlighting of the :: operator
1581+ 'attr-name': /\w+:(?!:)/,
1582+ 'capture': {
1583+ // Look-behind prevents bad highlighting of the && operator
1584+ pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
1585+ lookbehind: true,
1586+ alias: 'function'
1587+ },
1588+ 'argument': {
1589+ // Look-behind prevents bad highlighting of the && operator
1590+ pattern: /(^|[^&])&\d+/,
1591+ lookbehind: true,
1592+ alias: 'variable'
1593+ },
1594+ 'attribute': {
1595+ pattern: /@\w+/,
1596+ alias: 'variable'
1597+ },
1598+ 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
1599+ 'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|exception|impl|module|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|require|rescue|try|unless|use|when)\b/,
1600+ 'boolean': /\b(?:true|false|nil)\b/,
1601+ 'operator': [
1602+ /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
1603+ {
1604+ // We don't want to match <<
1605+ pattern: /([^<])<(?!<)/,
1606+ lookbehind: true
1607+ },
1608+ {
1609+ // We don't want to match >>
1610+ pattern: /([^>])>(?!>)/,
1611+ lookbehind: true
1612+ }
1613+ ],
1614+ 'punctuation': /<<|>>|[.,%\[\]{}()]/
16151615 };
16161616
16171617 Prism.languages.elixir.string.forEach(function(o) {
1618− o.inside = {
1619− 'interpolation': {
1620− pattern: /#\{[^}]+\}/,
1621− inside: {
1622− 'delimiter': {
1623− pattern: /^#\{|\}$/,
1624− alias: 'punctuation'
1625− },
1626− rest: Prism.languages.elixir
1627− }
1628− }
1629− };
1618+ o.inside = {
1619+ 'interpolation': {
1620+ pattern: /#\{[^}]+\}/,
1621+ inside: {
1622+ 'delimiter': {
1623+ pattern: /^#\{|\}$/,
1624+ alias: 'punctuation'
1625+ },
1626+ rest: Prism.languages.elixir
1627+ }
1628+ }
1629+ };
16301630 });
16311631
16321632 Prism.languages.erlang = {
1633− 'comment': /%.+/,
1634− 'string': {
1635− pattern: /"(?:\\.|[^\\"\r\n])*"/,
1636− greedy: true
1637− },
1638− 'quoted-function': {
1639− pattern: /'(?:\\.|[^\\'\r\n])+'(?=\()/,
1640− alias: 'function'
1641− },
1642− 'quoted-atom': {
1643− pattern: /'(?:\\.|[^\\'\r\n])+'/,
1644− alias: 'atom'
1645− },
1646− 'boolean': /\b(?:true|false)\b/,
1647− 'keyword': /\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,
1648− 'number': [
1649− /\$\\?./,
1650− /\d+#[a-z0-9]+/i,
1651− /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
1652− ],
1653− 'function': /\b[a-z][\w@]*(?=\()/,
1654− 'variable': {
1655− // Look-behind is used to prevent wrong highlighting of atoms containing "@"
1656− pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
1657− lookbehind: true
1658− },
1659− 'operator': [
1660− /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
1661− {
1662− // We don't want to match <<
1663− pattern: /(^|[^<])<(?!<)/,
1664− lookbehind: true
1665− },
1666− {
1667− // We don't want to match >>
1668− pattern: /(^|[^>])>(?!>)/,
1669− lookbehind: true
1670− }
1671− ],
1672− 'atom': /\b[a-z][\w@]*/,
1673− 'punctuation': /[()[\]{}:;,.#|]|<<|>>/
1633+ 'comment': /%.+/,
1634+ 'string': {
1635+ pattern: /"(?:\\.|[^\\"\r\n])*"/,
1636+ greedy: true
1637+ },
1638+ 'quoted-function': {
1639+ pattern: /'(?:\\.|[^\\'\r\n])+'(?=\()/,
1640+ alias: 'function'
1641+ },
1642+ 'quoted-atom': {
1643+ pattern: /'(?:\\.|[^\\'\r\n])+'/,
1644+ alias: 'atom'
1645+ },
1646+ 'boolean': /\b(?:true|false)\b/,
1647+ 'keyword': /\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,
1648+ 'number': [
1649+ /\$\\?./,
1650+ /\d+#[a-z0-9]+/i,
1651+ /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
1652+ ],
1653+ 'function': /\b[a-z][\w@]*(?=\()/,
1654+ 'variable': {
1655+ // Look-behind is used to prevent wrong highlighting of atoms containing "@"
1656+ pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
1657+ lookbehind: true
1658+ },
1659+ 'operator': [
1660+ /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
1661+ {
1662+ // We don't want to match <<
1663+ pattern: /(^|[^<])<(?!<)/,
1664+ lookbehind: true
1665+ },
1666+ {
1667+ // We don't want to match >>
1668+ pattern: /(^|[^>])>(?!>)/,
1669+ lookbehind: true
1670+ }
1671+ ],
1672+ 'atom': /\b[a-z][\w@]*/,
1673+ 'punctuation': /[()[\]{}:;,.#|]|<<|>>/
16741674
16751675 };
16761676 Prism.languages.go = Prism.languages.extend('clike', {
1677− 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
1678− 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
1679− 'boolean': /\b(?:_|iota|nil|true|false)\b/,
1680− 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1681− 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
1682− 'string': {
1683− pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
1684− greedy: true
1685− }
1677+ 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
1678+ 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
1679+ 'boolean': /\b(?:_|iota|nil|true|false)\b/,
1680+ 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1681+ 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
1682+ 'string': {
1683+ pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
1684+ greedy: true
1685+ }
16861686 });
16871687 delete Prism.languages.go['class-name'];
16881688
16891689 Prism.languages.groovy = Prism.languages.extend('clike', {
1690− 'keyword': /\b(?:as|def|in|abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|trait|transient|try|void|volatile|while)\b/,
1691− 'string': [
1692− {
1693− pattern: /("""|''')[\s\S]*?\1|(?:\$\/)(?:\$\/\$|[\s\S])*?\/\$/,
1694− greedy: true
1695− },
1696− {
1697− pattern: /(["'\/])(?:\\.|(?!\1)[^\\\r\n])*\1/,
1698− greedy: true
1699− }
1700− ],
1701− 'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
1702− 'operator': {
1703− pattern: /(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
1704− lookbehind: true
1705− },
1706− 'punctuation': /\.+|[{}[\];(),:$]/
1690+ 'keyword': /\b(?:as|def|in|abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|trait|transient|try|void|volatile|while)\b/,
1691+ 'string': [
1692+ {
1693+ pattern: /("""|''')[\s\S]*?\1|(?:\$\/)(?:\$\/\$|[\s\S])*?\/\$/,
1694+ greedy: true
1695+ },
1696+ {
1697+ pattern: /(["'\/])(?:\\.|(?!\1)[^\\\r\n])*\1/,
1698+ greedy: true
1699+ }
1700+ ],
1701+ 'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
1702+ 'operator': {
1703+ pattern: /(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
1704+ lookbehind: true
1705+ },
1706+ 'punctuation': /\.+|[{}[\];(),:$]/
17071707 });
17081708
17091709 Prism.languages.insertBefore('groovy', 'string', {
1710− 'shebang': {
1711− pattern: /#!.+/,
1712− alias: 'comment'
1713− }
1710+ 'shebang': {
1711+ pattern: /#!.+/,
1712+ alias: 'comment'
1713+ }
17141714 });
17151715
17161716 Prism.languages.insertBefore('groovy', 'punctuation', {
1717− 'spock-block': /\b(?:setup|given|when|then|and|cleanup|expect|where):/
1717+ 'spock-block': /\b(?:setup|given|when|then|and|cleanup|expect|where):/
17181718 });
17191719
17201720 Prism.languages.insertBefore('groovy', 'function', {
1721− 'annotation': {
1722− alias: 'punctuation',
1723− pattern: /(^|[^.])@\w+/,
1724− lookbehind: true
1725− }
1721+ 'annotation': {
1722+ alias: 'punctuation',
1723+ pattern: /(^|[^.])@\w+/,
1724+ lookbehind: true
1725+ }
17261726 });
17271727
17281728 // Handle string interpolation
17291729 Prism.hooks.add('wrap', function(env) {
1730− if (env.language === 'groovy' && env.type === 'string') {
1731− var delimiter = env.content[0];
1732−
1733− if (delimiter != "'") {
1734− var pattern = /([^\\])(?:\$(?:\{.*?\}|[\w.]+))/;
1735− if (delimiter === '$') {
1736− pattern = /([^\$])(?:\$(?:\{.*?\}|[\w.]+))/;
1737− }
1738−
1739− // To prevent double HTML-encoding we have to decode env.content first
1740− env.content = env.content.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
1741−
1742− env.content = Prism.highlight(env.content, {
1743− 'expression': {
1744− pattern: pattern,
1745− lookbehind: true,
1746− inside: Prism.languages.groovy
1747− }
1748− });
1749−
1750− env.classes.push(delimiter === '/' ? 'regex' : 'gstring');
1751− }
1752− }
1730+ if (env.language === 'groovy' && env.type === 'string') {
1731+ var delimiter = env.content[0];
1732+
1733+ if (delimiter != "'") {
1734+ var pattern = /([^\\])(?:\$(?:\{.*?\}|[\w.]+))/;
1735+ if (delimiter === '$') {
1736+ pattern = /([^\$])(?:\$(?:\{.*?\}|[\w.]+))/;
1737+ }
1738+
1739+ // To prevent double HTML-encoding we have to decode env.content first
1740+ env.content = env.content.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
1741+
1742+ env.content = Prism.highlight(env.content, {
1743+ 'expression': {
1744+ pattern: pattern,
1745+ lookbehind: true,
1746+ inside: Prism.languages.groovy
1747+ }
1748+ });
1749+
1750+ env.classes.push(delimiter === '/' ? 'regex' : 'gstring');
1751+ }
1752+ }
17531753 });
17541754
17551755 (function (Prism) {
17561756
1757− var keywords = /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while|var|null|exports|module|open|opens|provides|requires|to|transitive|uses|with)\b/;
1758−
1759− // based on the java naming conventions
1760− var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
1761−
1762− Prism.languages.java = Prism.languages.extend('clike', {
1763− 'class-name': [
1764− className,
1765−
1766− // variables and parameters
1767− // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1768− /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
1769− ],
1770− 'keyword': keywords,
1771− 'function': [
1772− Prism.languages.clike.function,
1773− {
1774− pattern: /(\:\:)[a-z_]\w*/,
1775− lookbehind: true
1776− }
1777− ],
1778− 'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
1779− 'operator': {
1780− pattern: /(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,
1781− lookbehind: true
1782− }
1783− });
1784−
1785− Prism.languages.insertBefore('java', 'class-name', {
1786− 'annotation': {
1787− alias: 'punctuation',
1788− pattern: /(^|[^.])@\w+/,
1789− lookbehind: true
1790− },
1791− 'namespace': {
1792− pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,
1793− lookbehind: true,
1794− inside: {
1795− 'punctuation': /\./,
1796− }
1797− },
1798− 'generics': {
1799− pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
1800− inside: {
1801− 'class-name': className,
1802− 'keyword': keywords,
1803− 'punctuation': /[<>(),.:]/,
1804− 'operator': /[?&|]/
1805− }
1806− }
1807− });
1757+ var keywords = /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while|var|null|exports|module|open|opens|provides|requires|to|transitive|uses|with)\b/;
1758+
1759+ // based on the java naming conventions
1760+ var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
1761+
1762+ Prism.languages.java = Prism.languages.extend('clike', {
1763+ 'class-name': [
1764+ className,
1765+
1766+ // variables and parameters
1767+ // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
1768+ /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
1769+ ],
1770+ 'keyword': keywords,
1771+ 'function': [
1772+ Prism.languages.clike.function,
1773+ {
1774+ pattern: /(\:\:)[a-z_]\w*/,
1775+ lookbehind: true
1776+ }
1777+ ],
1778+ 'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
1779+ 'operator': {
1780+ pattern: /(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,
1781+ lookbehind: true
1782+ }
1783+ });
1784+
1785+ Prism.languages.insertBefore('java', 'class-name', {
1786+ 'annotation': {
1787+ alias: 'punctuation',
1788+ pattern: /(^|[^.])@\w+/,
1789+ lookbehind: true
1790+ },
1791+ 'namespace': {
1792+ pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,
1793+ lookbehind: true,
1794+ inside: {
1795+ 'punctuation': /\./,
1796+ }
1797+ },
1798+ 'generics': {
1799+ pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
1800+ inside: {
1801+ 'class-name': className,
1802+ 'keyword': keywords,
1803+ 'punctuation': /[<>(),.:]/,
1804+ 'operator': /[?&|]/
1805+ }
1806+ }
1807+ });
18081808 }(Prism));
18091809
18101810 /**
@@ -1820,779 +1820,779 @@ Prism.hooks.add('wrap', function(env) { · 9 unmodified lines
18201820 * constant, delimiter, variable, function, package
18211821 */
18221822 (function (Prism) {
1823− Prism.languages.php = Prism.languages.extend('clike', {
1824− 'keyword': /\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
1825− 'boolean': {
1826− pattern: /\b(?:false|true)\b/i,
1827− alias: 'constant'
1828− },
1829− 'constant': [
1830− /\b[A-Z_][A-Z0-9_]*\b/,
1831− /\b(?:null)\b/i,
1832− ],
1833− 'comment': {
1834− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1835− lookbehind: true
1836− }
1837− });
1838−
1839− Prism.languages.insertBefore('php', 'string', {
1840− 'shell-comment': {
1841− pattern: /(^|[^\\])#.*/,
1842− lookbehind: true,
1843− alias: 'comment'
1844− }
1845− });
1846−
1847− Prism.languages.insertBefore('php', 'comment', {
1848− 'delimiter': {
1849− pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
1850− alias: 'important'
1851− }
1852− });
1853−
1854− Prism.languages.insertBefore('php', 'keyword', {
1855− 'variable': /\$+(?:\w+\b|(?={))/i,
1856− 'package': {
1857− pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1858− lookbehind: true,
1859− inside: {
1860− punctuation: /\\/
1861− }
1862− }
1863− });
1864−
1865− // Must be defined after the function pattern
1866− Prism.languages.insertBefore('php', 'operator', {
1867− 'property': {
1868− pattern: /(->)[\w]+/,
1869− lookbehind: true
1870− }
1871− });
1872−
1873− var string_interpolation = {
1874− pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
1875− lookbehind: true,
1876− inside: {
1877− rest: Prism.languages.php
1878− }
1879− };
1880−
1881− Prism.languages.insertBefore('php', 'string', {
1882− 'nowdoc-string': {
1883− pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1884− greedy: true,
1885− alias: 'string',
1886− inside: {
1887− 'delimiter': {
1888− pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
1889− alias: 'symbol',
1890− inside: {
1891− 'punctuation': /^<<<'?|[';]$/
1892− }
1893− }
1894− }
1895− },
1896− 'heredoc-string': {
1897− pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
1898− greedy: true,
1899− alias: 'string',
1900− inside: {
1901− 'delimiter': {
1902− pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
1903− alias: 'symbol',
1904− inside: {
1905− 'punctuation': /^<<<"?|[";]$/
1906− }
1907− },
1908− 'interpolation': string_interpolation // See below
1909− }
1910− },
1911− 'single-quoted-string': {
1912− pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1913− greedy: true,
1914− alias: 'string'
1915− },
1916− 'double-quoted-string': {
1917− pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1918− greedy: true,
1919− alias: 'string',
1920− inside: {
1921− 'interpolation': string_interpolation // See below
1922− }
1923− }
1924− });
1925− // The different types of PHP strings "replace" the C-like standard string
1926− delete Prism.languages.php['string'];
1927−
1928− Prism.hooks.add('before-tokenize', function(env) {
1929− if (!/<\?/.test(env.code)) {
1930− return;
1931− }
1932−
1933− var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
1934− Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
1935− });
1936−
1937− Prism.hooks.add('after-tokenize', function(env) {
1938− Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
1939− });
1823+ Prism.languages.php = Prism.languages.extend('clike', {
1824+ 'keyword': /\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
1825+ 'boolean': {
1826+ pattern: /\b(?:false|true)\b/i,
1827+ alias: 'constant'
1828+ },
1829+ 'constant': [
1830+ /\b[A-Z_][A-Z0-9_]*\b/,
1831+ /\b(?:null)\b/i,
1832+ ],
1833+ 'comment': {
1834+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1835+ lookbehind: true
1836+ }
1837+ });
1838+
1839+ Prism.languages.insertBefore('php', 'string', {
1840+ 'shell-comment': {
1841+ pattern: /(^|[^\\])#.*/,
1842+ lookbehind: true,
1843+ alias: 'comment'
1844+ }
1845+ });
1846+
1847+ Prism.languages.insertBefore('php', 'comment', {
1848+ 'delimiter': {
1849+ pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
1850+ alias: 'important'
1851+ }
1852+ });
1853+
1854+ Prism.languages.insertBefore('php', 'keyword', {
1855+ 'variable': /\$+(?:\w+\b|(?={))/i,
1856+ 'package': {
1857+ pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1858+ lookbehind: true,
1859+ inside: {
1860+ punctuation: /\\/
1861+ }
1862+ }
1863+ });
1864+
1865+ // Must be defined after the function pattern
1866+ Prism.languages.insertBefore('php', 'operator', {
1867+ 'property': {
1868+ pattern: /(->)[\w]+/,
1869+ lookbehind: true
1870+ }
1871+ });
1872+
1873+ var string_interpolation = {
1874+ pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
1875+ lookbehind: true,
1876+ inside: {
1877+ rest: Prism.languages.php
1878+ }
1879+ };
1880+
1881+ Prism.languages.insertBefore('php', 'string', {
1882+ 'nowdoc-string': {
1883+ pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1884+ greedy: true,
1885+ alias: 'string',
1886+ inside: {
1887+ 'delimiter': {
1888+ pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
1889+ alias: 'symbol',
1890+ inside: {
1891+ 'punctuation': /^<<<'?|[';]$/
1892+ }
1893+ }
1894+ }
1895+ },
1896+ 'heredoc-string': {
1897+ pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
1898+ greedy: true,
1899+ alias: 'string',
1900+ inside: {
1901+ 'delimiter': {
1902+ pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
1903+ alias: 'symbol',
1904+ inside: {
1905+ 'punctuation': /^<<<"?|[";]$/
1906+ }
1907+ },
1908+ 'interpolation': string_interpolation // See below
1909+ }
1910+ },
1911+ 'single-quoted-string': {
1912+ pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1913+ greedy: true,
1914+ alias: 'string'
1915+ },
1916+ 'double-quoted-string': {
1917+ pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1918+ greedy: true,
1919+ alias: 'string',
1920+ inside: {
1921+ 'interpolation': string_interpolation // See below
1922+ }
1923+ }
1924+ });
1925+ // The different types of PHP strings "replace" the C-like standard string
1926+ delete Prism.languages.php['string'];
1927+
1928+ Prism.hooks.add('before-tokenize', function(env) {
1929+ if (!/<\?/.test(env.code)) {
1930+ return;
1931+ }
1932+
1933+ var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
1934+ Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
1935+ });
1936+
1937+ Prism.hooks.add('after-tokenize', function(env) {
1938+ Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
1939+ });
19401940
19411941 }(Prism));
19421942
19431943 Prism.languages.json = {
1944− 'property': {
1945− pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1946− greedy: true
1947− },
1948− 'string': {
1949− pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1950− greedy: true
1951− },
1952− 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1953− 'number': /-?\d+\.?\d*(e[+-]?\d+)?/i,
1954− 'punctuation': /[{}[\],]/,
1955− 'operator': /:/,
1956− 'boolean': /\b(?:true|false)\b/,
1957− 'null': {
1958− pattern: /\bnull\b/,
1959− alias: 'keyword'
1960− }
1944+ 'property': {
1945+ pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
1946+ greedy: true
1947+ },
1948+ 'string': {
1949+ pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1950+ greedy: true
1951+ },
1952+ 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
1953+ 'number': /-?\d+\.?\d*(e[+-]?\d+)?/i,
1954+ 'punctuation': /[{}[\],]/,
1955+ 'operator': /:/,
1956+ 'boolean': /\b(?:true|false)\b/,
1957+ 'null': {
1958+ pattern: /\bnull\b/,
1959+ alias: 'keyword'
1960+ }
19611961 };
19621962
19631963 Prism.languages.julia= {
1964− 'comment': {
1965− pattern: /(^|[^\\])#.*/,
1966− lookbehind: true
1967− },
1968− 'string': /("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,
1969− 'keyword' : /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
1970− 'boolean' : /\b(?:true|false)\b/,
1971− 'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
1972− 'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
1973− 'punctuation' : /[{}[\];(),.:]/,
1974− 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
1964+ 'comment': {
1965+ pattern: /(^|[^\\])#.*/,
1966+ lookbehind: true
1967+ },
1968+ 'string': /("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,
1969+ 'keyword' : /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
1970+ 'boolean' : /\b(?:true|false)\b/,
1971+ 'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
1972+ 'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
1973+ 'punctuation' : /[{}[\];(),.:]/,
1974+ 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
19751975 };
19761976
19771977 (function (Prism) {
1978− Prism.languages.kotlin = Prism.languages.extend('clike', {
1979− 'keyword': {
1980− // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
1981− pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
1982− lookbehind: true
1983− },
1984− 'function': [
1985− /\w+(?=\s*\()/,
1986− {
1987− pattern: /(\.)\w+(?=\s*\{)/,
1988− lookbehind: true
1989− }
1990− ],
1991− 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
1992− 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
1993− });
1994−
1995− delete Prism.languages.kotlin["class-name"];
1996−
1997− Prism.languages.insertBefore('kotlin', 'string', {
1998− 'raw-string': {
1999− pattern: /("""|''')[\s\S]*?\1/,
2000− alias: 'string'
2001− // See interpolation below
2002− }
2003− });
2004− Prism.languages.insertBefore('kotlin', 'keyword', {
2005− 'annotation': {
2006− pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
2007− alias: 'builtin'
2008− }
2009− });
2010− Prism.languages.insertBefore('kotlin', 'function', {
2011− 'label': {
2012− pattern: /\w+@|@\w+/,
2013− alias: 'symbol'
2014− }
2015− });
2016−
2017− var interpolation = [
2018− {
2019− pattern: /\$\{[^}]+\}/,
2020− inside: {
2021− delimiter: {
2022− pattern: /^\$\{|\}$/,
2023− alias: 'variable'
2024− },
2025− rest: Prism.languages.kotlin
2026− }
2027− },
2028− {
2029− pattern: /\$\w+/,
2030− alias: 'variable'
2031− }
2032− ];
2033−
2034− Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
2035− interpolation: interpolation
2036− };
1978+ Prism.languages.kotlin = Prism.languages.extend('clike', {
1979+ 'keyword': {
1980+ // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
1981+ pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
1982+ lookbehind: true
1983+ },
1984+ 'function': [
1985+ /\w+(?=\s*\()/,
1986+ {
1987+ pattern: /(\.)\w+(?=\s*\{)/,
1988+ lookbehind: true
1989+ }
1990+ ],
1991+ 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
1992+ 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
1993+ });
1994+
1995+ delete Prism.languages.kotlin["class-name"];
1996+
1997+ Prism.languages.insertBefore('kotlin', 'string', {
1998+ 'raw-string': {
1999+ pattern: /("""|''')[\s\S]*?\1/,
2000+ alias: 'string'
2001+ // See interpolation below
2002+ }
2003+ });
2004+ Prism.languages.insertBefore('kotlin', 'keyword', {
2005+ 'annotation': {
2006+ pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
2007+ alias: 'builtin'
2008+ }
2009+ });
2010+ Prism.languages.insertBefore('kotlin', 'function', {
2011+ 'label': {
2012+ pattern: /\w+@|@\w+/,
2013+ alias: 'symbol'
2014+ }
2015+ });
2016+
2017+ var interpolation = [
2018+ {
2019+ pattern: /\$\{[^}]+\}/,
2020+ inside: {
2021+ delimiter: {
2022+ pattern: /^\$\{|\}$/,
2023+ alias: 'variable'
2024+ },
2025+ rest: Prism.languages.kotlin
2026+ }
2027+ },
2028+ {
2029+ pattern: /\$\w+/,
2030+ alias: 'variable'
2031+ }
2032+ ];
2033+
2034+ Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
2035+ interpolation: interpolation
2036+ };
20372037
20382038 }(Prism));
20392039
20402040 (function(Prism) {
2041− Prism.languages.crystal = Prism.languages.extend('ruby', {
2042− keyword: [
2043− /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,
2044− {
2045− pattern: /(\.\s*)(?:is_a|responds_to)\?/,
2046− lookbehind: true
2047− }
2048− ],
2049−
2050− number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
2051− });
2052−
2053− Prism.languages.insertBefore('crystal', 'string', {
2054− attribute: {
2055− pattern: /@\[.+?\]/,
2056− alias: 'attr-name',
2057− inside: {
2058− delimiter: {
2059− pattern: /^@\[|\]$/,
2060− alias: 'tag'
2061− },
2062− rest: Prism.languages.crystal
2063− }
2064− },
2065−
2066− expansion: [
2067− {
2068− pattern: /\{\{.+?\}\}/,
2069− inside: {
2070− delimiter: {
2071− pattern: /^\{\{|\}\}$/,
2072− alias: 'tag'
2073− },
2074− rest: Prism.languages.crystal
2075− }
2076− },
2077− {
2078− pattern: /\{%.+?%\}/,
2079− inside: {
2080− delimiter: {
2081− pattern: /^\{%|%\}$/,
2082− alias: 'tag'
2083− },
2084− rest: Prism.languages.crystal
2085− }
2086− }
2087− ]
2088− });
2041+ Prism.languages.crystal = Prism.languages.extend('ruby', {
2042+ keyword: [
2043+ /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield|__DIR__|__END_LINE__|__FILE__|__LINE__)\b/,
2044+ {
2045+ pattern: /(\.\s*)(?:is_a|responds_to)\?/,
2046+ lookbehind: true
2047+ }
2048+ ],
2049+
2050+ number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
2051+ });
2052+
2053+ Prism.languages.insertBefore('crystal', 'string', {
2054+ attribute: {
2055+ pattern: /@\[.+?\]/,
2056+ alias: 'attr-name',
2057+ inside: {
2058+ delimiter: {
2059+ pattern: /^@\[|\]$/,
2060+ alias: 'tag'
2061+ },
2062+ rest: Prism.languages.crystal
2063+ }
2064+ },
2065+
2066+ expansion: [
2067+ {
2068+ pattern: /\{\{.+?\}\}/,
2069+ inside: {
2070+ delimiter: {
2071+ pattern: /^\{\{|\}\}$/,
2072+ alias: 'tag'
2073+ },
2074+ rest: Prism.languages.crystal
2075+ }
2076+ },
2077+ {
2078+ pattern: /\{%.+?%\}/,
2079+ inside: {
2080+ delimiter: {
2081+ pattern: /^\{%|%\}$/,
2082+ alias: 'tag'
2083+ },
2084+ rest: Prism.languages.crystal
2085+ }
2086+ }
2087+ ]
2088+ });
20892089
20902090 }(Prism));
20912091
20922092 Prism.languages.lua = {
2093− 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
2094− // \z may be used to skip the following space
2095− 'string': {
2096− pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
2097− greedy: true
2098− },
2099− 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
2100− 'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
2101− 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
2102− 'operator': [
2103− /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
2104− {
2105− // Match ".." but don't break "..."
2106− pattern: /(^|[^.])\.\.(?!\.)/,
2107− lookbehind: true
2108− }
2109− ],
2110− 'punctuation': /[\[\](){},;]|\.+|:+/
2093+ 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
2094+ // \z may be used to skip the following space
2095+ 'string': {
2096+ pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
2097+ greedy: true
2098+ },
2099+ 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
2100+ 'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
2101+ 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
2102+ 'operator': [
2103+ /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
2104+ {
2105+ // Match ".." but don't break "..."
2106+ pattern: /(^|[^.])\.\.(?!\.)/,
2107+ lookbehind: true
2108+ }
2109+ ],
2110+ 'punctuation': /[\[\](){},;]|\.+|:+/
21112111 };
21122112 // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
21132113 // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
21142114
21152115 (function (Prism) {
21162116
2117− Prism.languages.django = {
2118− 'comment': /^{#[\s\S]*?#}$/,
2119− 'tag': {
2120− pattern: /(^{%[+-]?\s*)\w+/,
2121− lookbehind: true,
2122− alias: 'keyword'
2123− },
2124− 'delimiter': {
2125− pattern: /^{[{%][+-]?|[+-]?[}%]}$/,
2126− alias: 'punctuation'
2127− },
2128− 'string': {
2129− pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
2130− greedy: true
2131− },
2132− 'filter': {
2133− pattern: /(\|)\w+/,
2134− lookbehind: true,
2135− alias: 'function'
2136− },
2137− 'test': {
2138− pattern: /(\bis\s+(?:not\s+)?)(?!not\b)\w+/,
2139− lookbehind: true,
2140− alias: 'function'
2141− },
2142− 'function': /\b[a-z_]\w+(?=\s*\()/i,
2143− 'keyword': /\b(?:and|as|by|else|for|if|import|in|is|loop|not|or|recursive|with|without)\b/,
2144− 'operator': /[-+*/%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2145− 'number': /\b\d+(?:\.\d+)?\b/,
2146− 'boolean': /[Tt]rue|[Ff]alse|[Nn]one/,
2147− 'variable': /\b\w+?\b/,
2148− 'punctuation': /[{}[\](),.:;]/
2149− };
2150−
2151−
2152− var pattern = /{{[\s\S]*?}}|{%[\s\S]*?%}|{#[\s\S]*?#}/g;
2153− var markupTemplating = Prism.languages['markup-templating'];
2154−
2155− Prism.hooks.add('before-tokenize', function (env) {
2156− markupTemplating.buildPlaceholders(env, 'django', pattern);
2157− });
2158− Prism.hooks.add('after-tokenize', function (env) {
2159− markupTemplating.tokenizePlaceholders(env, 'django');
2160− });
2161−
2162− // Add an Jinja2 alias
2163− Prism.languages.jinja2 = Prism.languages.django;
2164− Prism.hooks.add('before-tokenize', function (env) {
2165− markupTemplating.buildPlaceholders(env, 'jinja2', pattern);
2166− });
2167− Prism.hooks.add('after-tokenize', function (env) {
2168− markupTemplating.tokenizePlaceholders(env, 'jinja2');
2169− });
2117+ Prism.languages.django = {
2118+ 'comment': /^{#[\s\S]*?#}$/,
2119+ 'tag': {
2120+ pattern: /(^{%[+-]?\s*)\w+/,
2121+ lookbehind: true,
2122+ alias: 'keyword'
2123+ },
2124+ 'delimiter': {
2125+ pattern: /^{[{%][+-]?|[+-]?[}%]}$/,
2126+ alias: 'punctuation'
2127+ },
2128+ 'string': {
2129+ pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
2130+ greedy: true
2131+ },
2132+ 'filter': {
2133+ pattern: /(\|)\w+/,
2134+ lookbehind: true,
2135+ alias: 'function'
2136+ },
2137+ 'test': {
2138+ pattern: /(\bis\s+(?:not\s+)?)(?!not\b)\w+/,
2139+ lookbehind: true,
2140+ alias: 'function'
2141+ },
2142+ 'function': /\b[a-z_]\w+(?=\s*\()/i,
2143+ 'keyword': /\b(?:and|as|by|else|for|if|import|in|is|loop|not|or|recursive|with|without)\b/,
2144+ 'operator': /[-+*/%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2145+ 'number': /\b\d+(?:\.\d+)?\b/,
2146+ 'boolean': /[Tt]rue|[Ff]alse|[Nn]one/,
2147+ 'variable': /\b\w+?\b/,
2148+ 'punctuation': /[{}[\](),.:;]/
2149+ };
2150+
2151+
2152+ var pattern = /{{[\s\S]*?}}|{%[\s\S]*?%}|{#[\s\S]*?#}/g;
2153+ var markupTemplating = Prism.languages['markup-templating'];
2154+
2155+ Prism.hooks.add('before-tokenize', function (env) {
2156+ markupTemplating.buildPlaceholders(env, 'django', pattern);
2157+ });
2158+ Prism.hooks.add('after-tokenize', function (env) {
2159+ markupTemplating.tokenizePlaceholders(env, 'django');
2160+ });
2161+
2162+ // Add an Jinja2 alias
2163+ Prism.languages.jinja2 = Prism.languages.django;
2164+ Prism.hooks.add('before-tokenize', function (env) {
2165+ markupTemplating.buildPlaceholders(env, 'jinja2', pattern);
2166+ });
2167+ Prism.hooks.add('after-tokenize', function (env) {
2168+ markupTemplating.tokenizePlaceholders(env, 'jinja2');
2169+ });
21702170
21712171 })(Prism);
21722172
21732173 Prism.languages.matlab = {
2174− 'comment': [
2175− /%\{[\s\S]*?\}%/,
2176− /%.+/
2177− ],
2178− 'string': {
2179− pattern: /\B'(?:''|[^'\r\n])*'/,
2180− greedy: true
2181− },
2182− // FIXME We could handle imaginary numbers as a whole
2183− 'number': /(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b/,
2184− 'keyword': /\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
2185− 'function': /(?!\d)\w+(?=\s*\()/,
2186− 'operator': /\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,
2187− 'punctuation': /\.{3}|[.,;\[\](){}!]/
2174+ 'comment': [
2175+ /%\{[\s\S]*?\}%/,
2176+ /%.+/
2177+ ],
2178+ 'string': {
2179+ pattern: /\B'(?:''|[^'\r\n])*'/,
2180+ greedy: true
2181+ },
2182+ // FIXME We could handle imaginary numbers as a whole
2183+ 'number': /(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b/,
2184+ 'keyword': /\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
2185+ 'function': /(?!\d)\w+(?=\s*\()/,
2186+ 'operator': /\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,
2187+ 'punctuation': /\.{3}|[.,;\[\](){}!]/
21882188 };
21892189 Prism.languages.typescript = Prism.languages.extend('javascript', {
2190− // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2191− 'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,
2192− 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
2190+ // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2191+ 'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,
2192+ 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
21932193 });
21942194
21952195 Prism.languages.ts = Prism.languages.typescript;
21962196
21972197 Prism.languages.nginx = Prism.languages.extend('clike', {
2198− 'comment': {
2199− pattern: /(^|[^"{\\])#.*/,
2200− lookbehind: true
2201− },
2202− 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types|ssl_session_tickets|ssl_stapling|ssl_stapling_verify|ssl_ecdh_curve|ssl_trusted_certificate|more_set_headers|ssl_early_data)\b/i
2198+ 'comment': {
2199+ pattern: /(^|[^"{\\])#.*/,
2200+ lookbehind: true
2201+ },
2202+ 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types|ssl_session_tickets|ssl_stapling|ssl_stapling_verify|ssl_ecdh_curve|ssl_trusted_certificate|more_set_headers|ssl_early_data)\b/i
22032203 });
22042204
22052205 Prism.languages.insertBefore('nginx', 'keyword', {
2206− 'variable': /\$[a-z_]+/i
2206+ 'variable': /\$[a-z_]+/i
22072207 });
22082208
22092209 Prism.languages.nim = {
2210− 'comment': /#.*/,
2211− // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
2212− // Character literals are handled specifically to prevent issues with numeric type suffixes
2213− 'string': {
2214− pattern: /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,
2215− greedy: true
2216− },
2217− // The negative look ahead prevents wrong highlighting of the .. operator
2218− 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
2219− 'keyword': /\b(?:addr|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|include|interface|iterator|let|macro|method|mixin|nil|object|out|proc|ptr|raise|ref|return|static|template|try|tuple|type|using|var|when|while|with|without|yield)\b/,
2220− 'function': {
2221− pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
2222− inside: {
2223− 'operator': /\*$/
2224− }
2225− },
2226− // We don't want to highlight operators inside backticks
2227− 'ignore': {
2228− pattern: /`[^`\r\n]+`/,
2229− inside: {
2230− 'punctuation': /`/
2231− }
2232− },
2233− 'operator': {
2234− // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
2235− // but allow the slice operator .. to take precedence over them
2236− // One can define his own operators in Nim so all combination of operators might be an operator.
2237− pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr|xor)\b)/m,
2238− lookbehind: true
2239− },
2240− 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
2210+ 'comment': /#.*/,
2211+ // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
2212+ // Character literals are handled specifically to prevent issues with numeric type suffixes
2213+ 'string': {
2214+ pattern: /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,
2215+ greedy: true
2216+ },
2217+ // The negative look ahead prevents wrong highlighting of the .. operator
2218+ 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
2219+ 'keyword': /\b(?:addr|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|include|interface|iterator|let|macro|method|mixin|nil|object|out|proc|ptr|raise|ref|return|static|template|try|tuple|type|using|var|when|while|with|without|yield)\b/,
2220+ 'function': {
2221+ pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
2222+ inside: {
2223+ 'operator': /\*$/
2224+ }
2225+ },
2226+ // We don't want to highlight operators inside backticks
2227+ 'ignore': {
2228+ pattern: /`[^`\r\n]+`/,
2229+ inside: {
2230+ 'punctuation': /`/
2231+ }
2232+ },
2233+ 'operator': {
2234+ // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
2235+ // but allow the slice operator .. to take precedence over them
2236+ // One can define his own operators in Nim so all combination of operators might be an operator.
2237+ pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr|xor)\b)/m,
2238+ lookbehind: true
2239+ },
2240+ 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
22412241 };
22422242 Prism.languages.perl = {
2243− 'comment': [
2244− {
2245− // POD
2246− pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
2247− lookbehind: true
2248− },
2249− {
2250− pattern: /(^|[^\\$])#.*/,
2251− lookbehind: true
2252− }
2253− ],
2254− // TODO Could be nice to handle Heredoc too.
2255− 'string': [
2256− // q/.../
2257− {
2258− pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2259− greedy: true
2260− },
2261−
2262− // q a...a
2263− {
2264− pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2265− greedy: true
2266− },
2267−
2268− // q(...)
2269− {
2270− pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
2271− greedy: true
2272− },
2273−
2274− // q{...}
2275− {
2276− pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
2277− greedy: true
2278− },
2279−
2280− // q[...]
2281− {
2282− pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
2283− greedy: true
2284− },
2285−
2286− // q<...>
2287− {
2288− pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
2289− greedy: true
2290− },
2291−
2292− // "...", `...`
2293− {
2294− pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2295− greedy: true
2296− },
2297−
2298− // '...'
2299− // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
2300− {
2301− pattern: /'(?:[^'\\\r\n]|\\.)*'/,
2302− greedy: true
2303− }
2304− ],
2305− 'regex': [
2306− // m/.../
2307− {
2308− pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
2309− greedy: true
2310− },
2311−
2312− // m a...a
2313− {
2314− pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
2315− greedy: true
2316− },
2317−
2318− // m(...)
2319− {
2320− pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
2321− greedy: true
2322− },
2323−
2324− // m{...}
2325− {
2326− pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
2327− greedy: true
2328− },
2329−
2330− // m[...]
2331− {
2332− pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
2333− greedy: true
2334− },
2335−
2336− // m<...>
2337− {
2338− pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
2339− greedy: true
2340− },
2341−
2342− // The lookbehinds prevent -s from breaking
2343− // FIXME We don't handle change of separator like s(...)[...]
2344− // s/.../.../
2345− {
2346− pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
2347− lookbehind: true,
2348− greedy: true
2349− },
2350−
2351− // s a...a...a
2352− {
2353− pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
2354− lookbehind: true,
2355− greedy: true
2356− },
2357−
2358− // s(...)(...)
2359− {
2360− pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
2361− lookbehind: true,
2362− greedy: true
2363− },
2364−
2365− // s{...}{...}
2366− {
2367− pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
2368− lookbehind: true,
2369− greedy: true
2370− },
2371−
2372− // s[...][...]
2373− {
2374− pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
2375− lookbehind: true,
2376− greedy: true
2377− },
2378−
2379− // s<...><...>
2380− {
2381− pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
2382− lookbehind: true,
2383− greedy: true
2384− },
2385−
2386− // /.../
2387− // The look-ahead tries to prevent two divisions on
2388− // the same line from being highlighted as regex.
2389− // This does not support multi-line regex.
2390− {
2391− pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
2392− greedy: true
2393− }
2394− ],
2395−
2396− // FIXME Not sure about the handling of ::, ', and #
2397− 'variable': [
2398− // ${^POSTMATCH}
2399− /[&*$@%]\{\^[A-Z]+\}/,
2400− // $^V
2401− /[&*$@%]\^[A-Z_]/,
2402− // ${...}
2403− /[&*$@%]#?(?=\{)/,
2404− // $foo
2405− /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
2406− // $1
2407− /[&*$@%]\d+/,
2408− // $_, @_, %!
2409− // The negative lookahead prevents from breaking the %= operator
2410− /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
2411− ],
2412− 'filehandle': {
2413− // <>, <FOO>, _
2414− pattern: /<(?![<=])\S*>|\b_\b/,
2415− alias: 'symbol'
2416− },
2417− 'vstring': {
2418− // v1.2, 1.2.3
2419− pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
2420− alias: 'string'
2421− },
2422− 'function': {
2423− pattern: /sub [a-z0-9_]+/i,
2424− inside: {
2425− keyword: /sub/
2426− }
2427− },
2428− 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
2429− 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
2430− 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
2431− 'punctuation': /[{}[\];(),:]/
2243+ 'comment': [
2244+ {
2245+ // POD
2246+ pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
2247+ lookbehind: true
2248+ },
2249+ {
2250+ pattern: /(^|[^\\$])#.*/,
2251+ lookbehind: true
2252+ }
2253+ ],
2254+ // TODO Could be nice to handle Heredoc too.
2255+ 'string': [
2256+ // q/.../
2257+ {
2258+ pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2259+ greedy: true
2260+ },
2261+
2262+ // q a...a
2263+ {
2264+ pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2265+ greedy: true
2266+ },
2267+
2268+ // q(...)
2269+ {
2270+ pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
2271+ greedy: true
2272+ },
2273+
2274+ // q{...}
2275+ {
2276+ pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
2277+ greedy: true
2278+ },
2279+
2280+ // q[...]
2281+ {
2282+ pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
2283+ greedy: true
2284+ },
2285+
2286+ // q<...>
2287+ {
2288+ pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
2289+ greedy: true
2290+ },
2291+
2292+ // "...", `...`
2293+ {
2294+ pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
2295+ greedy: true
2296+ },
2297+
2298+ // '...'
2299+ // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
2300+ {
2301+ pattern: /'(?:[^'\\\r\n]|\\.)*'/,
2302+ greedy: true
2303+ }
2304+ ],
2305+ 'regex': [
2306+ // m/.../
2307+ {
2308+ pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
2309+ greedy: true
2310+ },
2311+
2312+ // m a...a
2313+ {
2314+ pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
2315+ greedy: true
2316+ },
2317+
2318+ // m(...)
2319+ {
2320+ pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
2321+ greedy: true
2322+ },
2323+
2324+ // m{...}
2325+ {
2326+ pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
2327+ greedy: true
2328+ },
2329+
2330+ // m[...]
2331+ {
2332+ pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
2333+ greedy: true
2334+ },
2335+
2336+ // m<...>
2337+ {
2338+ pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
2339+ greedy: true
2340+ },
2341+
2342+ // The lookbehinds prevent -s from breaking
2343+ // FIXME We don't handle change of separator like s(...)[...]
2344+ // s/.../.../
2345+ {
2346+ pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
2347+ lookbehind: true,
2348+ greedy: true
2349+ },
2350+
2351+ // s a...a...a
2352+ {
2353+ pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
2354+ lookbehind: true,
2355+ greedy: true
2356+ },
2357+
2358+ // s(...)(...)
2359+ {
2360+ pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
2361+ lookbehind: true,
2362+ greedy: true
2363+ },
2364+
2365+ // s{...}{...}
2366+ {
2367+ pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
2368+ lookbehind: true,
2369+ greedy: true
2370+ },
2371+
2372+ // s[...][...]
2373+ {
2374+ pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
2375+ lookbehind: true,
2376+ greedy: true
2377+ },
2378+
2379+ // s<...><...>
2380+ {
2381+ pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
2382+ lookbehind: true,
2383+ greedy: true
2384+ },
2385+
2386+ // /.../
2387+ // The look-ahead tries to prevent two divisions on
2388+ // the same line from being highlighted as regex.
2389+ // This does not support multi-line regex.
2390+ {
2391+ pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
2392+ greedy: true
2393+ }
2394+ ],
2395+
2396+ // FIXME Not sure about the handling of ::, ', and #
2397+ 'variable': [
2398+ // ${^POSTMATCH}
2399+ /[&*$@%]\{\^[A-Z]+\}/,
2400+ // $^V
2401+ /[&*$@%]\^[A-Z_]/,
2402+ // ${...}
2403+ /[&*$@%]#?(?=\{)/,
2404+ // $foo
2405+ /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
2406+ // $1
2407+ /[&*$@%]\d+/,
2408+ // $_, @_, %!
2409+ // The negative lookahead prevents from breaking the %= operator
2410+ /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
2411+ ],
2412+ 'filehandle': {
2413+ // <>, <FOO>, _
2414+ pattern: /<(?![<=])\S*>|\b_\b/,
2415+ alias: 'symbol'
2416+ },
2417+ 'vstring': {
2418+ // v1.2, 1.2.3
2419+ pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
2420+ alias: 'string'
2421+ },
2422+ 'function': {
2423+ pattern: /sub [a-z0-9_]+/i,
2424+ inside: {
2425+ keyword: /sub/
2426+ }
2427+ },
2428+ 'keyword': /\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
2429+ 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
2430+ 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
2431+ 'punctuation': /[{}[\];(),:]/
24322432 };
24332433
24342434 Prism.languages.sql = {
2435− 'comment': {
2436− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2437− lookbehind: true
2438− },
2439− 'variable': [
2440− {
2441− pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2442− greedy: true
2443− },
2444− /@[\w.$]+/
2445− ],
2446− 'string': {
2447− pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
2448− greedy: true,
2449− lookbehind: true
2450− },
2451− 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
2452− 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
2453− 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2454− 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
2455− 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2456− 'punctuation': /[;[\]()`,.]/
2435+ 'comment': {
2436+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2437+ lookbehind: true
2438+ },
2439+ 'variable': [
2440+ {
2441+ pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2442+ greedy: true
2443+ },
2444+ /@[\w.$]+/
2445+ ],
2446+ 'string': {
2447+ pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
2448+ greedy: true,
2449+ lookbehind: true
2450+ },
2451+ 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
2452+ 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
2453+ 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2454+ 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
2455+ 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2456+ 'punctuation': /[;[\]()`,.]/
24572457 };
24582458
24592459 Prism.languages.scss = Prism.languages.extend('css', {
2460− 'comment': {
2461− pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2462− lookbehind: true
2463− },
2464− 'atrule': {
2465− pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
2466− inside: {
2467− 'rule': /@[\w-]+/
2468− // See rest below
2469− }
2470− },
2471− // url, compassified
2472− 'url': /(?:[-a-z]+-)?url(?=\()/i,
2473− // CSS selector regex is not appropriate for Sass
2474− // since there can be lot more things (var, @ directive, nesting..)
2475− // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2476− // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2477− // 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
2478− // can "pass" as a selector- e.g: proper#{$erty})
2479− // this one was hard to do, so please be careful if you edit this one :)
2480− 'selector': {
2481− // Initial look-ahead is used to prevent matching of blank selectors
2482− pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
2483− inside: {
2484− 'parent': {
2485− pattern: /&/,
2486− alias: 'important'
2487− },
2488− 'placeholder': /%[-\w]+/,
2489− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2490− }
2491− },
2492− 'property': {
2493− pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
2494− inside: {
2495− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2496− }
2497− }
2460+ 'comment': {
2461+ pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2462+ lookbehind: true
2463+ },
2464+ 'atrule': {
2465+ pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
2466+ inside: {
2467+ 'rule': /@[\w-]+/
2468+ // See rest below
2469+ }
2470+ },
2471+ // url, compassified
2472+ 'url': /(?:[-a-z]+-)?url(?=\()/i,
2473+ // CSS selector regex is not appropriate for Sass
2474+ // since there can be lot more things (var, @ directive, nesting..)
2475+ // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2476+ // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2477+ // 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
2478+ // can "pass" as a selector- e.g: proper#{$erty})
2479+ // this one was hard to do, so please be careful if you edit this one :)
2480+ 'selector': {
2481+ // Initial look-ahead is used to prevent matching of blank selectors
2482+ pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
2483+ inside: {
2484+ 'parent': {
2485+ pattern: /&/,
2486+ alias: 'important'
2487+ },
2488+ 'placeholder': /%[-\w]+/,
2489+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2490+ }
2491+ },
2492+ 'property': {
2493+ pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
2494+ inside: {
2495+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2496+ }
2497+ }
24982498 });
24992499
25002500 Prism.languages.insertBefore('scss', 'atrule', {
2501− 'keyword': [
2502− /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2503− {
2504− pattern: /( +)(?:from|through)(?= )/,
2505− lookbehind: true
2506− }
2507− ]
2501+ 'keyword': [
2502+ /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2503+ {
2504+ pattern: /( +)(?:from|through)(?= )/,
2505+ lookbehind: true
2506+ }
2507+ ]
25082508 });
25092509
25102510 Prism.languages.insertBefore('scss', 'important', {
2511− // var and interpolated vars
2512− 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2511+ // var and interpolated vars
2512+ 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
25132513 });
25142514
25152515 Prism.languages.insertBefore('scss', 'function', {
2516− 'placeholder': {
2517− pattern: /%[-\w]+/,
2518− alias: 'selector'
2519− },
2520− 'statement': {
2521− pattern: /\B!(?:default|optional)\b/i,
2522− alias: 'keyword'
2523− },
2524− 'boolean': /\b(?:true|false)\b/,
2525− 'null': {
2526− pattern: /\bnull\b/,
2527− alias: 'keyword'
2528− },
2529− 'operator': {
2530− pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2531− lookbehind: true
2532− }
2516+ 'placeholder': {
2517+ pattern: /%[-\w]+/,
2518+ alias: 'selector'
2519+ },
2520+ 'statement': {
2521+ pattern: /\B!(?:default|optional)\b/i,
2522+ alias: 'keyword'
2523+ },
2524+ 'boolean': /\b(?:true|false)\b/,
2525+ 'null': {
2526+ pattern: /\bnull\b/,
2527+ alias: 'keyword'
2528+ },
2529+ 'operator': {
2530+ pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2531+ lookbehind: true
2532+ }
25332533 });
25342534
25352535 Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
25362536
25372537 Prism.languages.python = {
2538− 'comment': {
2539− pattern: /(^|[^\\])#.*/,
2540− lookbehind: true
2541− },
2542− 'string-interpolation': {
2543− pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2544− greedy: true,
2545− inside: {
2546− 'interpolation': {
2547− // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2548− pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
2549− lookbehind: true,
2550− inside: {
2551− 'format-spec': {
2552− pattern: /(:)[^:(){}]+(?=}$)/,
2553− lookbehind: true
2554− },
2555− 'conversion-option': {
2556− pattern: /![sra](?=[:}]$)/,
2557− alias: 'punctuation'
2558− },
2559− rest: null
2560− }
2561− },
2562− 'string': /[\s\S]+/
2563− }
2564− },
2565− 'triple-quoted-string': {
2566− pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
2567− greedy: true,
2568− alias: 'string'
2569− },
2570− 'string': {
2571− pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2572− greedy: true
2573− },
2574− 'function': {
2575− pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2576− lookbehind: true
2577− },
2578− 'class-name': {
2579− pattern: /(\bclass\s+)\w+/i,
2580− lookbehind: true
2581− },
2582− 'decorator': {
2583− pattern: /(^\s*)@\w+(?:\.\w+)*/i,
2584− lookbehind: true,
2585− alias: ['annotation', 'punctuation'],
2586− inside: {
2587− 'punctuation': /\./
2588− }
2589− },
2590− 'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
2591− 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
2592− 'boolean': /\b(?:True|False|None)\b/,
2593− 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
2594− 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2595− 'punctuation': /[{}[\];(),.:]/
2538+ 'comment': {
2539+ pattern: /(^|[^\\])#.*/,
2540+ lookbehind: true
2541+ },
2542+ 'string-interpolation': {
2543+ pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
2544+ greedy: true,
2545+ inside: {
2546+ 'interpolation': {
2547+ // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
2548+ pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
2549+ lookbehind: true,
2550+ inside: {
2551+ 'format-spec': {
2552+ pattern: /(:)[^:(){}]+(?=}$)/,
2553+ lookbehind: true
2554+ },
2555+ 'conversion-option': {
2556+ pattern: /![sra](?=[:}]$)/,
2557+ alias: 'punctuation'
2558+ },
2559+ rest: null
2560+ }
2561+ },
2562+ 'string': /[\s\S]+/
2563+ }
2564+ },
2565+ 'triple-quoted-string': {
2566+ pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
2567+ greedy: true,
2568+ alias: 'string'
2569+ },
2570+ 'string': {
2571+ pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
2572+ greedy: true
2573+ },
2574+ 'function': {
2575+ pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
2576+ lookbehind: true
2577+ },
2578+ 'class-name': {
2579+ pattern: /(\bclass\s+)\w+/i,
2580+ lookbehind: true
2581+ },
2582+ 'decorator': {
2583+ pattern: /(^\s*)@\w+(?:\.\w+)*/i,
2584+ lookbehind: true,
2585+ alias: ['annotation', 'punctuation'],
2586+ inside: {
2587+ 'punctuation': /\./
2588+ }
2589+ },
2590+ 'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
2591+ 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
2592+ 'boolean': /\b(?:True|False|None)\b/,
2593+ 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
2594+ 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
2595+ 'punctuation': /[{}[\];(),.:]/
25962596 };
25972597
25982598 Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
@@ -2600,128 +2600,128 @@ Prism.languages.python['string-interpolation'].inside['interpolation'].inside.re · 1 unmodified line
26002600 Prism.languages.py = Prism.languages.python;
26012601 (function(Prism) {
26022602
2603−var javascript = Prism.util.clone(Prism.languages.javascript);
2604−
2605−Prism.languages.jsx = Prism.languages.extend('markup', javascript);
2606−Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
2607−
2608−Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
2609−Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
2610−Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
2611−
2612−Prism.languages.insertBefore('inside', 'attr-name', {
2613− 'spread': {
2614− pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
2615− inside: {
2616− 'punctuation': /\.{3}|[{}.]/,
2617− 'attr-value': /\w+/
2618− }
2619− }
2620−}, Prism.languages.jsx.tag);
2621−
2622−Prism.languages.insertBefore('inside', 'attr-value',{
2623− 'script': {
2624− // Allow for two levels of nesting
2625− pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
2626− inside: {
2627− 'script-punctuation': {
2628− pattern: /^=(?={)/,
2629− alias: 'punctuation'
2630− },
2631− rest: Prism.languages.jsx
2632− },
2633− 'alias': 'language-javascript'
2634− }
2635−}, Prism.languages.jsx.tag);
2603+ var javascript = Prism.util.clone(Prism.languages.javascript);
2604+
2605+ Prism.languages.jsx = Prism.languages.extend('markup', javascript);
2606+ Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
2607+
2608+ Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
2609+ Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
2610+ Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
2611+
2612+ Prism.languages.insertBefore('inside', 'attr-name', {
2613+ 'spread': {
2614+ pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
2615+ inside: {
2616+ 'punctuation': /\.{3}|[{}.]/,
2617+ 'attr-value': /\w+/
2618+ }
2619+ }
2620+ }, Prism.languages.jsx.tag);
2621+
2622+ Prism.languages.insertBefore('inside', 'attr-value',{
2623+ 'script': {
2624+ // Allow for two levels of nesting
2625+ pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
2626+ inside: {
2627+ 'script-punctuation': {
2628+ pattern: /^=(?={)/,
2629+ alias: 'punctuation'
2630+ },
2631+ rest: Prism.languages.jsx
2632+ },
2633+ 'alias': 'language-javascript'
2634+ }

394 more lines aren’t shown here.