written 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/written/app/assets/javascripts/written/core/content.coffee +41 -10
- data/lib/written/app/assets/javascripts/written/core/cursor.coffee +5 -5
- data/lib/written/app/assets/javascripts/written/core/document.coffee +2 -1
- data/lib/written/app/assets/javascripts/written/core/history.coffee +23 -10
- data/lib/written/app/assets/javascripts/written/parsers/block/code.coffee +3 -2
- data/lib/written/app/assets/javascripts/written/parsers/parsers.coffee +15 -0
- data/lib/written/app/assets/javascripts/written.coffee +0 -2
- data/lib/written/version.rb +1 -1
- data/test/server/app/assets/javascripts/application.coffee +4 -0
- data/test/server/app/assets/javascripts/prism.js +26 -0
- data/test/server/app/assets/stylesheets/application.scss +1 -0
- data/test/server/app/assets/stylesheets/prism.css +179 -0
- data/test/server/app/views/posts/show.html.erb +4 -1
- metadata +3 -4
- data/lib/written/app/assets/javascripts/vendors/prism.js +0 -1411
- data/lib/written/app/assets/javascripts/written/extensions/clipboard.coffee +0 -114
- data/lib/written/app/assets/javascripts/written/extensions/image.coffee +0 -91
@@ -1,1411 +0,0 @@
|
|
1
|
-
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+apacheconf+bash+c+csharp+cpp+ruby+git+go+haml+http+java+nginx+objectivec+php+python+scss */
|
2
|
-
var _self = (typeof window !== 'undefined')
|
3
|
-
? window // if in browser
|
4
|
-
: (
|
5
|
-
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
6
|
-
? self // if in worker
|
7
|
-
: {} // if in node js
|
8
|
-
);
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Prism: Lightweight, robust, elegant syntax highlighting
|
12
|
-
* MIT license http://www.opensource.org/licenses/mit-license.php/
|
13
|
-
* @author Lea Verou http://lea.verou.me
|
14
|
-
*/
|
15
|
-
|
16
|
-
var Prism = (function(){
|
17
|
-
|
18
|
-
// Private helper vars
|
19
|
-
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
20
|
-
|
21
|
-
var _ = _self.Prism = {
|
22
|
-
util: {
|
23
|
-
encode: function (tokens) {
|
24
|
-
if (tokens instanceof Token) {
|
25
|
-
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
|
26
|
-
} else if (_.util.type(tokens) === 'Array') {
|
27
|
-
return tokens.map(_.util.encode);
|
28
|
-
} else {
|
29
|
-
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
30
|
-
}
|
31
|
-
},
|
32
|
-
|
33
|
-
type: function (o) {
|
34
|
-
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
35
|
-
},
|
36
|
-
|
37
|
-
// Deep clone a language definition (e.g. to extend it)
|
38
|
-
clone: function (o) {
|
39
|
-
var type = _.util.type(o);
|
40
|
-
|
41
|
-
switch (type) {
|
42
|
-
case 'Object':
|
43
|
-
var clone = {};
|
44
|
-
|
45
|
-
for (var key in o) {
|
46
|
-
if (o.hasOwnProperty(key)) {
|
47
|
-
clone[key] = _.util.clone(o[key]);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
return clone;
|
52
|
-
|
53
|
-
case 'Array':
|
54
|
-
// Check for existence for IE8
|
55
|
-
return o.map && o.map(function(v) { return _.util.clone(v); });
|
56
|
-
}
|
57
|
-
|
58
|
-
return o;
|
59
|
-
}
|
60
|
-
},
|
61
|
-
|
62
|
-
languages: {
|
63
|
-
extend: function (id, redef) {
|
64
|
-
var lang = _.util.clone(_.languages[id]);
|
65
|
-
|
66
|
-
for (var key in redef) {
|
67
|
-
lang[key] = redef[key];
|
68
|
-
}
|
69
|
-
|
70
|
-
return lang;
|
71
|
-
},
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Insert a token before another token in a language literal
|
75
|
-
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
|
76
|
-
* we cannot just provide an object, we need anobject and a key.
|
77
|
-
* @param inside The key (or language id) of the parent
|
78
|
-
* @param before The key to insert before. If not provided, the function appends instead.
|
79
|
-
* @param insert Object with the key/value pairs to insert
|
80
|
-
* @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
|
81
|
-
*/
|
82
|
-
insertBefore: function (inside, before, insert, root) {
|
83
|
-
root = root || _.languages;
|
84
|
-
var grammar = root[inside];
|
85
|
-
|
86
|
-
if (arguments.length == 2) {
|
87
|
-
insert = arguments[1];
|
88
|
-
|
89
|
-
for (var newToken in insert) {
|
90
|
-
if (insert.hasOwnProperty(newToken)) {
|
91
|
-
grammar[newToken] = insert[newToken];
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
return grammar;
|
96
|
-
}
|
97
|
-
|
98
|
-
var ret = {};
|
99
|
-
|
100
|
-
for (var token in grammar) {
|
101
|
-
|
102
|
-
if (grammar.hasOwnProperty(token)) {
|
103
|
-
|
104
|
-
if (token == before) {
|
105
|
-
|
106
|
-
for (var newToken in insert) {
|
107
|
-
|
108
|
-
if (insert.hasOwnProperty(newToken)) {
|
109
|
-
ret[newToken] = insert[newToken];
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
ret[token] = grammar[token];
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
// Update references in other language definitions
|
119
|
-
_.languages.DFS(_.languages, function(key, value) {
|
120
|
-
if (value === root[inside] && key != inside) {
|
121
|
-
this[key] = ret;
|
122
|
-
}
|
123
|
-
});
|
124
|
-
|
125
|
-
return root[inside] = ret;
|
126
|
-
},
|
127
|
-
|
128
|
-
// Traverse a language definition with Depth First Search
|
129
|
-
DFS: function(o, callback, type) {
|
130
|
-
for (var i in o) {
|
131
|
-
if (o.hasOwnProperty(i)) {
|
132
|
-
callback.call(o, i, o[i], type || i);
|
133
|
-
|
134
|
-
if (_.util.type(o[i]) === 'Object') {
|
135
|
-
_.languages.DFS(o[i], callback);
|
136
|
-
}
|
137
|
-
else if (_.util.type(o[i]) === 'Array') {
|
138
|
-
_.languages.DFS(o[i], callback, i);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
}
|
142
|
-
}
|
143
|
-
},
|
144
|
-
plugins: {},
|
145
|
-
|
146
|
-
highlightAll: function(async, callback) {
|
147
|
-
var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
|
148
|
-
|
149
|
-
for (var i=0, element; element = elements[i++];) {
|
150
|
-
_.highlightElement(element, async === true, callback);
|
151
|
-
}
|
152
|
-
},
|
153
|
-
|
154
|
-
highlightElement: function(element, async, callback) {
|
155
|
-
// Find language
|
156
|
-
var language, grammar, parent = element;
|
157
|
-
|
158
|
-
while (parent && !lang.test(parent.className)) {
|
159
|
-
parent = parent.parentNode;
|
160
|
-
}
|
161
|
-
|
162
|
-
if (parent) {
|
163
|
-
language = (parent.className.match(lang) || [,''])[1];
|
164
|
-
grammar = _.languages[language];
|
165
|
-
}
|
166
|
-
|
167
|
-
// Set language on the element, if not present
|
168
|
-
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
169
|
-
|
170
|
-
// Set language on the parent, for styling
|
171
|
-
parent = element.parentNode;
|
172
|
-
|
173
|
-
if (/pre/i.test(parent.nodeName)) {
|
174
|
-
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
175
|
-
}
|
176
|
-
|
177
|
-
var code = element.textContent;
|
178
|
-
|
179
|
-
var env = {
|
180
|
-
element: element,
|
181
|
-
language: language,
|
182
|
-
grammar: grammar,
|
183
|
-
code: code
|
184
|
-
};
|
185
|
-
|
186
|
-
if (!code || !grammar) {
|
187
|
-
_.hooks.run('complete', env);
|
188
|
-
return;
|
189
|
-
}
|
190
|
-
|
191
|
-
_.hooks.run('before-highlight', env);
|
192
|
-
|
193
|
-
if (async && _self.Worker) {
|
194
|
-
var worker = new Worker(_.filename);
|
195
|
-
|
196
|
-
worker.onmessage = function(evt) {
|
197
|
-
env.highlightedCode = evt.data;
|
198
|
-
|
199
|
-
_.hooks.run('before-insert', env);
|
200
|
-
|
201
|
-
env.element.innerHTML = env.highlightedCode;
|
202
|
-
|
203
|
-
callback && callback.call(env.element);
|
204
|
-
_.hooks.run('after-highlight', env);
|
205
|
-
_.hooks.run('complete', env);
|
206
|
-
};
|
207
|
-
|
208
|
-
worker.postMessage(JSON.stringify({
|
209
|
-
language: env.language,
|
210
|
-
code: env.code,
|
211
|
-
immediateClose: true
|
212
|
-
}));
|
213
|
-
}
|
214
|
-
else {
|
215
|
-
env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
|
216
|
-
|
217
|
-
_.hooks.run('before-insert', env);
|
218
|
-
|
219
|
-
env.element.innerHTML = env.highlightedCode;
|
220
|
-
|
221
|
-
callback && callback.call(element);
|
222
|
-
|
223
|
-
_.hooks.run('after-highlight', env);
|
224
|
-
_.hooks.run('complete', env);
|
225
|
-
}
|
226
|
-
},
|
227
|
-
|
228
|
-
highlight: function (text, grammar, language) {
|
229
|
-
var tokens = _.tokenize(text, grammar);
|
230
|
-
return Token.stringify(_.util.encode(tokens), language);
|
231
|
-
},
|
232
|
-
|
233
|
-
tokenize: function(text, grammar, language) {
|
234
|
-
var Token = _.Token;
|
235
|
-
|
236
|
-
var strarr = [text];
|
237
|
-
|
238
|
-
var rest = grammar.rest;
|
239
|
-
|
240
|
-
if (rest) {
|
241
|
-
for (var token in rest) {
|
242
|
-
grammar[token] = rest[token];
|
243
|
-
}
|
244
|
-
|
245
|
-
delete grammar.rest;
|
246
|
-
}
|
247
|
-
|
248
|
-
tokenloop: for (var token in grammar) {
|
249
|
-
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
|
250
|
-
continue;
|
251
|
-
}
|
252
|
-
|
253
|
-
var patterns = grammar[token];
|
254
|
-
patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
|
255
|
-
|
256
|
-
for (var j = 0; j < patterns.length; ++j) {
|
257
|
-
var pattern = patterns[j],
|
258
|
-
inside = pattern.inside,
|
259
|
-
lookbehind = !!pattern.lookbehind,
|
260
|
-
lookbehindLength = 0,
|
261
|
-
alias = pattern.alias;
|
262
|
-
|
263
|
-
pattern = pattern.pattern || pattern;
|
264
|
-
|
265
|
-
for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
|
266
|
-
|
267
|
-
var str = strarr[i];
|
268
|
-
|
269
|
-
if (strarr.length > text.length) {
|
270
|
-
// Something went terribly wrong, ABORT, ABORT!
|
271
|
-
break tokenloop;
|
272
|
-
}
|
273
|
-
|
274
|
-
if (str instanceof Token) {
|
275
|
-
continue;
|
276
|
-
}
|
277
|
-
|
278
|
-
pattern.lastIndex = 0;
|
279
|
-
|
280
|
-
var match = pattern.exec(str);
|
281
|
-
|
282
|
-
if (match) {
|
283
|
-
if(lookbehind) {
|
284
|
-
lookbehindLength = match[1].length;
|
285
|
-
}
|
286
|
-
|
287
|
-
var from = match.index - 1 + lookbehindLength,
|
288
|
-
match = match[0].slice(lookbehindLength),
|
289
|
-
len = match.length,
|
290
|
-
to = from + len,
|
291
|
-
before = str.slice(0, from + 1),
|
292
|
-
after = str.slice(to + 1);
|
293
|
-
|
294
|
-
var args = [i, 1];
|
295
|
-
|
296
|
-
if (before) {
|
297
|
-
args.push(before);
|
298
|
-
}
|
299
|
-
|
300
|
-
var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias);
|
301
|
-
|
302
|
-
args.push(wrapped);
|
303
|
-
|
304
|
-
if (after) {
|
305
|
-
args.push(after);
|
306
|
-
}
|
307
|
-
|
308
|
-
Array.prototype.splice.apply(strarr, args);
|
309
|
-
}
|
310
|
-
}
|
311
|
-
}
|
312
|
-
}
|
313
|
-
|
314
|
-
return strarr;
|
315
|
-
},
|
316
|
-
|
317
|
-
hooks: {
|
318
|
-
all: {},
|
319
|
-
|
320
|
-
add: function (name, callback) {
|
321
|
-
var hooks = _.hooks.all;
|
322
|
-
|
323
|
-
hooks[name] = hooks[name] || [];
|
324
|
-
|
325
|
-
hooks[name].push(callback);
|
326
|
-
},
|
327
|
-
|
328
|
-
run: function (name, env) {
|
329
|
-
var callbacks = _.hooks.all[name];
|
330
|
-
|
331
|
-
if (!callbacks || !callbacks.length) {
|
332
|
-
return;
|
333
|
-
}
|
334
|
-
|
335
|
-
for (var i=0, callback; callback = callbacks[i++];) {
|
336
|
-
callback(env);
|
337
|
-
}
|
338
|
-
}
|
339
|
-
}
|
340
|
-
};
|
341
|
-
|
342
|
-
var Token = _.Token = function(type, content, alias) {
|
343
|
-
this.type = type;
|
344
|
-
this.content = content;
|
345
|
-
this.alias = alias;
|
346
|
-
};
|
347
|
-
|
348
|
-
Token.stringify = function(o, language, parent) {
|
349
|
-
if (typeof o == 'string') {
|
350
|
-
return o;
|
351
|
-
}
|
352
|
-
|
353
|
-
if (_.util.type(o) === 'Array') {
|
354
|
-
return o.map(function(element) {
|
355
|
-
return Token.stringify(element, language, o);
|
356
|
-
}).join('');
|
357
|
-
}
|
358
|
-
|
359
|
-
var env = {
|
360
|
-
type: o.type,
|
361
|
-
content: Token.stringify(o.content, language, parent),
|
362
|
-
tag: 'span',
|
363
|
-
classes: ['token', o.type],
|
364
|
-
attributes: {},
|
365
|
-
language: language,
|
366
|
-
parent: parent
|
367
|
-
};
|
368
|
-
|
369
|
-
if (env.type == 'comment') {
|
370
|
-
env.attributes['spellcheck'] = 'true';
|
371
|
-
}
|
372
|
-
|
373
|
-
if (o.alias) {
|
374
|
-
var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
|
375
|
-
Array.prototype.push.apply(env.classes, aliases);
|
376
|
-
}
|
377
|
-
|
378
|
-
_.hooks.run('wrap', env);
|
379
|
-
|
380
|
-
var attributes = '';
|
381
|
-
|
382
|
-
for (var name in env.attributes) {
|
383
|
-
attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
|
384
|
-
}
|
385
|
-
|
386
|
-
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
|
387
|
-
|
388
|
-
};
|
389
|
-
|
390
|
-
if (!_self.document) {
|
391
|
-
if (!_self.addEventListener) {
|
392
|
-
// in Node.js
|
393
|
-
return _self.Prism;
|
394
|
-
}
|
395
|
-
// In worker
|
396
|
-
_self.addEventListener('message', function(evt) {
|
397
|
-
var message = JSON.parse(evt.data),
|
398
|
-
lang = message.language,
|
399
|
-
code = message.code,
|
400
|
-
immediateClose = message.immediateClose;
|
401
|
-
|
402
|
-
_self.postMessage(_.highlight(code, _.languages[lang], lang));
|
403
|
-
if (immediateClose) {
|
404
|
-
_self.close();
|
405
|
-
}
|
406
|
-
}, false);
|
407
|
-
|
408
|
-
return _self.Prism;
|
409
|
-
}
|
410
|
-
|
411
|
-
// Get current script and highlight
|
412
|
-
var script = document.getElementsByTagName('script');
|
413
|
-
|
414
|
-
script = script[script.length - 1];
|
415
|
-
|
416
|
-
if (script) {
|
417
|
-
_.filename = script.src;
|
418
|
-
|
419
|
-
if (document.addEventListener && !script.hasAttribute('data-manual')) {
|
420
|
-
document.addEventListener('DOMContentLoaded', _.highlightAll);
|
421
|
-
}
|
422
|
-
}
|
423
|
-
|
424
|
-
return _self.Prism;
|
425
|
-
|
426
|
-
})();
|
427
|
-
|
428
|
-
if (typeof module !== 'undefined' && module.exports) {
|
429
|
-
module.exports = Prism;
|
430
|
-
}
|
431
|
-
|
432
|
-
// hack for components to work correctly in node.js
|
433
|
-
if (typeof global !== 'undefined') {
|
434
|
-
global.Prism = Prism;
|
435
|
-
}
|
436
|
-
;
|
437
|
-
Prism.languages.markup = {
|
438
|
-
'comment': /<!--[\w\W]*?-->/,
|
439
|
-
'prolog': /<\?[\w\W]+?\?>/,
|
440
|
-
'doctype': /<!DOCTYPE[\w\W]+?>/,
|
441
|
-
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
|
442
|
-
'tag': {
|
443
|
-
pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
|
444
|
-
inside: {
|
445
|
-
'tag': {
|
446
|
-
pattern: /^<\/?[^\s>\/]+/i,
|
447
|
-
inside: {
|
448
|
-
'punctuation': /^<\/?/,
|
449
|
-
'namespace': /^[^\s>\/:]+:/
|
450
|
-
}
|
451
|
-
},
|
452
|
-
'attr-value': {
|
453
|
-
pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
|
454
|
-
inside: {
|
455
|
-
'punctuation': /[=>"']/
|
456
|
-
}
|
457
|
-
},
|
458
|
-
'punctuation': /\/?>/,
|
459
|
-
'attr-name': {
|
460
|
-
pattern: /[^\s>\/]+/,
|
461
|
-
inside: {
|
462
|
-
'namespace': /^[^\s>\/:]+:/
|
463
|
-
}
|
464
|
-
}
|
465
|
-
|
466
|
-
}
|
467
|
-
},
|
468
|
-
'entity': /&#?[\da-z]{1,8};/i
|
469
|
-
};
|
470
|
-
|
471
|
-
// Plugin to make entity title show the real entity, idea by Roman Komarov
|
472
|
-
Prism.hooks.add('wrap', function(env) {
|
473
|
-
|
474
|
-
if (env.type === 'entity') {
|
475
|
-
env.attributes['title'] = env.content.replace(/&/, '&');
|
476
|
-
}
|
477
|
-
});
|
478
|
-
|
479
|
-
Prism.languages.xml = Prism.languages.markup;
|
480
|
-
Prism.languages.html = Prism.languages.markup;
|
481
|
-
Prism.languages.mathml = Prism.languages.markup;
|
482
|
-
Prism.languages.svg = Prism.languages.markup;
|
483
|
-
|
484
|
-
Prism.languages.css = {
|
485
|
-
'comment': /\/\*[\w\W]*?\*\//,
|
486
|
-
'atrule': {
|
487
|
-
pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
|
488
|
-
inside: {
|
489
|
-
'rule': /@[\w-]+/
|
490
|
-
// See rest below
|
491
|
-
}
|
492
|
-
},
|
493
|
-
'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
|
494
|
-
'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
|
495
|
-
'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
|
496
|
-
'property': /(\b|\B)[\w-]+(?=\s*:)/i,
|
497
|
-
'important': /\B!important\b/i,
|
498
|
-
'function': /[-a-z0-9]+(?=\()/i,
|
499
|
-
'punctuation': /[(){};:]/
|
500
|
-
};
|
501
|
-
|
502
|
-
Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
|
503
|
-
|
504
|
-
if (Prism.languages.markup) {
|
505
|
-
Prism.languages.insertBefore('markup', 'tag', {
|
506
|
-
'style': {
|
507
|
-
pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
|
508
|
-
lookbehind: true,
|
509
|
-
inside: Prism.languages.css,
|
510
|
-
alias: 'language-css'
|
511
|
-
}
|
512
|
-
});
|
513
|
-
|
514
|
-
Prism.languages.insertBefore('inside', 'attr-value', {
|
515
|
-
'style-attr': {
|
516
|
-
pattern: /\s*style=("|').*?\1/i,
|
517
|
-
inside: {
|
518
|
-
'attr-name': {
|
519
|
-
pattern: /^\s*style/i,
|
520
|
-
inside: Prism.languages.markup.tag.inside
|
521
|
-
},
|
522
|
-
'punctuation': /^\s*=\s*['"]|['"]\s*$/,
|
523
|
-
'attr-value': {
|
524
|
-
pattern: /.+/i,
|
525
|
-
inside: Prism.languages.css
|
526
|
-
}
|
527
|
-
},
|
528
|
-
alias: 'language-css'
|
529
|
-
}
|
530
|
-
}, Prism.languages.markup.tag);
|
531
|
-
};
|
532
|
-
Prism.languages.clike = {
|
533
|
-
'comment': [
|
534
|
-
{
|
535
|
-
pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
|
536
|
-
lookbehind: true
|
537
|
-
},
|
538
|
-
{
|
539
|
-
pattern: /(^|[^\\:])\/\/.*/,
|
540
|
-
lookbehind: true
|
541
|
-
}
|
542
|
-
],
|
543
|
-
'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
544
|
-
'class-name': {
|
545
|
-
pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
|
546
|
-
lookbehind: true,
|
547
|
-
inside: {
|
548
|
-
punctuation: /(\.|\\)/
|
549
|
-
}
|
550
|
-
},
|
551
|
-
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
552
|
-
'boolean': /\b(true|false)\b/,
|
553
|
-
'function': /[a-z0-9_]+(?=\()/i,
|
554
|
-
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
|
555
|
-
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
556
|
-
'punctuation': /[{}[\];(),.:]/
|
557
|
-
};
|
558
|
-
|
559
|
-
Prism.languages.javascript = Prism.languages.extend('clike', {
|
560
|
-
'keyword': /\b(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|var|void|while|with|yield)\b/,
|
561
|
-
'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
|
562
|
-
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
563
|
-
'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i
|
564
|
-
});
|
565
|
-
|
566
|
-
Prism.languages.insertBefore('javascript', 'keyword', {
|
567
|
-
'regex': {
|
568
|
-
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
|
569
|
-
lookbehind: true
|
570
|
-
}
|
571
|
-
});
|
572
|
-
|
573
|
-
Prism.languages.insertBefore('javascript', 'class-name', {
|
574
|
-
'template-string': {
|
575
|
-
pattern: /`(?:\\`|\\?[^`])*`/,
|
576
|
-
inside: {
|
577
|
-
'interpolation': {
|
578
|
-
pattern: /\$\{[^}]+\}/,
|
579
|
-
inside: {
|
580
|
-
'interpolation-punctuation': {
|
581
|
-
pattern: /^\$\{|\}$/,
|
582
|
-
alias: 'punctuation'
|
583
|
-
},
|
584
|
-
rest: Prism.languages.javascript
|
585
|
-
}
|
586
|
-
},
|
587
|
-
'string': /[\s\S]+/
|
588
|
-
}
|
589
|
-
}
|
590
|
-
});
|
591
|
-
|
592
|
-
if (Prism.languages.markup) {
|
593
|
-
Prism.languages.insertBefore('markup', 'tag', {
|
594
|
-
'script': {
|
595
|
-
pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
|
596
|
-
lookbehind: true,
|
597
|
-
inside: Prism.languages.javascript,
|
598
|
-
alias: 'language-javascript'
|
599
|
-
}
|
600
|
-
});
|
601
|
-
}
|
602
|
-
|
603
|
-
Prism.languages.js = Prism.languages.javascript;
|
604
|
-
Prism.languages.apacheconf = {
|
605
|
-
'comment': /#.*/,
|
606
|
-
'directive-inline': {
|
607
|
-
pattern: /^(\s*)\b(AcceptFilter|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding|AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch|Allow|AllowCONNECT|AllowEncodedSlashes|AllowMethods|AllowOverride|AllowOverrideList|Anonymous|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail|AsyncRequestWorkerFactor|AuthBasicAuthoritative|AuthBasicFake|AuthBasicProvider|AuthBasicUseDigestAlgorithm|AuthDBDUserPWQuery|AuthDBDUserRealmQuery|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm|AuthDigestDomain|AuthDigestNonceLifetime|AuthDigestProvider|AuthDigestQop|AuthDigestShmemSize|AuthFormAuthoritative|AuthFormBody|AuthFormDisableNoStore|AuthFormFakeBasicAuth|AuthFormLocation|AuthFormLoginRequiredLocation|AuthFormLoginSuccessLocation|AuthFormLogoutLocation|AuthFormMethod|AuthFormMimetype|AuthFormPassword|AuthFormProvider|AuthFormSitePassphrase|AuthFormSize|AuthFormUsername|AuthGroupFile|AuthLDAPAuthorizePrefix|AuthLDAPBindAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareAsUser|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPInitialBindAsUser|AuthLDAPInitialBindPattern|AuthLDAPMaxSubGroupDepth|AuthLDAPRemoteUserAttribute|AuthLDAPRemoteUserIsDN|AuthLDAPSearchAsUser|AuthLDAPSubGroupAttribute|AuthLDAPSubGroupClass|AuthLDAPUrl|AuthMerging|AuthName|AuthnCacheContext|AuthnCacheEnable|AuthnCacheProvideFor|AuthnCacheSOCache|AuthnCacheTimeout|AuthnzFcgiCheckAuthnProvider|AuthnzFcgiDefineProvider|AuthType|AuthUserFile|AuthzDBDLoginToReferer|AuthzDBDQuery|AuthzDBDRedirectQuery|AuthzDBMType|AuthzSendForbiddenOnFailure|BalancerGrowth|BalancerInherit|BalancerMember|BalancerPersist|BrowserMatch|BrowserMatchNoCase|BufferedLogs|BufferSize|CacheDefaultExpire|CacheDetailHeader|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheFile|CacheHeader|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheIgnoreQueryString|CacheIgnoreURLSessionIdentifiers|CacheKeyBaseURL|CacheLastModifiedFactor|CacheLock|CacheLockMaxAge|CacheLockPath|CacheMaxExpire|CacheMaxFileSize|CacheMinExpire|CacheMinFileSize|CacheNegotiatedDocs|CacheQuickHandler|CacheReadSize|CacheReadTime|CacheRoot|CacheSocache|CacheSocacheMaxSize|CacheSocacheMaxTime|CacheSocacheMinTime|CacheSocacheReadSize|CacheSocacheReadTime|CacheStaleOnError|CacheStoreExpired|CacheStoreNoStore|CacheStorePrivate|CGIDScriptTimeout|CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckCaseOnly|CheckSpelling|ChrootDir|ContentDigest|CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavGenericLockDB|DavLockDB|DavMinTimeout|DBDExptime|DBDInitSQL|DBDKeep|DBDMax|DBDMin|DBDParams|DBDPersist|DBDPrepareSQL|DBDriver|DefaultIcon|DefaultLanguage|DefaultRuntimeDir|DefaultType|Define|DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateInflateLimitRequestBody|DeflateInflateRatioBurst|DeflateInflateRatioLimit|DeflateMemLevel|DeflateWindowSize|Deny|DirectoryCheckHandler|DirectoryIndex|DirectoryIndexRedirect|DirectorySlash|DocumentRoot|DTracePrivileges|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|Error|ErrorDocument|ErrorLog|ErrorLogFormat|Example|ExpiresActive|ExpiresByType|ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FallbackResource|FileETag|FilterChain|FilterDeclare|FilterProtocol|FilterProvider|FilterTrace|ForceLanguagePriority|ForceType|ForensicLog|GprofDir|GracefulShutdownTimeout|Group|Header|HeaderName|HeartbeatAddress|HeartbeatListen|HeartbeatMaxServers|HeartbeatStorage|HeartbeatStorage|HostnameLookups|IdentityCheck|IdentityCheckTimeout|ImapBase|ImapDefault|ImapMenu|Include|IncludeOptional|IndexHeadInsert|IndexIgnore|IndexIgnoreReset|IndexOptions|IndexOrderDefault|IndexStyleSheet|InputSed|ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout|KeptBodySize|LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionPoolTTL|LDAPConnectionTimeout|LDAPLibraryDebug|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPReferralHopLimit|LDAPReferrals|LDAPRetries|LDAPRetryDelay|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTimeout|LDAPTrustedClientCert|LDAPTrustedGlobalCert|LDAPTrustedMode|LDAPVerifyServerCert|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|LogFormat|LogLevel|LogMessage|LuaAuthzProvider|LuaCodeCache|LuaHookAccessChecker|LuaHookAuthChecker|LuaHookCheckUserID|LuaHookFixups|LuaHookInsertFilter|LuaHookLog|LuaHookMapToStorage|LuaHookTranslateName|LuaHookTypeChecker|LuaInherit|LuaInputFilter|LuaMapHandler|LuaOutputFilter|LuaPackageCPath|LuaPackagePath|LuaQuickHandler|LuaRoot|LuaScope|MaxConnectionsPerChild|MaxKeepAliveRequests|MaxMemFree|MaxRangeOverlaps|MaxRangeReversals|MaxRanges|MaxRequestWorkers|MaxSpareServers|MaxSpareThreads|MaxThreads|MergeTrailers|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads|MMapFile|ModemStandard|ModMimeUsePathInfo|MultiviewsMatch|Mutex|NameVirtualHost|NoProxy|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|OutputSed|PassEnv|PidFile|PrivilegesMode|Protocol|ProtocolEcho|ProxyAddHeaders|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyExpressDBMFile|ProxyExpressDBMType|ProxyExpressEnable|ProxyFtpDirCharset|ProxyFtpEscapeWildcards|ProxyFtpListOnWildcard|ProxyHTMLBufSize|ProxyHTMLCharsetOut|ProxyHTMLDocType|ProxyHTMLEnable|ProxyHTMLEvents|ProxyHTMLExtended|ProxyHTMLFixups|ProxyHTMLInterp|ProxyHTMLLinks|ProxyHTMLMeta|ProxyHTMLStripComments|ProxyHTMLURLMap|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassInherit|ProxyPassInterpolateEnv|ProxyPassMatch|ProxyPassReverse|ProxyPassReverseCookieDomain|ProxyPassReverseCookiePath|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxySCGIInternalRedirect|ProxySCGISendfile|ProxySet|ProxySourceAddress|ProxyStatus|ProxyTimeout|ProxyVia|ReadmeName|ReceiveBufferSize|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ReflectorHeader|RemoteIPHeader|RemoteIPInternalProxy|RemoteIPInternalProxyList|RemoteIPProxiesHeader|RemoteIPTrustedProxy|RemoteIPTrustedProxyList|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader|RequestReadTimeout|Require|RewriteBase|RewriteCond|RewriteEngine|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen|SeeRequestTail|SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|Session|SessionCookieName|SessionCookieName2|SessionCookieRemove|SessionCryptoCipher|SessionCryptoDriver|SessionCryptoPassphrase|SessionCryptoPassphraseFile|SessionDBDCookieName|SessionDBDCookieName2|SessionDBDCookieRemove|SessionDBDDeleteLabel|SessionDBDInsertLabel|SessionDBDPerUser|SessionDBDSelectLabel|SessionDBDUpdateLabel|SessionEnv|SessionExclude|SessionHeader|SessionInclude|SessionMaxAge|SetEnv|SetEnvIf|SetEnvIfExpr|SetEnvIfNoCase|SetHandler|SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIETag|SSILastModified|SSILegacyExprParser|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath|SSLCADNRequestFile|SSLCADNRequestPath|SSLCARevocationCheck|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLCompression|SSLCryptoDevice|SSLEngine|SSLFIPS|SSLHonorCipherOrder|SSLInsecureRenegotiation|SSLOCSPDefaultResponder|SSLOCSPEnable|SSLOCSPOverrideResponder|SSLOCSPResponderTimeout|SSLOCSPResponseMaxAge|SSLOCSPResponseTimeSkew|SSLOCSPUseRequestNonce|SSLOpenSSLConfCmd|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationCheck|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCheckPeerCN|SSLProxyCheckPeerExpire|SSLProxyCheckPeerName|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateChainFile|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRenegBufferSize|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLSessionTicketKeyFile|SSLSRPUnknownUserSeed|SSLSRPVerifierFile|SSLStaplingCache|SSLStaplingErrorCacheTimeout|SSLStaplingFakeTryLater|SSLStaplingForceURL|SSLStaplingResponderTimeout|SSLStaplingResponseMaxAge|SSLStaplingResponseTimeSkew|SSLStaplingReturnResponderErrors|SSLStaplingStandardCacheTimeout|SSLStrictSNIVHostCheck|SSLUserName|SSLUseStapling|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|Substitute|Suexec|SuexecUserGroup|ThreadLimit|ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnDefine|UndefMacro|UnsetEnv|Use|UseCanonicalName|UseCanonicalPhysicalPort|User|UserDir|VHostCGIMode|VHostCGIPrivs|VHostGroup|VHostPrivs|VHostSecure|VHostUser|VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP|WatchdogInterval|XBitHack|xml2EncAlias|xml2EncDefault|xml2StartParse)\b/mi,
|
608
|
-
lookbehind: true,
|
609
|
-
alias: 'property'
|
610
|
-
},
|
611
|
-
'directive-block': {
|
612
|
-
pattern: /<\/?\b(AuthnProviderAlias|AuthzProviderAlias|Directory|DirectoryMatch|Else|ElseIf|Files|FilesMatch|If|IfDefine|IfModule|IfVersion|Limit|LimitExcept|Location|LocationMatch|Macro|Proxy|RequireAll|RequireAny|RequireNone|VirtualHost)\b *.*>/i,
|
613
|
-
inside: {
|
614
|
-
'directive-block': {
|
615
|
-
pattern: /^<\/?\w+/,
|
616
|
-
inside: {
|
617
|
-
'punctuation': /^<\/?/
|
618
|
-
},
|
619
|
-
alias: 'tag'
|
620
|
-
},
|
621
|
-
'directive-block-parameter': {
|
622
|
-
pattern: /.*[^>]/,
|
623
|
-
inside: {
|
624
|
-
'punctuation': /:/,
|
625
|
-
'string': {
|
626
|
-
pattern: /("|').*\1/,
|
627
|
-
inside: {
|
628
|
-
'variable': /(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/
|
629
|
-
}
|
630
|
-
}
|
631
|
-
},
|
632
|
-
alias: 'attr-value'
|
633
|
-
},
|
634
|
-
'punctuation': />/
|
635
|
-
},
|
636
|
-
alias: 'tag'
|
637
|
-
},
|
638
|
-
'directive-flags': {
|
639
|
-
pattern: /\[(\w,?)+\]/,
|
640
|
-
alias: 'keyword'
|
641
|
-
},
|
642
|
-
'string': {
|
643
|
-
pattern: /("|').*\1/,
|
644
|
-
inside: {
|
645
|
-
'variable': /(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/
|
646
|
-
}
|
647
|
-
},
|
648
|
-
'variable': /(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/,
|
649
|
-
'regex': /\^?.*\$|\^.*\$?/
|
650
|
-
};
|
651
|
-
|
652
|
-
(function(Prism) {
|
653
|
-
var insideString = {
|
654
|
-
variable: [
|
655
|
-
// Arithmetic Environment
|
656
|
-
{
|
657
|
-
pattern: /\$?\(\([\w\W]+?\)\)/,
|
658
|
-
inside: {
|
659
|
-
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
660
|
-
variable: [{
|
661
|
-
pattern: /(^\$\(\([\w\W]+)\)\)/,
|
662
|
-
lookbehind: true
|
663
|
-
},
|
664
|
-
/^\$\(\(/,
|
665
|
-
],
|
666
|
-
number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,
|
667
|
-
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
668
|
-
operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
|
669
|
-
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
670
|
-
punctuation: /\(\(?|\)\)?|,|;/
|
671
|
-
}
|
672
|
-
},
|
673
|
-
// Command Substitution
|
674
|
-
{
|
675
|
-
pattern: /\$\([^)]+\)|`[^`]+`/,
|
676
|
-
inside: {
|
677
|
-
variable: /^\$\(|^`|\)$|`$/
|
678
|
-
}
|
679
|
-
},
|
680
|
-
/\$(?:[a-z0-9_#\?\*!@]+|\{[^}]+\})/i
|
681
|
-
],
|
682
|
-
};
|
683
|
-
|
684
|
-
Prism.languages.bash = {
|
685
|
-
'shebang': {
|
686
|
-
pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,
|
687
|
-
alias: 'important'
|
688
|
-
},
|
689
|
-
'comment': {
|
690
|
-
pattern: /(^|[^"{\\])#.*/,
|
691
|
-
lookbehind: true
|
692
|
-
},
|
693
|
-
'string': [
|
694
|
-
//Support for Here-Documents https://en.wikipedia.org/wiki/Here_document
|
695
|
-
{
|
696
|
-
pattern: /((?:^|[^<])<<\s*)(?:"|')?(\w+?)(?:"|')?\s*\r?\n(?:[\s\S])*?\r?\n\2/g,
|
697
|
-
lookbehind: true,
|
698
|
-
inside: insideString
|
699
|
-
},
|
700
|
-
{
|
701
|
-
pattern: /("|')(?:\\?[\s\S])*?\1/g,
|
702
|
-
inside: insideString
|
703
|
-
}
|
704
|
-
],
|
705
|
-
'variable': insideString.variable,
|
706
|
-
// Originally based on http://ss64.com/bash/
|
707
|
-
'function': {
|
708
|
-
pattern: /(^|\s|;|\||&)(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|\s|;|\||&)/,
|
709
|
-
lookbehind: true
|
710
|
-
},
|
711
|
-
'keyword': {
|
712
|
-
pattern: /(^|\s|;|\||&)(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|\s|;|\||&)/,
|
713
|
-
lookbehind: true
|
714
|
-
},
|
715
|
-
'boolean': {
|
716
|
-
pattern: /(^|\s|;|\||&)(?:true|false)(?=$|\s|;|\||&)/,
|
717
|
-
lookbehind: true
|
718
|
-
},
|
719
|
-
'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,
|
720
|
-
'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/
|
721
|
-
};
|
722
|
-
|
723
|
-
var inside = insideString.variable[1].inside;
|
724
|
-
inside['function'] = Prism.languages.bash['function'];
|
725
|
-
inside.keyword = Prism.languages.bash.keyword;
|
726
|
-
inside.boolean = Prism.languages.bash.boolean;
|
727
|
-
inside.operator = Prism.languages.bash.operator;
|
728
|
-
inside.punctuation = Prism.languages.bash.punctuation;
|
729
|
-
})(Prism);
|
730
|
-
Prism.languages.c = Prism.languages.extend('clike', {
|
731
|
-
'keyword': /\b(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/,
|
732
|
-
'operator': /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
|
733
|
-
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
|
734
|
-
});
|
735
|
-
|
736
|
-
Prism.languages.insertBefore('c', 'string', {
|
737
|
-
'macro': {
|
738
|
-
// allow for multiline macro definitions
|
739
|
-
// spaces after the # character compile fine with gcc
|
740
|
-
pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,
|
741
|
-
lookbehind: true,
|
742
|
-
alias: 'property',
|
743
|
-
inside: {
|
744
|
-
// highlight the path of the include statement as a string
|
745
|
-
'string': {
|
746
|
-
pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,
|
747
|
-
lookbehind: true
|
748
|
-
},
|
749
|
-
// highlight macro directives as keywords
|
750
|
-
'directive': {
|
751
|
-
pattern: /(#\s*)\b(define|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
|
752
|
-
lookbehind: true,
|
753
|
-
alias: 'keyword'
|
754
|
-
}
|
755
|
-
}
|
756
|
-
},
|
757
|
-
// highlight predefined macros as constants
|
758
|
-
'constant': /\b(__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|stdin|stdout|stderr)\b/
|
759
|
-
});
|
760
|
-
|
761
|
-
delete Prism.languages.c['class-name'];
|
762
|
-
delete Prism.languages.c['boolean'];
|
763
|
-
|
764
|
-
Prism.languages.csharp = Prism.languages.extend('clike', {
|
765
|
-
'keyword': /\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,
|
766
|
-
'string': [
|
767
|
-
/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,
|
768
|
-
/("|')(\\?.)*?\1/
|
769
|
-
],
|
770
|
-
'number': /\b-?(0x[\da-f]+|\d*\.?\d+f?)\b/i
|
771
|
-
});
|
772
|
-
|
773
|
-
Prism.languages.insertBefore('csharp', 'keyword', {
|
774
|
-
'preprocessor': {
|
775
|
-
pattern: /(^\s*)#.*/m,
|
776
|
-
lookbehind: true,
|
777
|
-
alias: 'property',
|
778
|
-
inside: {
|
779
|
-
// highlight preprocessor directives as keywords
|
780
|
-
'directive': {
|
781
|
-
pattern: /(\s*#)\b(define|elif|else|endif|endregion|error|if|line|pragma|region|undef|warning)\b/,
|
782
|
-
lookbehind: true,
|
783
|
-
alias: 'keyword'
|
784
|
-
}
|
785
|
-
}
|
786
|
-
}
|
787
|
-
});
|
788
|
-
|
789
|
-
Prism.languages.cpp = Prism.languages.extend('c', {
|
790
|
-
'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|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/,
|
791
|
-
'boolean': /\b(true|false)\b/,
|
792
|
-
'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
|
793
|
-
});
|
794
|
-
|
795
|
-
Prism.languages.insertBefore('cpp', 'keyword', {
|
796
|
-
'class-name': {
|
797
|
-
pattern: /(class\s+)[a-z0-9_]+/i,
|
798
|
-
lookbehind: true
|
799
|
-
}
|
800
|
-
});
|
801
|
-
/**
|
802
|
-
* Original by Samuel Flores
|
803
|
-
*
|
804
|
-
* Adds the following new token classes:
|
805
|
-
* constant, builtin, variable, symbol, regex
|
806
|
-
*/
|
807
|
-
(function(Prism) {
|
808
|
-
Prism.languages.ruby = Prism.languages.extend('clike', {
|
809
|
-
'comment': /#(?!\{[^\r\n]*?\}).*/,
|
810
|
-
'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|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
|
811
|
-
});
|
812
|
-
|
813
|
-
var interpolation = {
|
814
|
-
pattern: /#\{[^}]+\}/,
|
815
|
-
inside: {
|
816
|
-
'delimiter': {
|
817
|
-
pattern: /^#\{|\}$/,
|
818
|
-
alias: 'tag'
|
819
|
-
},
|
820
|
-
rest: Prism.util.clone(Prism.languages.ruby)
|
821
|
-
}
|
822
|
-
};
|
823
|
-
|
824
|
-
Prism.languages.insertBefore('ruby', 'keyword', {
|
825
|
-
'regex': [
|
826
|
-
{
|
827
|
-
pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
|
828
|
-
inside: {
|
829
|
-
'interpolation': interpolation
|
830
|
-
}
|
831
|
-
},
|
832
|
-
{
|
833
|
-
pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
|
834
|
-
inside: {
|
835
|
-
'interpolation': interpolation
|
836
|
-
}
|
837
|
-
},
|
838
|
-
{
|
839
|
-
// Here we need to specifically allow interpolation
|
840
|
-
pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
|
841
|
-
inside: {
|
842
|
-
'interpolation': interpolation
|
843
|
-
}
|
844
|
-
},
|
845
|
-
{
|
846
|
-
pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
|
847
|
-
inside: {
|
848
|
-
'interpolation': interpolation
|
849
|
-
}
|
850
|
-
},
|
851
|
-
{
|
852
|
-
pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
|
853
|
-
inside: {
|
854
|
-
'interpolation': interpolation
|
855
|
-
}
|
856
|
-
},
|
857
|
-
{
|
858
|
-
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
|
859
|
-
lookbehind: true
|
860
|
-
}
|
861
|
-
],
|
862
|
-
'variable': /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
|
863
|
-
'symbol': /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/
|
864
|
-
});
|
865
|
-
|
866
|
-
Prism.languages.insertBefore('ruby', 'number', {
|
867
|
-
'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
|
868
|
-
'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
|
869
|
-
});
|
870
|
-
|
871
|
-
Prism.languages.ruby.string = [
|
872
|
-
{
|
873
|
-
pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
|
874
|
-
inside: {
|
875
|
-
'interpolation': interpolation
|
876
|
-
}
|
877
|
-
},
|
878
|
-
{
|
879
|
-
pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
|
880
|
-
inside: {
|
881
|
-
'interpolation': interpolation
|
882
|
-
}
|
883
|
-
},
|
884
|
-
{
|
885
|
-
// Here we need to specifically allow interpolation
|
886
|
-
pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
|
887
|
-
inside: {
|
888
|
-
'interpolation': interpolation
|
889
|
-
}
|
890
|
-
},
|
891
|
-
{
|
892
|
-
pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
|
893
|
-
inside: {
|
894
|
-
'interpolation': interpolation
|
895
|
-
}
|
896
|
-
},
|
897
|
-
{
|
898
|
-
pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
|
899
|
-
inside: {
|
900
|
-
'interpolation': interpolation
|
901
|
-
}
|
902
|
-
},
|
903
|
-
{
|
904
|
-
pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
|
905
|
-
inside: {
|
906
|
-
'interpolation': interpolation
|
907
|
-
}
|
908
|
-
}
|
909
|
-
];
|
910
|
-
}(Prism));
|
911
|
-
Prism.languages.git = {
|
912
|
-
/*
|
913
|
-
* A simple one line comment like in a git status command
|
914
|
-
* For instance:
|
915
|
-
* $ git status
|
916
|
-
* # On branch infinite-scroll
|
917
|
-
* # Your branch and 'origin/sharedBranches/frontendTeam/infinite-scroll' have diverged,
|
918
|
-
* # and have 1 and 2 different commits each, respectively.
|
919
|
-
* nothing to commit (working directory clean)
|
920
|
-
*/
|
921
|
-
'comment': /^#.*/m,
|
922
|
-
|
923
|
-
/*
|
924
|
-
* Regexp to match the changed lines in a git diff output. Check the example below.
|
925
|
-
*/
|
926
|
-
'deleted': /^[-–].*/m,
|
927
|
-
'inserted': /^\+.*/m,
|
928
|
-
|
929
|
-
/*
|
930
|
-
* a string (double and simple quote)
|
931
|
-
*/
|
932
|
-
'string': /("|')(\\?.)*?\1/m,
|
933
|
-
|
934
|
-
/*
|
935
|
-
* a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
|
936
|
-
* For instance:
|
937
|
-
* $ git add file.txt
|
938
|
-
*/
|
939
|
-
'command': {
|
940
|
-
pattern: /^.*\$ git .*$/m,
|
941
|
-
inside: {
|
942
|
-
/*
|
943
|
-
* A git command can contain a parameter starting by a single or a double dash followed by a string
|
944
|
-
* For instance:
|
945
|
-
* $ git diff --cached
|
946
|
-
* $ git log -p
|
947
|
-
*/
|
948
|
-
'parameter': /\s(--|-)\w+/m
|
949
|
-
}
|
950
|
-
},
|
951
|
-
|
952
|
-
/*
|
953
|
-
* Coordinates displayed in a git diff command
|
954
|
-
* For instance:
|
955
|
-
* $ git diff
|
956
|
-
* diff --git file.txt file.txt
|
957
|
-
* index 6214953..1d54a52 100644
|
958
|
-
* --- file.txt
|
959
|
-
* +++ file.txt
|
960
|
-
* @@ -1 +1,2 @@
|
961
|
-
* -Here's my tetx file
|
962
|
-
* +Here's my text file
|
963
|
-
* +And this is the second line
|
964
|
-
*/
|
965
|
-
'coord': /^@@.*@@$/m,
|
966
|
-
|
967
|
-
/*
|
968
|
-
* Match a "commit [SHA1]" line in a git log output.
|
969
|
-
* For instance:
|
970
|
-
* $ git log
|
971
|
-
* commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
|
972
|
-
* Author: lgiraudel
|
973
|
-
* Date: Mon Feb 17 11:18:34 2014 +0100
|
974
|
-
*
|
975
|
-
* Add of a new line
|
976
|
-
*/
|
977
|
-
'commit_sha1': /^commit \w{40}$/m
|
978
|
-
};
|
979
|
-
|
980
|
-
Prism.languages.go = Prism.languages.extend('clike', {
|
981
|
-
'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/,
|
982
|
-
'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/,
|
983
|
-
'boolean': /\b(_|iota|nil|true|false)\b/,
|
984
|
-
'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
985
|
-
'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
|
986
|
-
'string': /("|'|`)(\\?.|\r|\n)*?\1/
|
987
|
-
});
|
988
|
-
delete Prism.languages.go['class-name'];
|
989
|
-
|
990
|
-
/* TODO
|
991
|
-
Handle multiline code after tag
|
992
|
-
%foo= some |
|
993
|
-
multiline |
|
994
|
-
code |
|
995
|
-
*/
|
996
|
-
|
997
|
-
(function(Prism) {
|
998
|
-
|
999
|
-
Prism.languages.haml = {
|
1000
|
-
// Multiline stuff should appear before the rest
|
1001
|
-
|
1002
|
-
'multiline-comment': {
|
1003
|
-
pattern: /((?:^|\r?\n|\r)([\t ]*))(?:\/|-#).*((?:\r?\n|\r)\2[\t ]+.+)*/,
|
1004
|
-
lookbehind: true,
|
1005
|
-
alias: 'comment'
|
1006
|
-
},
|
1007
|
-
|
1008
|
-
'multiline-code': [
|
1009
|
-
{
|
1010
|
-
pattern: /((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*,[\t ]*((?:\r?\n|\r)\2[\t ]+.*,[\t ]*)*((?:\r?\n|\r)\2[\t ]+.+)/,
|
1011
|
-
lookbehind: true,
|
1012
|
-
inside: {
|
1013
|
-
rest: Prism.languages.ruby
|
1014
|
-
}
|
1015
|
-
},
|
1016
|
-
{
|
1017
|
-
pattern: /((?:^|\r?\n|\r)([\t ]*)(?:[~-]|[&!]?=)).*\|[\t ]*((?:\r?\n|\r)\2[\t ]+.*\|[\t ]*)*/,
|
1018
|
-
lookbehind: true,
|
1019
|
-
inside: {
|
1020
|
-
rest: Prism.languages.ruby
|
1021
|
-
}
|
1022
|
-
}
|
1023
|
-
],
|
1024
|
-
|
1025
|
-
// See at the end of the file for known filters
|
1026
|
-
'filter': {
|
1027
|
-
pattern: /((?:^|\r?\n|\r)([\t ]*)):[\w-]+((?:\r?\n|\r)(?:\2[\t ]+.+|\s*?(?=\r?\n|\r)))+/,
|
1028
|
-
lookbehind: true,
|
1029
|
-
inside: {
|
1030
|
-
'filter-name': {
|
1031
|
-
pattern: /^:[\w-]+/,
|
1032
|
-
alias: 'variable'
|
1033
|
-
}
|
1034
|
-
}
|
1035
|
-
},
|
1036
|
-
|
1037
|
-
'markup': {
|
1038
|
-
pattern: /((?:^|\r?\n|\r)[\t ]*)<.+/,
|
1039
|
-
lookbehind: true,
|
1040
|
-
inside: {
|
1041
|
-
rest: Prism.languages.markup
|
1042
|
-
}
|
1043
|
-
},
|
1044
|
-
'doctype': {
|
1045
|
-
pattern: /((?:^|\r?\n|\r)[\t ]*)!!!(?: .+)?/,
|
1046
|
-
lookbehind: true
|
1047
|
-
},
|
1048
|
-
'tag': {
|
1049
|
-
// Allows for one nested group of braces
|
1050
|
-
pattern: /((?:^|\r?\n|\r)[\t ]*)[%.#][\w\-#.]*[\w\-](?:\([^)]+\)|\{(?:\{[^}]+\}|[^}])+\}|\[[^\]]+\])*[\/<>]*/,
|
1051
|
-
lookbehind: true,
|
1052
|
-
inside: {
|
1053
|
-
'attributes': [
|
1054
|
-
{
|
1055
|
-
// Lookbehind tries to prevent interpolations for breaking it all
|
1056
|
-
// Allows for one nested group of braces
|
1057
|
-
pattern: /(^|[^#])\{(?:\{[^}]+\}|[^}])+\}/,
|
1058
|
-
lookbehind: true,
|
1059
|
-
inside: {
|
1060
|
-
rest: Prism.languages.ruby
|
1061
|
-
}
|
1062
|
-
},
|
1063
|
-
{
|
1064
|
-
pattern: /\([^)]+\)/,
|
1065
|
-
inside: {
|
1066
|
-
'attr-value': {
|
1067
|
-
pattern: /(=\s*)(?:"(?:\\?.)*?"|[^)\s]+)/,
|
1068
|
-
lookbehind: true
|
1069
|
-
},
|
1070
|
-
'attr-name': /[\w:-]+(?=\s*!?=|\s*[,)])/,
|
1071
|
-
'punctuation': /[=(),]/
|
1072
|
-
}
|
1073
|
-
},
|
1074
|
-
{
|
1075
|
-
pattern: /\[[^\]]+\]/,
|
1076
|
-
inside: {
|
1077
|
-
rest: Prism.languages.ruby
|
1078
|
-
}
|
1079
|
-
}
|
1080
|
-
],
|
1081
|
-
'punctuation': /[<>]/
|
1082
|
-
}
|
1083
|
-
},
|
1084
|
-
'code': {
|
1085
|
-
pattern: /((?:^|\r?\n|\r)[\t ]*(?:[~-]|[&!]?=)).+/,
|
1086
|
-
lookbehind: true,
|
1087
|
-
inside: {
|
1088
|
-
rest: Prism.languages.ruby
|
1089
|
-
}
|
1090
|
-
},
|
1091
|
-
// Interpolations in plain text
|
1092
|
-
'interpolation': {
|
1093
|
-
pattern: /#\{[^}]+\}/,
|
1094
|
-
inside: {
|
1095
|
-
'delimiter': {
|
1096
|
-
pattern: /^#\{|\}$/,
|
1097
|
-
alias: 'punctuation'
|
1098
|
-
},
|
1099
|
-
rest: Prism.languages.ruby
|
1100
|
-
}
|
1101
|
-
},
|
1102
|
-
'punctuation': {
|
1103
|
-
pattern: /((?:^|\r?\n|\r)[\t ]*)[~=\-&!]+/,
|
1104
|
-
lookbehind: true
|
1105
|
-
}
|
1106
|
-
};
|
1107
|
-
|
1108
|
-
var filter_pattern = '((?:^|\\r?\\n|\\r)([\\t ]*)):{{filter_name}}((?:\\r?\\n|\\r)(?:\\2[\\t ]+.+|\\s*?(?=\\r?\\n|\\r)))+';
|
1109
|
-
|
1110
|
-
// Non exhaustive list of available filters and associated languages
|
1111
|
-
var filters = [
|
1112
|
-
'css',
|
1113
|
-
{filter:'coffee',language:'coffeescript'},
|
1114
|
-
'erb',
|
1115
|
-
'javascript',
|
1116
|
-
'less',
|
1117
|
-
'markdown',
|
1118
|
-
'ruby',
|
1119
|
-
'scss',
|
1120
|
-
'textile'
|
1121
|
-
];
|
1122
|
-
var all_filters = {};
|
1123
|
-
for (var i = 0, l = filters.length; i < l; i++) {
|
1124
|
-
var filter = filters[i];
|
1125
|
-
filter = typeof filter === 'string' ? {filter: filter, language: filter} : filter;
|
1126
|
-
if (Prism.languages[filter.language]) {
|
1127
|
-
all_filters['filter-' + filter.filter] = {
|
1128
|
-
pattern: RegExp(filter_pattern.replace('{{filter_name}}', filter.filter)),
|
1129
|
-
lookbehind: true,
|
1130
|
-
inside: {
|
1131
|
-
'filter-name': {
|
1132
|
-
pattern: /^:[\w-]+/,
|
1133
|
-
alias: 'variable'
|
1134
|
-
},
|
1135
|
-
rest: Prism.languages[filter.language]
|
1136
|
-
}
|
1137
|
-
}
|
1138
|
-
}
|
1139
|
-
}
|
1140
|
-
|
1141
|
-
Prism.languages.insertBefore('haml', 'filter', all_filters);
|
1142
|
-
|
1143
|
-
}(Prism));
|
1144
|
-
Prism.languages.http = {
|
1145
|
-
'request-line': {
|
1146
|
-
pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\/\/\S+\sHTTP\/[0-9.]+/m,
|
1147
|
-
inside: {
|
1148
|
-
// HTTP Verb
|
1149
|
-
property: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,
|
1150
|
-
// Path or query argument
|
1151
|
-
'attr-name': /:\w+/
|
1152
|
-
}
|
1153
|
-
},
|
1154
|
-
'response-status': {
|
1155
|
-
pattern: /^HTTP\/1.[01] [0-9]+.*/m,
|
1156
|
-
inside: {
|
1157
|
-
// Status, e.g. 200 OK
|
1158
|
-
property: {
|
1159
|
-
pattern: /(^HTTP\/1.[01] )[0-9]+.*/i,
|
1160
|
-
lookbehind: true
|
1161
|
-
}
|
1162
|
-
}
|
1163
|
-
},
|
1164
|
-
// HTTP header name
|
1165
|
-
'header-name': {
|
1166
|
-
pattern: /^[\w-]+:(?=.)/m,
|
1167
|
-
alias: 'keyword'
|
1168
|
-
}
|
1169
|
-
};
|
1170
|
-
|
1171
|
-
// Create a mapping of Content-Type headers to language definitions
|
1172
|
-
var httpLanguages = {
|
1173
|
-
'application/json': Prism.languages.javascript,
|
1174
|
-
'application/xml': Prism.languages.markup,
|
1175
|
-
'text/xml': Prism.languages.markup,
|
1176
|
-
'text/html': Prism.languages.markup
|
1177
|
-
};
|
1178
|
-
|
1179
|
-
// Insert each content type parser that has its associated language
|
1180
|
-
// currently loaded.
|
1181
|
-
for (var contentType in httpLanguages) {
|
1182
|
-
if (httpLanguages[contentType]) {
|
1183
|
-
var options = {};
|
1184
|
-
options[contentType] = {
|
1185
|
-
pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*', 'i'),
|
1186
|
-
lookbehind: true,
|
1187
|
-
inside: {
|
1188
|
-
rest: httpLanguages[contentType]
|
1189
|
-
}
|
1190
|
-
};
|
1191
|
-
Prism.languages.insertBefore('http', 'header-name', options);
|
1192
|
-
}
|
1193
|
-
}
|
1194
|
-
;
|
1195
|
-
Prism.languages.java = Prism.languages.extend('clike', {
|
1196
|
-
'keyword': /\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)\b/,
|
1197
|
-
'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,
|
1198
|
-
'operator': {
|
1199
|
-
pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
|
1200
|
-
lookbehind: true
|
1201
|
-
}
|
1202
|
-
});
|
1203
|
-
Prism.languages.nginx = Prism.languages.extend('clike', {
|
1204
|
-
'comment': {
|
1205
|
-
pattern: /(^|[^"{\\])#.*/,
|
1206
|
-
lookbehind: true
|
1207
|
-
},
|
1208
|
-
'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|server|events|location|include|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)\b/i,
|
1209
|
-
});
|
1210
|
-
|
1211
|
-
Prism.languages.insertBefore('nginx', 'keyword', {
|
1212
|
-
'variable': /\$[a-z_]+/i
|
1213
|
-
});
|
1214
|
-
Prism.languages.objectivec = Prism.languages.extend('c', {
|
1215
|
-
'keyword': /\b(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|in|self|super)\b|(@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,
|
1216
|
-
'string': /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|@"(\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
1217
|
-
'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/
|
1218
|
-
});
|
1219
|
-
|
1220
|
-
/**
|
1221
|
-
* Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
|
1222
|
-
* Modified by Miles Johnson: http://milesj.me
|
1223
|
-
*
|
1224
|
-
* Supports the following:
|
1225
|
-
* - Extends clike syntax
|
1226
|
-
* - Support for PHP 5.3+ (namespaces, traits, generators, etc)
|
1227
|
-
* - Smarter constant and function matching
|
1228
|
-
*
|
1229
|
-
* Adds the following new token classes:
|
1230
|
-
* constant, delimiter, variable, function, package
|
1231
|
-
*/
|
1232
|
-
|
1233
|
-
Prism.languages.php = Prism.languages.extend('clike', {
|
1234
|
-
'keyword': /\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,
|
1235
|
-
'constant': /\b[A-Z0-9_]{2,}\b/,
|
1236
|
-
'comment': {
|
1237
|
-
pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
|
1238
|
-
lookbehind: true
|
1239
|
-
}
|
1240
|
-
});
|
1241
|
-
|
1242
|
-
// Shell-like comments are matched after strings, because they are less
|
1243
|
-
// common than strings containing hashes...
|
1244
|
-
Prism.languages.insertBefore('php', 'class-name', {
|
1245
|
-
'shell-comment': {
|
1246
|
-
pattern: /(^|[^\\])#.*/,
|
1247
|
-
lookbehind: true,
|
1248
|
-
alias: 'comment'
|
1249
|
-
}
|
1250
|
-
});
|
1251
|
-
|
1252
|
-
Prism.languages.insertBefore('php', 'keyword', {
|
1253
|
-
'delimiter': /\?>|<\?(?:php)?/i,
|
1254
|
-
'variable': /\$\w+\b/i,
|
1255
|
-
'package': {
|
1256
|
-
pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
|
1257
|
-
lookbehind: true,
|
1258
|
-
inside: {
|
1259
|
-
punctuation: /\\/
|
1260
|
-
}
|
1261
|
-
}
|
1262
|
-
});
|
1263
|
-
|
1264
|
-
// Must be defined after the function pattern
|
1265
|
-
Prism.languages.insertBefore('php', 'operator', {
|
1266
|
-
'property': {
|
1267
|
-
pattern: /(->)[\w]+/,
|
1268
|
-
lookbehind: true
|
1269
|
-
}
|
1270
|
-
});
|
1271
|
-
|
1272
|
-
// Add HTML support of the markup language exists
|
1273
|
-
if (Prism.languages.markup) {
|
1274
|
-
|
1275
|
-
// Tokenize all inline PHP blocks that are wrapped in <?php ?>
|
1276
|
-
// This allows for easy PHP + markup highlighting
|
1277
|
-
Prism.hooks.add('before-highlight', function(env) {
|
1278
|
-
if (env.language !== 'php') {
|
1279
|
-
return;
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
env.tokenStack = [];
|
1283
|
-
|
1284
|
-
env.backupCode = env.code;
|
1285
|
-
env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function(match) {
|
1286
|
-
env.tokenStack.push(match);
|
1287
|
-
|
1288
|
-
return '{{{PHP' + env.tokenStack.length + '}}}';
|
1289
|
-
});
|
1290
|
-
});
|
1291
|
-
|
1292
|
-
// Restore env.code for other plugins (e.g. line-numbers)
|
1293
|
-
Prism.hooks.add('before-insert', function(env) {
|
1294
|
-
if (env.language === 'php') {
|
1295
|
-
env.code = env.backupCode;
|
1296
|
-
delete env.backupCode;
|
1297
|
-
}
|
1298
|
-
});
|
1299
|
-
|
1300
|
-
// Re-insert the tokens after highlighting
|
1301
|
-
Prism.hooks.add('after-highlight', function(env) {
|
1302
|
-
if (env.language !== 'php') {
|
1303
|
-
return;
|
1304
|
-
}
|
1305
|
-
|
1306
|
-
for (var i = 0, t; t = env.tokenStack[i]; i++) {
|
1307
|
-
// The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
|
1308
|
-
env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
|
1309
|
-
}
|
1310
|
-
|
1311
|
-
env.element.innerHTML = env.highlightedCode;
|
1312
|
-
});
|
1313
|
-
|
1314
|
-
// Wrap tokens in classes that are missing them
|
1315
|
-
Prism.hooks.add('wrap', function(env) {
|
1316
|
-
if (env.language === 'php' && env.type === 'markup') {
|
1317
|
-
env.content = env.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g, "<span class=\"token php\">$1</span>");
|
1318
|
-
}
|
1319
|
-
});
|
1320
|
-
|
1321
|
-
// Add the rules before all others
|
1322
|
-
Prism.languages.insertBefore('php', 'comment', {
|
1323
|
-
'markup': {
|
1324
|
-
pattern: /<[^?]\/?(.*?)>/,
|
1325
|
-
inside: Prism.languages.markup
|
1326
|
-
},
|
1327
|
-
'php': /\{\{\{PHP[0-9]+\}\}\}/
|
1328
|
-
});
|
1329
|
-
}
|
1330
|
-
;
|
1331
|
-
Prism.languages.python= {
|
1332
|
-
'comment': {
|
1333
|
-
pattern: /(^|[^\\])#.*/,
|
1334
|
-
lookbehind: true
|
1335
|
-
},
|
1336
|
-
'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(?:\\?.)*?\1/,
|
1337
|
-
'function' : {
|
1338
|
-
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
|
1339
|
-
lookbehind: true
|
1340
|
-
},
|
1341
|
-
'class-name': {
|
1342
|
-
pattern: /(\bclass\s+)[a-z0-9_]+/i,
|
1343
|
-
lookbehind: true
|
1344
|
-
},
|
1345
|
-
'keyword' : /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
|
1346
|
-
'boolean' : /\b(?:True|False)\b/,
|
1347
|
-
'number' : /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
1348
|
-
'operator' : /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
|
1349
|
-
'punctuation' : /[{}[\];(),.:]/
|
1350
|
-
};
|
1351
|
-
|
1352
|
-
Prism.languages.scss = Prism.languages.extend('css', {
|
1353
|
-
'comment': {
|
1354
|
-
pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
|
1355
|
-
lookbehind: true
|
1356
|
-
},
|
1357
|
-
'atrule': {
|
1358
|
-
pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
|
1359
|
-
inside: {
|
1360
|
-
'rule': /@[\w-]+/
|
1361
|
-
// See rest below
|
1362
|
-
}
|
1363
|
-
},
|
1364
|
-
// url, compassified
|
1365
|
-
'url': /(?:[-a-z]+-)*url(?=\()/i,
|
1366
|
-
// CSS selector regex is not appropriate for Sass
|
1367
|
-
// since there can be lot more things (var, @ directive, nesting..)
|
1368
|
-
// a selector must start at the end of a property or after a brace (end of other rules or nesting)
|
1369
|
-
// it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
|
1370
|
-
// 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
|
1371
|
-
// can "pass" as a selector- e.g: proper#{$erty})
|
1372
|
-
// this one was hard to do, so please be careful if you edit this one :)
|
1373
|
-
'selector': {
|
1374
|
-
// Initial look-ahead is used to prevent matching of blank selectors
|
1375
|
-
pattern: /(?=\S)[^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m,
|
1376
|
-
inside: {
|
1377
|
-
'placeholder': /%[-_\w]+/
|
1378
|
-
}
|
1379
|
-
}
|
1380
|
-
});
|
1381
|
-
|
1382
|
-
Prism.languages.insertBefore('scss', 'atrule', {
|
1383
|
-
'keyword': [
|
1384
|
-
/@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
|
1385
|
-
{
|
1386
|
-
pattern: /( +)(?:from|through)(?= )/,
|
1387
|
-
lookbehind: true
|
1388
|
-
}
|
1389
|
-
]
|
1390
|
-
});
|
1391
|
-
|
1392
|
-
Prism.languages.insertBefore('scss', 'property', {
|
1393
|
-
// var and interpolated vars
|
1394
|
-
'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
|
1395
|
-
});
|
1396
|
-
|
1397
|
-
Prism.languages.insertBefore('scss', 'function', {
|
1398
|
-
'placeholder': {
|
1399
|
-
pattern: /%[-_\w]+/,
|
1400
|
-
alias: 'selector'
|
1401
|
-
},
|
1402
|
-
'statement': /\B!(?:default|optional)\b/i,
|
1403
|
-
'boolean': /\b(?:true|false)\b/,
|
1404
|
-
'null': /\bnull\b/,
|
1405
|
-
'operator': {
|
1406
|
-
pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
|
1407
|
-
lookbehind: true
|
1408
|
-
}
|
1409
|
-
});
|
1410
|
-
|
1411
|
-
Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
|