History

Fix merge conflict

Jasper van Merle committed 8 years ago

Commit 536fa352 parents e894a2f e8d52c9175 files · +2496 −1111Browse files

Showing the changes to assets/javascripts (12 of 175 files). Show all

Unified · Split

12 files
  1. assets/javascripts/app/app.coffee +1 −6
  2. assets/javascripts/app/shortcuts.coffee +3 −0
  3. assets/javascripts/lib/page.coffee +1 −1
  4. assets/javascripts/news.json +9 −0
  5. assets/javascripts/templates/error_tmpl.coffee +4 −7
  6. assets/javascripts/templates/pages/about_tmpl.coffee +36 −1
  7. assets/javascripts/templates/pages/help_tmpl.coffee +3 −0
  8. assets/javascripts/templates/pages/root_tmpl.coffee.erb +0 −11
  9. assets/javascripts/vendor/prism.js +633 −352
  10. assets/javascripts/views/content/root_page.coffee +0 −4
  11. assets/javascripts/views/content/settings_page.coffee +3 −4
  12. assets/javascripts/views/search/search.coffee +5 −0
assets/javascripts/app/app.coffee+1−6
@@ -245,7 +245,7 @@ · 244 unmodified lines
245 matchMedia: !!window.matchMedia245 matchMedia: !!window.matchMedia
246 insertAdjacentHTML: !!document.body.insertAdjacentHTML246 insertAdjacentHTML: !!document.body.insertAdjacentHTML
247 defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false247 defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false
248 cssGradients: supportsCssGradients()248 cssVariables: CSS.supports and CSS.supports('(--t: 0)')
249 249
250 for key, value of features when not value250 for key, value of features when not value
251 Raven.captureMessage "unsupported/#{key}", level: 'info'251 Raven.captureMessage "unsupported/#{key}", level: 'info'
@@ -268,9 +268,4 @@ · 16 unmodified lines
268 isInvalidLocation: ->268 isInvalidLocation: ->
269 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0269 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
270 270
271supportsCssGradients = ->
272 el = document.createElement('div')
273 el.style.cssText = "background-image: -webkit-linear-gradient(top, #000, #fff); background-image: linear-gradient(to top, #000, #fff);"
274 el.style.backgroundImage.indexOf('gradient') >= 0
275
276$.extend app, Events271$.extend app, Events
assets/javascripts/app/shortcuts.coffee+3−0
@@ -149,6 +149,9 @@ class app.Shortcuts · 148 unmodified lines
149 when 40149 when 40
150 @trigger 'altDown'150 @trigger 'altDown'
151 false151 false
152 when 68
153 @trigger 'altD'
154 false
152 when 70155 when 70
153 @trigger 'altF', event156 @trigger 'altF', event
154 when 71157 when 71
assets/javascripts/lib/page.coffee+1−1
@@ -190,7 +190,7 @@ isSameOrigin = (url) -> · 189 unmodified lines
190 190
191updateCanonicalLink = ->191updateCanonicalLink = ->
192 @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')192 @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
193 @canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")193 @canonicalLink.setAttribute('href', "https://#{location.host}#{location.pathname}")
194 194
195trackers = []195trackers = []
196 196
assets/javascripts/news.json+9−0
@@ -1,5 +1,14 @@
1[1[
2 [2 [
3 "2018-09-23",
4 "New documentations: <a href=\"/puppeteer/\">Puppeteer</a> and <a href=\"/handlebars/\">Handlebars.js</a>"
5 ], [
6 "2018-08-12",
7 "New documentations: <a href=\"/dart/\">Dart</a> and <a href=\"/qt/\">Qt</a>"
8 ], [
9 "2018-07-29",
10 "New documentations: <a href=\"/bash/\">Bash</a>, <a href=\"/graphite/\">Graphite</a> and <a href=\"/pygame/\">Pygame</a>"
11 ], [
3 "2018-07-08",12 "2018-07-08",
4 "New documentations: <a href=\"/leaflet/\">Leaflet</a>, <a href=\"/terraform/\">Terraform</a> and <a href=\"/koa/\">Koa</a>"13 "New documentations: <a href=\"/leaflet/\">Leaflet</a>, <a href=\"/terraform/\">Terraform</a> and <a href=\"/koa/\">Koa</a>"
5 ], [14 ], [
assets/javascripts/templates/error_tmpl.coffee+4−7
@@ -56,13 +56,10 @@ app.templates.unsupportedBrowser = """ · 55 unmodified lines
56 <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>56 <h1 class="_fail-title">Your browser is unsupported, sorry.</h1>
57 <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:57 <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
58 <ul class="_fail-list">58 <ul class="_fail-list">
59 <li>Recent versions of Chrome and Firefox59 <li>Recent versions of Firefox, Chrome, or Opera
60 <li>Safari 5.1+60 <li>Safari 9.1+
61 <li>Opera 12.1+61 <li>Edge 16+
62 <li>Internet Explorer 10+62 <li>iOS 10+
63 <li>iOS 6+
64 <li>Android 4.1+
65 <li>Windows Phone 8+
66 </ul>63 </ul>
67 <p class="_fail-text">64 <p class="_fail-text">
68 If you're unable to upgrade, I apologize.65 If you're unable to upgrade, I apologize.
assets/javascripts/templates/pages/about_tmpl.coffee+36−1
@@ -115,6 +115,11 @@ credits = [ · 114 unmodified lines
115 '2010-2016 Jeremy Ashkenas, DocumentCloud',115 '2010-2016 Jeremy Ashkenas, DocumentCloud',
116 'MIT',116 'MIT',
117 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'117 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'
118 ], [
119 'Bash',
120 '2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.',
121 'GFDL',
122 'https://www.gnu.org/licenses/fdl-1.3.en.html'
118 ], [123 ], [
119 'Bluebird',124 'Bluebird',
120 '2013-2017 Petka Antonov',125 '2013-2017 Petka Antonov',
@@ -162,7 +167,7 @@ credits = [ · 41 unmodified lines
162 'https://github.com/clojure/clojure/blob/master/epl-v10.html'167 'https://github.com/clojure/clojure/blob/master/epl-v10.html'
163 ], [168 ], [
164 'CMake',169 'CMake',
165 '2000-2017 Kitware, Inc. and Contributors',170 '2000-2018 Kitware, Inc. and Contributors',
166 'BSD',171 'BSD',
167 'https://cmake.org/licensing/'172 'https://cmake.org/licensing/'
168 ], [173 ], [
@@ -210,6 +215,11 @@ credits = [ · 41 unmodified lines
210 '2010-2018 Michael Bostock',215 '2010-2018 Michael Bostock',
211 'BSD',216 'BSD',
212 'https://raw.githubusercontent.com/d3/d3/master/LICENSE'217 'https://raw.githubusercontent.com/d3/d3/master/LICENSE'
218 ], [
219 'Dart',
220 '2012 the Dart project authors',
221 'CC BY-SA',
222 'https://creativecommons.org/licenses/by-sa/4.0/'
213 ], [223 ], [
214 'Django',224 'Django',
215 'Django Software Foundation and individual contributors',225 'Django Software Foundation and individual contributors',
@@ -290,11 +300,21 @@ credits = [ · 74 unmodified lines
290 '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',300 '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
291 'MIT',301 'MIT',
292 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'302 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'
303 ], [
304 'Graphite',
305 '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',
306 'Apache',
307 'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE'
293 ], [308 ], [
294 'Grunt',309 'Grunt',
295 'GruntJS Team',310 'GruntJS Team',
296 'MIT',311 'MIT',
297 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10'312 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10'
313 ], [
314 'Handlebars',
315 '2011-2017 Yehuda Katz',
316 'MIT',
317 'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE'
298 ], [318 ], [
299 'Haskell',319 'Haskell',
300 'The University of Glasgow',320 'The University of Glasgow',
@@ -550,6 +570,16 @@ credits = [ · 249 unmodified lines
550 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',570 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
551 'PostgreSQL',571 'PostgreSQL',
552 'https://www.postgresql.org/about/licence/'572 'https://www.postgresql.org/about/licence/'
573 ], [
574 'Puppeteer',
575 '2017 Google Inc',
576 'Apache',
577 'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE'
578 ], [
579 'Pygame',
580 'Pygame Developpers',
581 'LGPLv2.1',
582 'https://raw.githubusercontent.com/pygame/pygame/master/LICENSE'
553 ], [583 ], [
554 'Python',584 'Python',
555 '2001-2018 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',585 '2001-2018 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
@@ -560,6 +590,11 @@ credits = [ · 4 unmodified lines
560 '2009-2017 Kristopher Michael Kowal',590 '2009-2017 Kristopher Michael Kowal',
561 'MIT',591 'MIT',
562 'https://raw.githubusercontent.com/kriskowal/q/master/LICENSE'592 'https://raw.githubusercontent.com/kriskowal/q/master/LICENSE'
593 ], [
594 'Qt',
595 '2012-2018 The Qt Company Ltd',
596 'GFDL',
597 'https://doc.qt.io/qt-5/licensing.html'
563 ], [598 ], [
564 'Ramda',599 'Ramda',
565 '2013-2016 Scott Sauyet and Michael Hurley',600 '2013-2016 Scott Sauyet and Michael Hurley',
assets/javascripts/templates/pages/help_tmpl.coffee+3−0
@@ -131,6 +131,9 @@ app.templates.helpPage = -> · 130 unmodified lines
131 <dt class="_shortcuts-dt">131 <dt class="_shortcuts-dt">
132 <code class="_shortcut-code">alt + s</code>132 <code class="_shortcut-code">alt + s</code>
133 <dd class="_shortcuts-dd">Search on Stack Overflow133 <dd class="_shortcuts-dd">Search on Stack Overflow
134 <dt class="_shortcuts-dt">
135 <code class="_shortcut-code">alt + d</code>
136 <dd class="_shortcuts-dd">Search on DuckDuckGo
134 </dl>137 </dl>
135 <p class="_note _note-green">138 <p class="_note _note-green">
136 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or139 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
assets/javascripts/templates/pages/root_tmpl.coffee.erb+0−11
@@ -72,14 +72,3 @@ app.templates.androidWarning = """ · 71 unmodified lines
72 <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.72 <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.
73 </div>73 </div>
74"""74"""
75
76app.templates.httpWarning = """
77 <div class="_intro"><div class="_intro-message">
78 <h2 class="_intro-title">Hi there!</h2>
79 <p>DevDocs is migrating to HTTPS.
80 <p>Please update your bookmarks to point to <a href="https://devdocs.io">https://devdocs.io</a>.
81 <p>When using the HTTPS version, your preferences will carry over automatically, but your offline data will be reset. Simply re-download documentation in the <a href="https://devdocs.io/offline">Offline area</a>, and you'll be all set to use DevDocs securely offline.
82 <p>Sorry for the inconvenience. This migration is needed because browsers are removing support for certain DOM APIs that power DevDocs's offline mode over non-secure origins.
83 <p>Thanks for using DevDocs, and happy coding!
84 </div></div>
85"""
assets/javascripts/vendor/prism.js+633−352
@@ -1,4 +1,5 @@
1/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+django+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript+yaml */1/* PrismJS 1.15.0
2https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+django+elixir+markup-templating+erlang+go+java+json+kotlin+lua+crystal+nginx+nim+perl+php+sql+scss+python+jsx+typescript+rust+yaml */
2var _self = (typeof window !== 'undefined')3var _self = (typeof window !== 'undefined')
3 ? window // if in browser4 ? window // if in browser
4 : (5 : (
@@ -16,11 +17,12 @@ var _self = (typeof window !== 'undefined') · 11 unmodified lines
16var Prism = (function(){17var Prism = (function(){
17 18
18// Private helper vars19// Private helper vars
19var lang = /\blang(?:uage)?-(\w+)\b/i;20var lang = /\blang(?:uage)?-([\w-]+)\b/i;
20var uniqueId = 0;21var uniqueId = 0;
21 22
22var _ = _self.Prism = {23var _ = _self.Prism = {
23 manual: _self.Prism && _self.Prism.manual,24 manual: _self.Prism && _self.Prism.manual,
25 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
24 util: {26 util: {
25 encode: function (tokens) {27 encode: function (tokens) {
26 if (tokens instanceof Token) {28 if (tokens instanceof Token) {
@@ -44,23 +46,38 @@ var _ = _self.Prism = { · 17 unmodified lines
44 },46 },
45 47
46 // Deep clone a language definition (e.g. to extend it)48 // Deep clone a language definition (e.g. to extend it)
47 clone: function (o) {49 clone: function (o, visited) {
48 var type = _.util.type(o);50 var type = _.util.type(o);
51 visited = visited || {};
49 52
50 switch (type) {53 switch (type) {
51 case 'Object':54 case 'Object':
55 if (visited[_.util.objId(o)]) {
56 return visited[_.util.objId(o)];
57 }
52 var clone = {};58 var clone = {};
59 visited[_.util.objId(o)] = clone;
53 60
54 for (var key in o) {61 for (var key in o) {
55 if (o.hasOwnProperty(key)) {62 if (o.hasOwnProperty(key)) {
56 clone[key] = _.util.clone(o[key]);63 clone[key] = _.util.clone(o[key], visited);
57 }64 }
58 }65 }
59 66
60 return clone;67 return clone;
61 68
62 case 'Array':69 case 'Array':
63 return o.map(function(v) { return _.util.clone(v); });70 if (visited[_.util.objId(o)]) {
71 return visited[_.util.objId(o)];
72 }
73 var clone = [];
74 visited[_.util.objId(o)] = clone;
75
76 o.forEach(function (v, i) {
77 clone[i] = _.util.clone(v, visited);
78 });
79
80 return clone;
64 }81 }
65 82
66 return o;83 return o;
@@ -155,6 +172,10 @@ var _ = _self.Prism = { · 88 unmodified lines
155 plugins: {},172 plugins: {},
156 173
157 highlightAll: function(async, callback) {174 highlightAll: function(async, callback) {
175 _.highlightAllUnder(document, async, callback);
176 },
177
178 highlightAllUnder: function(container, async, callback) {
158 var env = {179 var env = {
159 callback: callback,180 callback: callback,
160 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'181 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
@@ -162,7 +183,7 @@ var _ = _self.Prism = { · 1 unmodified line
162 183
163 _.hooks.run("before-highlightall", env);184 _.hooks.run("before-highlightall", env);
164 185
165 var elements = env.elements || document.querySelectorAll(env.selector);186 var elements = env.elements || container.querySelectorAll(env.selector);
166 187
167 for (var i=0, element; element = elements[i++];) {188 for (var i=0, element; element = elements[i++];) {
168 _.highlightElement(element, async === true, env.callback);189 _.highlightElement(element, async === true, env.callback);
@@ -185,11 +206,13 @@ var _ = _self.Prism = { · 16 unmodified lines
185 // Set language on the element, if not present206 // Set language on the element, if not present
186 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;207 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
187 208
188 // Set language on the parent, for styling209 if (element.parentNode) {
189 parent = element.parentNode;210 // Set language on the parent, for styling
211 parent = element.parentNode;
190 212
191 if (/pre/i.test(parent.nodeName)) {213 if (/pre/i.test(parent.nodeName)) {
192 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;214 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
215 }
193 }216 }
194 217
195 var code = element.textContent;218 var code = element.textContent;
@@ -251,8 +274,15 @@ var _ = _self.Prism = { · 55 unmodified lines
251 },274 },
252 275
253 highlight: function (text, grammar, language) {276 highlight: function (text, grammar, language) {
254 var tokens = _.tokenize(text, grammar);277 var env = {
255 return Token.stringify(_.util.encode(tokens), language);278 code: text,
279 grammar: grammar,
280 language: language
281 };
282 _.hooks.run('before-tokenize', env);
283 env.tokens = _.tokenize(env.code, env.grammar);
284 _.hooks.run('after-tokenize', env);
285 return Token.stringify(_.util.encode(env.tokens), env.language);
256 },286 },
257 287
258 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {288 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
@@ -300,15 +330,9 @@ var _ = _self.Prism = { · 41 unmodified lines
300 continue;330 continue;
301 }331 }
302 332
303 pattern.lastIndex = 0;333 if (greedy && i != strarr.length - 1) {
304
305 var match = pattern.exec(str),
306 delNum = 1;
307
308 // Greedy patterns can override/remove up to two previously matched tokens
309 if (!match && greedy && i != strarr.length - 1) {
310 pattern.lastIndex = pos;334 pattern.lastIndex = pos;
311 match = pattern.exec(text);335 var match = pattern.exec(text);
312 if (!match) {336 if (!match) {
313 break;337 break;
314 }338 }
@@ -327,11 +351,8 @@ var _ = _self.Prism = { · 12 unmodified lines
327 }351 }
328 }352 }
329 353
330 /*354 // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
331 * If strarr[i] is a Token, then the match starts inside another Token, which is invalid355 if (strarr[i] instanceof Token) {
332 * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
333 */
334 if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
335 continue;356 continue;
336 }357 }
337 358
@@ -339,6 +360,11 @@ var _ = _self.Prism = { · 1 unmodified line
339 delNum = k - i;360 delNum = k - i;
340 str = text.slice(pos, p);361 str = text.slice(pos, p);
341 match.index -= pos;362 match.index -= pos;
363 } else {
364 pattern.lastIndex = 0;
365
366 var match = pattern.exec(str),
367 delNum = 1;
342 }368 }
343 369
344 if (!match) {370 if (!match) {
@@ -350,7 +376,7 @@ var _ = _self.Prism = { · 5 unmodified lines
350 }376 }
351 377
352 if(lookbehind) {378 if(lookbehind) {
353 lookbehindLength = match[1].length;379 lookbehindLength = match[1] ? match[1].length : 0;
354 }380 }
355 381
356 var from = match.index + lookbehindLength,382 var from = match.index + lookbehindLength,
@@ -480,18 +506,21 @@ Token.stringify = function(o, language, parent) { · 123 unmodified lines
480// // in Node.js506// // in Node.js
481// return _self.Prism;507// return _self.Prism;
482// }508// }
483// // In worker509
484// _self.addEventListener('message', function(evt) {510// if (!_.disableWorkerMessageHandler) {
485// var message = JSON.parse(evt.data),511// // In worker
486// lang = message.language,512// _self.addEventListener('message', function (evt) {
487// code = message.code,513// var message = JSON.parse(evt.data),
488// immediateClose = message.immediateClose;514// lang = message.language,
489 515// code = message.code,
490// _self.postMessage(_.highlight(code, _.languages[lang], lang));516// immediateClose = message.immediateClose;
491// if (immediateClose) {517
492// _self.close();518// _self.postMessage(_.highlight(code, _.languages[lang], lang));
493// }519// if (immediateClose) {
494// }, false);520// _self.close();
521// }
522// }, false);
523// }
495 524
496// return _self.Prism;525// return _self.Prism;
497// }526// }
@@ -535,7 +564,8 @@ Prism.languages.markup = { · 37 unmodified lines
535 'doctype': /<!DOCTYPE[\s\S]+?>/i,564 'doctype': /<!DOCTYPE[\s\S]+?>/i,
536 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,565 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
537 'tag': {566 'tag': {
538 pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,567 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
568 greedy: true,
539 inside: {569 inside: {
540 'tag': {570 'tag': {
541 pattern: /^<\/?[^\s>\/]+/i,571 pattern: /^<\/?[^\s>\/]+/i,
@@ -600,13 +630,13 @@ Prism.languages.css = { · 58 unmodified lines
600 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,630 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
601 greedy: true631 greedy: true
602 },632 },
603 'property': /[\w-]+(?=\s*:)/i,633 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
604 'important': /\B!important\b/i,634 'important': /\B!important\b/i,
605 'function': /[-a-z0-9]+(?=\()/i,635 'function': /[-a-z0-9]+(?=\()/i,
606 'punctuation': /[(){};:]/636 'punctuation': /[(){};:]/
607};637};
608 638
609Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);639Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
610 640
611if (Prism.languages.markup) {641if (Prism.languages.markup) {
612 Prism.languages.insertBefore('markup', 'tag', {642 Prism.languages.insertBefore('markup', 'tag', {
@@ -614,10 +644,11 @@ if (Prism.languages.markup) { · 1 unmodified line
614 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,644 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
615 lookbehind: true,645 lookbehind: true,
616 inside: Prism.languages.css,646 inside: Prism.languages.css,
617 alias: 'language-css'647 alias: 'language-css',
648 greedy: true
618 }649 }
619 });650 });
620 651
621 Prism.languages.insertBefore('inside', 'attr-value', {652 Prism.languages.insertBefore('inside', 'attr-value', {
622 'style-attr': {653 'style-attr': {
623 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,654 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
@@ -644,7 +675,8 @@ Prism.languages.clike = { · 20 unmodified lines
644 },675 },
645 {676 {
646 pattern: /(^|[^\\:])\/\/.*/,677 pattern: /(^|[^\\:])\/\/.*/,
647 lookbehind: true678 lookbehind: true,
679 greedy: true
648 }680 }
649 ],681 ],
650 'string': {682 'string': {
@@ -661,51 +693,53 @@ Prism.languages.clike = { · 10 unmodified lines
661 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,693 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
662 'boolean': /\b(?:true|false)\b/,694 'boolean': /\b(?:true|false)\b/,
663 'function': /[a-z0-9_]+(?=\()/i,695 'function': /[a-z0-9_]+(?=\()/i,
664 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,696 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
665 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,697 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
666 'punctuation': /[{}[\];(),.:]/698 'punctuation': /[{}[\];(),.:]/
667};699};
668 700
669Prism.languages.javascript = Prism.languages.extend('clike', {701Prism.languages.javascript = Prism.languages.extend('clike', {
670 '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/,702 '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/,
671 'number': /\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,703 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
672 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)704 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
673 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*\()/i,705 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
674 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/706 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
675});707});
676 708
677Prism.languages.insertBefore('javascript', 'keyword', {709Prism.languages.insertBefore('javascript', 'keyword', {
678 'regex': {710 'regex': {
679 pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,711 pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
680 lookbehind: true,712 lookbehind: true,
681 greedy: true713 greedy: true
682 },714 },
683 // This must be declared before keyword because we use "function" inside the look-forward715 // This must be declared before keyword because we use "function" inside the look-forward
684 'function-variable': {716 'function-variable': {
685 pattern: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)\s*=>))/i,717 pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
686 alias: 'function'718 alias: 'function'
687 }719 },
720 'constant': /\b[A-Z][A-Z\d_]*\b/
688});721});
689 722
690Prism.languages.insertBefore('javascript', 'string', {723Prism.languages.insertBefore('javascript', 'string', {
691 'template-string': {724 'template-string': {
692 pattern: /`(?:\\[\s\S]|[^\\`])*`/,725 pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
693 greedy: true,726 greedy: true,
694 inside: {727 inside: {
695 'interpolation': {728 'interpolation': {
696 pattern: /\$\{[^}]+\}/,729 pattern: /\${[^}]+}/,
697 inside: {730 inside: {
698 'interpolation-punctuation': {731 'interpolation-punctuation': {
699 pattern: /^\$\{|\}$/,732 pattern: /^\${|}$/,
700 alias: 'punctuation'733 alias: 'punctuation'
701 },734 },
702 rest: Prism.languages.javascript735 rest: null // See below
703 }736 }
704 },737 },
705 'string': /[\s\S]+/738 'string': /[\s\S]+/
706 }739 }
707 }740 }
708});741});
742Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript;
709 743
710if (Prism.languages.markup) {744if (Prism.languages.markup) {
711 Prism.languages.insertBefore('markup', 'tag', {745 Prism.languages.insertBefore('markup', 'tag', {
@@ -713,7 +747,8 @@ if (Prism.languages.markup) { · 1 unmodified line
713 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,747 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
714 lookbehind: true,748 lookbehind: true,
715 inside: Prism.languages.javascript,749 inside: Prism.languages.javascript,
716 alias: 'language-javascript'750 alias: 'language-javascript',
751 greedy: true
717 }752 }
718 });753 });
719}754}
@@ -723,7 +758,7 @@ Prism.languages.js = Prism.languages.javascript; · 3 unmodified lines
723Prism.languages.c = Prism.languages.extend('clike', {758Prism.languages.c = Prism.languages.extend('clike', {
724 '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/,759 '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/,
725 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,760 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
726 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i761 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
727});762});
728 763
729Prism.languages.insertBefore('c', 'string', {764Prism.languages.insertBefore('c', 'string', {
@@ -768,7 +803,7 @@ delete Prism.languages.c['boolean']; · 38 unmodified lines
768 },803 },
769 /^\$\(\(/804 /^\$\(\(/
770 ],805 ],
771 number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,806 number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
772 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic807 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
773 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,808 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
774 // If there is no $ sign at the beginning highlight (( and )) as punctuation809 // If there is no $ sign at the beginning highlight (( and )) as punctuation
@@ -778,6 +813,7 @@ delete Prism.languages.c['boolean']; · 3 unmodified lines
778 // Command Substitution813 // Command Substitution
779 {814 {
780 pattern: /\$\([^)]+\)|`[^`]+`/,815 pattern: /\$\([^)]+\)|`[^`]+`/,
816 greedy: true,
781 inside: {817 inside: {
782 variable: /^\$\(|^`|\)$|`$/818 variable: /^\$\(|^`|\)$|`$/
783 }819 }
@@ -804,7 +840,7 @@ delete Prism.languages.c['boolean']; · 20 unmodified lines
804 inside: insideString840 inside: insideString
805 },841 },
806 {842 {
807 pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,843 pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
808 greedy: true,844 greedy: true,
809 inside: insideString845 inside: insideString
810 }846 }
@@ -812,7 +848,7 @@ delete Prism.languages.c['boolean']; · 1 unmodified line
812 'variable': insideString.variable,848 'variable': insideString.variable,
813 // Originally based on http://ss64.com/bash/849 // Originally based on http://ss64.com/bash/
814 'function': {850 'function': {
815 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|npm|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;|&])/,851 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|curl|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|npm|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;|&])/,
816 lookbehind: true852 lookbehind: true
817 },853 },
818 'keyword': {854 'keyword': {
@@ -828,15 +864,18 @@ delete Prism.languages.c['boolean']; · 9 unmodified lines
828 };864 };
829 865
830 var inside = insideString.variable[1].inside;866 var inside = insideString.variable[1].inside;
867 inside.string = Prism.languages.bash.string;
831 inside['function'] = Prism.languages.bash['function'];868 inside['function'] = Prism.languages.bash['function'];
832 inside.keyword = Prism.languages.bash.keyword;869 inside.keyword = Prism.languages.bash.keyword;
833 inside.boolean = Prism.languages.bash.boolean;870 inside['boolean'] = Prism.languages.bash['boolean'];
834 inside.operator = Prism.languages.bash.operator;871 inside.operator = Prism.languages.bash.operator;
835 inside.punctuation = Prism.languages.bash.punctuation;872 inside.punctuation = Prism.languages.bash.punctuation;
873
874 Prism.languages.shell = Prism.languages.bash;
836})(Prism);875})(Prism);
837 876
838Prism.languages.cpp = Prism.languages.extend('c', {877Prism.languages.cpp = Prism.languages.extend('c', {
839 '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/,878 '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/,
840 'boolean': /\b(?:true|false)\b/,879 'boolean': /\b(?:true|false)\b/,
841 'operator': /--?|\+\+?|!=?|<{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/880 'operator': /--?|\+\+?|!=?|<{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/
842});881});
@@ -847,6 +886,15 @@ Prism.languages.insertBefore('cpp', 'keyword', { · 4 unmodified lines
847 lookbehind: true886 lookbehind: true
848 }887 }
849});888});
889
890Prism.languages.insertBefore('cpp', 'string', {
891 'raw-string': {
892 pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
893 alias: 'string',
894 greedy: true
895 }
896});
897
850(function(Prism) {898(function(Prism) {
851 899
852// Ignore comments starting with { to privilege string interpolation highlighting900// Ignore comments starting with { to privilege string interpolation highlighting
@@ -947,10 +995,13 @@ delete Prism.languages.coffeescript['template-string']; · 94 unmodified lines
947(function(Prism) {995(function(Prism) {
948 Prism.languages.ruby = Prism.languages.extend('clike', {996 Prism.languages.ruby = Prism.languages.extend('clike', {
949 'comment': [997 'comment': [
950 /#(?!\{[^\r\n]*?\}).*/,998 /#.*/,
951 /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m999 {
1000 pattern: /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m,
1001 greedy: true
1002 }
952 ],1003 ],
953 '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/1004 '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/
954 });1005 });
955 1006
956 var interpolation = {1007 var interpolation = {
@@ -960,7 +1011,7 @@ delete Prism.languages.coffeescript['template-string']; · 3 unmodified lines
960 pattern: /^#\{|\}$/,1011 pattern: /^#\{|\}$/,
961 alias: 'tag'1012 alias: 'tag'
962 },1013 },
963 rest: Prism.util.clone(Prism.languages.ruby)1014 rest: Prism.languages.ruby
964 }1015 }
965 };1016 };
966 1017
@@ -1009,7 +1060,10 @@ delete Prism.languages.coffeescript['template-string']; · 42 unmodified lines
1009 }1060 }
1010 ],1061 ],
1011 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,1062 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
1012 'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/1063 'symbol': {
1064 pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
1065 lookbehind: true
1066 }
1013 });1067 });
1014 1068
1015 Prism.languages.insertBefore('ruby', 'number', {1069 Prism.languages.insertBefore('ruby', 'number', {
@@ -1127,6 +1181,30 @@ Prism.languages.insertBefore('d', 'function', { · 111 unmodified lines
1127 alias: 'variable'1181 alias: 'variable'
1128 }1182 }
1129});1183});
1184Prism.languages.dart = Prism.languages.extend('clike', {
1185 'string': [
1186 {
1187 pattern: /r?("""|''')[\s\S]*?\1/,
1188 greedy: true
1189 },
1190 {
1191 pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
1192 greedy: true
1193 }
1194 ],
1195 'keyword': [
1196 /\b(?:async|sync|yield)\*/,
1197 /\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/
1198 ],
1199 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
1200});
1201
1202Prism.languages.insertBefore('dart','function',{
1203 'metadata': {
1204 pattern: /@\w+/,
1205 alias: 'symbol'
1206 }
1207});
1130// Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.1208// Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
1131// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.1209// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
1132 1210
@@ -1170,15 +1248,15 @@ if (Prism.languages.css) { · 37 unmodified lines
1170Prism.languages.jinja2 = Prism.languages.django;1248Prism.languages.jinja2 = Prism.languages.django;
1171 1249
1172Prism.languages.elixir = {1250Prism.languages.elixir = {
1173 // Negative look-ahead is needed for string interpolation
1174 // Negative look-behind is needed to avoid highlighting markdown headers in
1175 // multi-line doc strings
1176 'comment': {1251 'comment': {
1177 pattern: /(^|[^#])#(?![{#]).*/m,1252 pattern: /#.*/m,
1178 lookbehind: true1253 lookbehind: true
1179 },1254 },
1180 // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>1255 // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
1181 'regex': /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,1256 'regex': {
1257 pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
1258 greedy: true
1259 },
1182 'string': [1260 'string': [
1183 {1261 {
1184 // ~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>1262 // ~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>
@@ -1225,7 +1303,7 @@ Prism.languages.elixir = { · 40 unmodified lines
1225 alias: 'variable'1303 alias: 'variable'
1226 },1304 },
1227 'attribute': {1305 'attribute': {
1228 pattern: /@[\S]+/,1306 pattern: /@\w+/,
1229 alias: 'variable'1307 alias: 'variable'
1230 },1308 },
1231 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,1309 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
@@ -1256,13 +1334,102 @@ Prism.languages.elixir.string.forEach(function(o) { · 24 unmodified lines
1256 pattern: /^#\{|\}$/,1334 pattern: /^#\{|\}$/,
1257 alias: 'punctuation'1335 alias: 'punctuation'
1258 },1336 },
1259 rest: Prism.util.clone(Prism.languages.elixir)1337 rest: Prism.languages.elixir
1260 }1338 }
1261 }1339 }
1262 };1340 };
1263});1341});
1264 1342
1265 1343
1344Prism.languages['markup-templating'] = {};
1345
1346Object.defineProperties(Prism.languages['markup-templating'], {
1347 buildPlaceholders: {
1348 // Tokenize all inline templating expressions matching placeholderPattern
1349 // If the replaceFilter function is provided, it will be called with every match.
1350 // If it returns false, the match will not be replaced.
1351 value: function (env, language, placeholderPattern, replaceFilter) {
1352 if (env.language !== language) {
1353 return;
1354 }
1355
1356 env.tokenStack = [];
1357
1358 env.code = env.code.replace(placeholderPattern, function(match) {
1359 if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
1360 return match;
1361 }
1362 var i = env.tokenStack.length;
1363 // Check for existing strings
1364 while (env.code.indexOf('___' + language.toUpperCase() + i + '___') !== -1)
1365 ++i;
1366
1367 // Create a sparse array
1368 env.tokenStack[i] = match;
1369
1370 return '___' + language.toUpperCase() + i + '___';
1371 });
1372
1373 // Switch the grammar to markup
1374 env.grammar = Prism.languages.markup;
1375 }
1376 },
1377 tokenizePlaceholders: {
1378 // Replace placeholders with proper tokens after tokenizing
1379 value: function (env, language) {
1380 if (env.language !== language || !env.tokenStack) {
1381 return;
1382 }
1383
1384 // Switch the grammar back
1385 env.grammar = Prism.languages[language];
1386
1387 var j = 0;
1388 var keys = Object.keys(env.tokenStack);
1389 var walkTokens = function (tokens) {
1390 if (j >= keys.length) {
1391 return;
1392 }
1393 for (var i = 0; i < tokens.length; i++) {
1394 var token = tokens[i];
1395 if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
1396 var k = keys[j];
1397 var t = env.tokenStack[k];
1398 var s = typeof token === 'string' ? token : token.content;
1399
1400 var index = s.indexOf('___' + language.toUpperCase() + k + '___');
1401 if (index > -1) {
1402 ++j;
1403 var before = s.substring(0, index);
1404 var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar, language), 'language-' + language, t);
1405 var after = s.substring(index + ('___' + language.toUpperCase() + k + '___').length);
1406 var replacement;
1407 if (before || after) {
1408 replacement = [before, middle, after].filter(function (v) { return !!v; });
1409 walkTokens(replacement);
1410 } else {
1411 replacement = middle;
1412 }
1413 if (typeof token === 'string') {
1414 Array.prototype.splice.apply(tokens, [i, 1].concat(replacement));
1415 } else {
1416 token.content = replacement;
1417 }
1418
1419 if (j >= keys.length) {
1420 break;
1421 }
1422 }
1423 } else if (token.content && typeof token.content !== 'string') {
1424 walkTokens(token.content);
1425 }
1426 }
1427 };
1428
1429 walkTokens(env.tokens);
1430 }
1431 }
1432});
1266Prism.languages.erlang = {1433Prism.languages.erlang = {
1267 'comment': /%.+/,1434 'comment': /%.+/,
1268 'string': {1435 'string': {
@@ -1282,7 +1449,7 @@ Prism.languages.erlang = { · 13 unmodified lines
1282 'number': [1449 'number': [
1283 /\$\\?./,1450 /\$\\?./,
1284 /\d+#[a-z0-9]+/i,1451 /\d+#[a-z0-9]+/i,
1285 /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/1452 /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
1286 ],1453 ],
1287 'function': /\b[a-z][\w@]*(?=\()/,1454 'function': /\b[a-z][\w@]*(?=\()/,
1288 'variable': {1455 'variable': {
@@ -1312,7 +1479,7 @@ Prism.languages.go = Prism.languages.extend('clike', { · 23 unmodified lines
1312 '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/,1479 '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/,
1313 'boolean': /\b(?:_|iota|nil|true|false)\b/,1480 'boolean': /\b(?:_|iota|nil|true|false)\b/,
1314 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,1481 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
1315 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,1482 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
1316 'string': {1483 'string': {
1317 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,1484 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
1318 greedy: true1485 greedy: true
@@ -1322,7 +1489,7 @@ delete Prism.languages.go['class-name']; · 3 unmodified lines
1322 1489
1323Prism.languages.java = Prism.languages.extend('clike', {1490Prism.languages.java = Prism.languages.extend('clike', {
1324 '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/,1491 '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/,
1325 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,1492 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp-]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?[df]?/i,
1326 'operator': {1493 'operator': {
1327 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,1494 pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
1328 lookbehind: true1495 lookbehind: true
@@ -1337,14 +1504,25 @@ Prism.languages.insertBefore('java','function', { · 8 unmodified lines
1337 }1504 }
1338});1505});
1339 1506
1507Prism.languages.insertBefore('java', 'class-name', {
1508 'generics': {
1509 pattern: /<\s*\w+(?:\.\w+)?(?:\s*,\s*\w+(?:\.\w+)?)*>/i,
1510 alias: 'function',
1511 inside: {
1512 keyword: Prism.languages.java.keyword,
1513 punctuation: /[<>(),.:]/
1514 }
1515 }
1516});
1517
1340Prism.languages.json = {1518Prism.languages.json = {
1341 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,1519 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
1342 'string': {1520 'string': {
1343 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,1521 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
1344 greedy: true1522 greedy: true
1345 },1523 },
1346 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,1524 'number': /-?\d+\.?\d*([Ee][+-]?\d+)?/,
1347 'punctuation': /[{}[\]);,]/,1525 'punctuation': /[{}[\],]/,
1348 'operator': /:/g,1526 'operator': /:/g,
1349 'boolean': /\b(?:true|false)\b/i,1527 'boolean': /\b(?:true|false)\b/i,
1350 'null': /\bnull\b/i1528 'null': /\bnull\b/i
@@ -1356,7 +1534,7 @@ Prism.languages.jsonp = Prism.languages.json; · 5 unmodified lines
1356 Prism.languages.kotlin = Prism.languages.extend('clike', {1534 Prism.languages.kotlin = Prism.languages.extend('clike', {
1357 'keyword': {1535 'keyword': {
1358 // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get1536 // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
1359 pattern: /(^|[^.])\b(?:abstract|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|else|enum|final|finally|for|fun|get|if|import|in|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|out|override|package|private|protected|public|reified|return|sealed|set|super|tailrec|this|throw|to|try|val|var|when|where|while)\b/,1537 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/,
1360 lookbehind: true1538 lookbehind: true
1361 },1539 },
1362 'function': [1540 'function': [
@@ -1366,7 +1544,7 @@ Prism.languages.jsonp = Prism.languages.json; · 3 unmodified lines
1366 lookbehind: true1544 lookbehind: true
1367 }1545 }
1368 ],1546 ],
1369 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,1547 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
1370 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/1548 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
1371 });1549 });
1372 1550
@@ -1400,7 +1578,7 @@ Prism.languages.jsonp = Prism.languages.json; · 27 unmodified lines
1400 pattern: /^\$\{|\}$/,1578 pattern: /^\$\{|\}$/,
1401 alias: 'variable'1579 alias: 'variable'
1402 },1580 },
1403 rest: Prism.util.clone(Prism.languages.kotlin)1581 rest: Prism.languages.kotlin
1404 }1582 }
1405 },1583 },
1406 {1584 {
@@ -1414,6 +1592,7 @@ Prism.languages.jsonp = Prism.languages.json; · 7 unmodified lines
1414 };1592 };
1415 1593
1416}(Prism));1594}(Prism));
1595
1417Prism.languages.lua = {1596Prism.languages.lua = {
1418 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,1597 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
1419 // \z may be used to skip the following space1598 // \z may be used to skip the following space
@@ -1434,16 +1613,68 @@ Prism.languages.lua = { · 14 unmodified lines
1434 ],1613 ],
1435 'punctuation': /[\[\](){},;]|\.+|:+/1614 'punctuation': /[\[\](){},;]|\.+|:+/
1436};1615};
1616(function(Prism) {
1617 Prism.languages.crystal = Prism.languages.extend('ruby', {
1618 keyword: [
1619 /\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/,
1620 {
1621 pattern: /(\.\s*)(?:is_a|responds_to)\?/,
1622 lookbehind: true
1623 }
1624 ],
1625
1626 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/
1627 });
1628
1629 Prism.languages.insertBefore('crystal', 'string', {
1630 attribute: {
1631 pattern: /@\[.+?\]/,
1632 alias: 'attr-name',
1633 inside: {
1634 delimiter: {
1635 pattern: /^@\[|\]$/,
1636 alias: 'tag'
1637 },
1638 rest: Prism.languages.crystal
1639 }
1640 },
1641
1642 expansion: [
1643 {
1644 pattern: /\{\{.+?\}\}/,
1645 inside: {
1646 delimiter: {
1647 pattern: /^\{\{|\}\}$/,
1648 alias: 'tag'
1649 },
1650 rest: Prism.languages.crystal
1651 }
1652 },
1653 {
1654 pattern: /\{%.+?%\}/,
1655 inside: {
1656 delimiter: {
1657 pattern: /^\{%|%\}$/,
1658 alias: 'tag'
1659 },
1660 rest: Prism.languages.crystal
1661 }
1662 }
1663 ]
1664 });
1665
1666}(Prism));
1667
1437Prism.languages.nginx = Prism.languages.extend('clike', {1668Prism.languages.nginx = Prism.languages.extend('clike', {
1438 'comment': {1669 'comment': {
1439 pattern: /(^|[^"{\\])#.*/,1670 pattern: /(^|[^"{\\])#.*/,
1440 lookbehind: true1671 lookbehind: true
1441 },1672 },
1442 '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)\b/i1673 '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)\b/i
1443});1674});
1444 1675
1445Prism.languages.insertBefore('nginx', 'keyword', {1676Prism.languages.insertBefore('nginx', 'keyword', {
1446 'variable': /\$[a-z_]+/i1677 'variable': /\$[a-z_]+/i
1447});1678});
1448Prism.languages.nim = {1679Prism.languages.nim = {
1449 'comment': /#.*/,1680 'comment': /#.*/,
@@ -1497,31 +1728,31 @@ Prism.languages.perl = { · 47 unmodified lines
1497 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,1728 pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1498 greedy: true1729 greedy: true
1499 },1730 },
1500 1731
1501 // q a...a1732 // q a...a
1502 {1733 {
1503 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,1734 pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
1504 greedy: true1735 greedy: true
1505 },1736 },
1506 1737
1507 // q(...)1738 // q(...)
1508 {1739 {
1509 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,1740 pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
1510 greedy: true1741 greedy: true
1511 },1742 },
1512 1743
1513 // q{...}1744 // q{...}
1514 {1745 {
1515 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,1746 pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
1516 greedy: true1747 greedy: true
1517 },1748 },
1518 1749
1519 // q[...]1750 // q[...]
1520 {1751 {
1521 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,1752 pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
1522 greedy: true1753 greedy: true
1523 },1754 },
1524 1755
1525 // q<...>1756 // q<...>
1526 {1757 {
1527 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,1758 pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
@@ -1547,31 +1778,31 @@ Prism.languages.perl = { · 19 unmodified lines
1547 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,1778 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
1548 greedy: true1779 greedy: true
1549 },1780 },
1550 1781
1551 // m a...a1782 // m a...a
1552 {1783 {
1553 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,1784 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
1554 greedy: true1785 greedy: true
1555 },1786 },
1556 1787
1557 // m(...)1788 // m(...)
1558 {1789 {
1559 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,1790 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
1560 greedy: true1791 greedy: true
1561 },1792 },
1562 1793
1563 // m{...}1794 // m{...}
1564 {1795 {
1565 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,1796 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
1566 greedy: true1797 greedy: true
1567 },1798 },
1568 1799
1569 // m[...]1800 // m[...]
1570 {1801 {
1571 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,1802 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
1572 greedy: true1803 greedy: true
1573 },1804 },
1574 1805
1575 // m<...>1806 // m<...>
1576 {1807 {
1577 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,1808 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
@@ -1586,42 +1817,42 @@ Prism.languages.perl = { · 8 unmodified lines
1586 lookbehind: true,1817 lookbehind: true,
1587 greedy: true1818 greedy: true
1588 },1819 },
1589 1820
1590 // s a...a...a1821 // s a...a...a
1591 {1822 {
1592 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,1823 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
1593 lookbehind: true,1824 lookbehind: true,
1594 greedy: true1825 greedy: true
1595 },1826 },
1596 1827
1597 // s(...)(...)1828 // s(...)(...)
1598 {1829 {
1599 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,1830 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
1600 lookbehind: true,1831 lookbehind: true,
1601 greedy: true1832 greedy: true
1602 },1833 },
1603 1834
1604 // s{...}{...}1835 // s{...}{...}
1605 {1836 {
1606 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,1837 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
1607 lookbehind: true,1838 lookbehind: true,
1608 greedy: true1839 greedy: true
1609 },1840 },
1610 1841
1611 // s[...][...]1842 // s[...][...]
1612 {1843 {
1613 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,1844 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
1614 lookbehind: true,1845 lookbehind: true,
1615 greedy: true1846 greedy: true
1616 },1847 },
1617 1848
1618 // s<...><...>1849 // s<...><...>
1619 {1850 {
1620 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,1851 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
1621 lookbehind: true,1852 lookbehind: true,
1622 greedy: true1853 greedy: true
1623 },1854 },
1624 1855
1625 // /.../1856 // /.../
1626 // The look-ahead tries to prevent two divisions on1857 // The look-ahead tries to prevent two divisions on
1627 // the same line from being highlighted as regex.1858 // the same line from being highlighted as regex.
@@ -1665,7 +1896,7 @@ Prism.languages.perl = { · 37 unmodified lines
1665 }1896 }
1666 },1897 },
1667 '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|say|state|sub|switch|undef|unless|until|use|when|while)\b/,1898 '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|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
1668 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,1899 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
1669 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,1900 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
1670 'punctuation': /[{}[\];(),:]/1901 'punctuation': /[{}[\];(),:]/
1671};1902};
@@ -1682,110 +1913,211 @@ Prism.languages.perl = { · 10 unmodified lines
1682 * Adds the following new token classes:1913 * Adds the following new token classes:
1683 * constant, delimiter, variable, function, package1914 * constant, delimiter, variable, function, package
1684 */1915 */
1916(function (Prism) {
1917 Prism.languages.php = Prism.languages.extend('clike', {
1918 '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,
1919 'constant': /\b[A-Z0-9_]{2,}\b/,
1920 'comment': {
1921 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1922 lookbehind: true
1923 }
1924 });
1685 1925
1686Prism.languages.php = Prism.languages.extend('clike', {1926 Prism.languages.insertBefore('php', 'string', {
1687 '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,1927 'shell-comment': {
1688 'constant': /\b[A-Z0-9_]{2,}\b/,1928 pattern: /(^|[^\\])#.*/,
1689 'comment': {1929 lookbehind: true,
1690 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,1930 alias: 'comment'
1691 lookbehind: true1931 }
1692 }1932 });
1693});
1694 1933
1695// Shell-like comments are matched after strings, because they are less1934 Prism.languages.insertBefore('php', 'keyword', {
1696// common than strings containing hashes...1935 'delimiter': {
1697Prism.languages.insertBefore('php', 'class-name', {1936 pattern: /\?>|<\?(?:php|=)?/i,
1698 'shell-comment': {1937 alias: 'important'
1699 pattern: /(^|[^\\])#.*/,1938 },
1700 lookbehind: true,1939 'variable': /\$+(?:\w+\b|(?={))/i,
1701 alias: 'comment'1940 'package': {
1702 }1941 pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1703});1942 lookbehind: true,
1943 inside: {
1944 punctuation: /\\/
1945 }
1946 }
1947 });
1704 1948
1705Prism.languages.insertBefore('php', 'keyword', {1949 // Must be defined after the function pattern
1706 'delimiter': {1950 Prism.languages.insertBefore('php', 'operator', {
1707 pattern: /\?>|<\?(?:php|=)?/i,1951 'property': {
1708 alias: 'important'1952 pattern: /(->)[\w]+/,
1709 },1953 lookbehind: true
1710 'variable': /\$\w+\b/i,
1711 'package': {
1712 pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
1713 lookbehind: true,
1714 inside: {
1715 punctuation: /\\/
1716 }1954 }
1717 }1955 });
1718});
1719 1956
1720// Must be defined after the function pattern1957 Prism.languages.insertBefore('php', 'string', {
1721Prism.languages.insertBefore('php', 'operator', {1958 'nowdoc-string': {
1722 'property': {1959 pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
1723 pattern: /(->)[\w]+/,1960 greedy: true,
1724 lookbehind: true1961 alias: 'string',
1725 }1962 inside: {
1726});1963 'delimiter': {
1964 pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
1965 alias: 'symbol',
1966 inside: {
1967 'punctuation': /^<<<'?|[';]$/
1968 }
1969 }
1970 }
1971 },
1972 'heredoc-string': {
1973 pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
1974 greedy: true,
1975 alias: 'string',
1976 inside: {
1977 'delimiter': {
1978 pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
1979 alias: 'symbol',
1980 inside: {
1981 'punctuation': /^<<<"?|[";]$/
1982 }
1983 },
1984 'interpolation': null // See below
1985 }
1986 },
1987 'single-quoted-string': {
1988 pattern: /'(?:\\[\s\S]|[^\\'])*'/,
1989 greedy: true,
1990 alias: 'string'
1991 },
1992 'double-quoted-string': {
1993 pattern: /"(?:\\[\s\S]|[^\\"])*"/,
1994 greedy: true,
1995 alias: 'string',
1996 inside: {
1997 'interpolation': null // See below
1998 }
1999 }
2000 });
2001 // The different types of PHP strings "replace" the C-like standard string
2002 delete Prism.languages.php['string'];
1727 2003
1728// Add HTML support if the markup language exists2004 var string_interpolation = {
1729if (Prism.languages.markup) {2005 pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
2006 lookbehind: true,
2007 inside: {
2008 rest: Prism.languages.php
2009 }
2010 };
2011 Prism.languages.php['heredoc-string'].inside['interpolation'] = string_interpolation;
2012 Prism.languages.php['double-quoted-string'].inside['interpolation'] = string_interpolation;
1730 2013
1731 // Tokenize all inline PHP blocks that are wrapped in <?php ?>2014 Prism.hooks.add('before-tokenize', function(env) {
1732 // This allows for easy PHP + markup highlighting2015 if (!/(?:<\?php|<\?)/ig.test(env.code)) {
1733 Prism.hooks.add('before-highlight', function(env) {
1734 if (env.language !== 'php' || !/(?:<\?php|<\?)/ig.test(env.code)) {
1735 return;2016 return;
1736 }2017 }
1737 2018
1738 env.tokenStack = [];2019 var phpPattern = /(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig;
1739 2020 Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
1740 env.backupCode = env.code;2021 });
1741 env.code = env.code.replace(/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig, function(match) {
1742 var i = env.tokenStack.length;
1743 // Check for existing strings
1744 while (env.backupCode.indexOf('___PHP' + i + '___') !== -1)
1745 ++i;
1746
1747 // Create a sparse array
1748 env.tokenStack[i] = match;
1749
1750 return '___PHP' + i + '___';
1751 });
1752 2022
1753 // Switch the grammar to markup2023 Prism.hooks.add('after-tokenize', function(env) {
1754 env.grammar = Prism.languages.markup;2024 Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
1755 });2025 });
1756 2026
1757 // Restore env.code for other plugins (e.g. line-numbers)2027}(Prism));
1758 Prism.hooks.add('before-insert', function(env) {2028Prism.languages.sql= {
1759 if (env.language === 'php' && env.backupCode) {2029 'comment': {
1760 env.code = env.backupCode;2030 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
1761 delete env.backupCode;2031 lookbehind: true
2032 },
2033 'string' : {
2034 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2035 greedy: true,
2036 lookbehind: true
2037 },
2038 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2039 '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?
2040 '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,
2041 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2042 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
2043 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2044 'punctuation': /[;[\]()`,.]/
2045};
2046Prism.languages.scss = Prism.languages.extend('css', {
2047 'comment': {
2048 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
2049 lookbehind: true
2050 },
2051 'atrule': {
2052 pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
2053 inside: {
2054 'rule': /@[\w-]+/
2055 // See rest below
1762 }2056 }
1763 });2057 },
2058 // url, compassified
2059 'url': /(?:[-a-z]+-)*url(?=\()/i,
2060 // CSS selector regex is not appropriate for Sass
2061 // since there can be lot more things (var, @ directive, nesting..)
2062 // a selector must start at the end of a property or after a brace (end of other rules or nesting)
2063 // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
2064 // 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
2065 // can "pass" as a selector- e.g: proper#{$erty})
2066 // this one was hard to do, so please be careful if you edit this one :)
2067 'selector': {
2068 // Initial look-ahead is used to prevent matching of blank selectors
2069 pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
2070 inside: {
2071 'parent': {
2072 pattern: /&/,
2073 alias: 'important'
2074 },
2075 'placeholder': /%[-\w]+/,
2076 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2077 }
2078 }
2079});
1764 2080
1765 // Re-insert the tokens after highlighting2081Prism.languages.insertBefore('scss', 'atrule', {
1766 Prism.hooks.add('after-highlight', function(env) {2082 'keyword': [
1767 if (env.language !== 'php' || !env.tokenStack) {2083 /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
1768 return;2084 {
2085 pattern: /( +)(?:from|through)(?= )/,
2086 lookbehind: true
1769 }2087 }
2088 ]
2089});
1770 2090
1771 // Switch the grammar back2091Prism.languages.scss.property = {
1772 env.grammar = Prism.languages.php;2092 pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2093 inside: {
2094 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2095 }
2096};
1773 2097
1774 for (var i = 0, keys = Object.keys(env.tokenStack); i < keys.length; ++i) {2098Prism.languages.insertBefore('scss', 'important', {
1775 var k = keys[i];2099 // var and interpolated vars
1776 var t = env.tokenStack[k];2100 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2101});
1777 2102
1778 // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns2103Prism.languages.insertBefore('scss', 'function', {
1779 env.highlightedCode = env.highlightedCode.replace('___PHP' + k + '___',2104 'placeholder': {
1780 "<span class=\"token php language-php\">" +2105 pattern: /%[-\w]+/,
1781 Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +2106 alias: 'selector'
1782 "</span>");2107 },
1783 }2108 'statement': {
2109 pattern: /\B!(?:default|optional)\b/i,
2110 alias: 'keyword'
2111 },
2112 'boolean': /\b(?:true|false)\b/,
2113 'null': /\bnull\b/,
2114 'operator': {
2115 pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2116 lookbehind: true
2117 }
2118});
1784 2119
1785 env.element.innerHTML = env.highlightedCode;2120Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
1786 });
1787}
1788;
1789Prism.languages.python = {2121Prism.languages.python = {
1790 'comment': {2122 'comment': {
1791 pattern: /(^|[^\\])#.*/,2123 pattern: /(^|[^\\])#.*/,
@@ -1811,7 +2143,7 @@ Prism.languages.python = { · 19 unmodified lines
1811 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,2143 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
1812 '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/,2144 '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/,
1813 'boolean': /\b(?:True|False|None)\b/,2145 'boolean': /\b(?:True|False|None)\b/,
1814 'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,2146 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
1815 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,2147 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
1816 'punctuation': /[{}[\];(),.:]/2148 'punctuation': /[{}[\];(),.:]/
1817};2149};
@@ -1821,93 +2153,134 @@ Prism.languages.python = { · 3 unmodified lines
1821var javascript = Prism.util.clone(Prism.languages.javascript);2153var javascript = Prism.util.clone(Prism.languages.javascript);
1822 2154
1823Prism.languages.jsx = Prism.languages.extend('markup', javascript);2155Prism.languages.jsx = Prism.languages.extend('markup', javascript);
1824Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+|(?:\{[^}]*\})))?|\{\.{3}\w+\}))*\s*\/?>/i;2156Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
1825 2157
2158Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
1826Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;2159Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
1827 2160
1828Prism.languages.insertBefore('inside', 'attr-name', {2161Prism.languages.insertBefore('inside', 'attr-name', {
1829 'spread': {2162 'spread': {
1830 pattern: /\{\.{3}\w+\}/,2163 pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
1831 inside: {2164 inside: {
1832 'punctuation': /[{}]|\.{3}/,2165 'punctuation': /\.{3}|[{}.]/,
1833 'attr-value': /\w+/2166 'attr-value': /\w+/
1834 }2167 }
1835 }2168 }
1836}, Prism.languages.jsx.tag);2169}, Prism.languages.jsx.tag);
1837 2170
1838var jsxExpression = Prism.util.clone(Prism.languages.jsx);
1839
1840delete jsxExpression.punctuation;
1841
1842jsxExpression = Prism.languages.insertBefore('jsx', 'operator', {
1843 'punctuation': /=(?={)|[{}[\];(),.:]/
1844}, { jsx: jsxExpression });
1845
1846Prism.languages.insertBefore('inside', 'attr-value',{2171Prism.languages.insertBefore('inside', 'attr-value',{
1847 'script': {2172 'script': {
1848 // Allow for one level of nesting2173 // Allow for two levels of nesting
1849 pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i,2174 pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
1850 inside: jsxExpression,2175 inside: {
2176 'script-punctuation': {
2177 pattern: /^=(?={)/,
2178 alias: 'punctuation'
2179 },
2180 rest: Prism.languages.jsx
2181 },
1851 'alias': 'language-javascript'2182 'alias': 'language-javascript'
1852 }2183 }
1853}, Prism.languages.jsx.tag);2184}, Prism.languages.jsx.tag);
1854 2185
1855}(Prism));2186// The following will handle plain text inside tags
2187var stringifyToken = function (token) {
2188 if (!token) {
2189 return '';
2190 }
2191 if (typeof token === 'string') {
2192 return token;
2193 }
2194 if (typeof token.content === 'string') {
2195 return token.content;
2196 }
2197 return token.content.map(stringifyToken).join('');
2198};
1856 2199
1857(function(Prism) {2200var walkTokens = function (tokens) {
1858 Prism.languages.crystal = Prism.languages.extend('ruby', {2201 var openedTags = [];
1859 keyword: [2202 for (var i = 0; i < tokens.length; i++) {
1860 /\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/,2203 var token = tokens[i];
1861 {2204 var notTagNorBrace = false;
1862 pattern: /(\.\s*)(?:is_a|responds_to)\?/,2205
1863 lookbehind: true2206 if (typeof token !== 'string') {
1864 }2207 if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
1865 ],2208 // We found a tag, now find its kind
2209
2210 if (token.content[0].content[0].content === '</') {
2211 // Closing tag
2212 if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
2213 // Pop matching opening tag
2214 openedTags.pop();
2215 }
2216 } else {
2217 if (token.content[token.content.length - 1].content === '/>') {
2218 // Autoclosed tag, ignore
2219 } else {
2220 // Opening tag
2221 openedTags.push({
2222 tagName: stringifyToken(token.content[0].content[1]),
2223 openedBraces: 0
2224 });
2225 }
2226 }
2227 } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
1866 2228
1867 number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:\d(?:[0-9_]*\d)?)(?:\.[0-9_]*\d)?(?:[eE][+-]?[0-9_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/2229 // Here we might have entered a JSX context inside a tag
1868 });2230 openedTags[openedTags.length - 1].openedBraces++;
1869 2231
1870 var rest = Prism.util.clone(Prism.languages.crystal);2232 } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
1871 2233
1872 Prism.languages.insertBefore('crystal', 'string', {2234 // Here we might have left a JSX context inside a tag
1873 attribute: {2235 openedTags[openedTags.length - 1].openedBraces--;
1874 pattern: /@\[.+?\]/,
1875 alias: 'attr-name',
1876 inside: {
1877 delimiter: {
1878 pattern: /^@\[|\]$/,
1879 alias: 'tag'
1880 },
1881 rest: rest
1882 }
1883 },
1884 2236
1885 expansion: [2237 } else {
1886 {2238 notTagNorBrace = true
1887 pattern: /\{\{.+?\}\}/,
1888 inside: {
1889 delimiter: {
1890 pattern: /^\{\{|\}\}$/,
1891 alias: 'tag'
1892 },
1893 rest: rest
1894 }2239 }
1895 },2240 }
1896 {2241 if (notTagNorBrace || typeof token === 'string') {
1897 pattern: /\{%.+?%\}/,2242 if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
1898 inside: {2243 // Here we are inside a tag, and not inside a JSX context.
1899 delimiter: {2244 // That's plain text: drop any tokens matched.
1900 pattern: /^\{%|%\}$/,2245 var plainText = stringifyToken(token);
1901 alias: 'tag'2246
1902 },2247 // And merge text with adjacent text
1903 rest: rest2248 if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
2249 plainText += stringifyToken(tokens[i + 1]);
2250 tokens.splice(i + 1, 1);
2251 }
2252 if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
2253 plainText = stringifyToken(tokens[i - 1]) + plainText;
2254 tokens.splice(i - 1, 1);
2255 i--;
2256 }
2257
2258 tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
1904 }2259 }
1905 }2260 }
1906 ]2261
1907 });2262 if (token.content && typeof token.content !== 'string') {
2263 walkTokens(token.content);
2264 }
2265 }
2266};
2267
2268Prism.hooks.add('after-tokenize', function (env) {
2269 if (env.language !== 'jsx' && env.language !== 'tsx') {
2270 return;
2271 }
2272 walkTokens(env.tokens);
2273});
1908 2274
1909}(Prism));2275}(Prism));
1910 2276
2277Prism.languages.typescript = Prism.languages.extend('javascript', {
2278 // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2279 '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|module|declare|constructor|namespace|abstract|require|type)\b/,
2280 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console)\b/,
2281});
2282
2283Prism.languages.ts = Prism.languages.typescript;
1911/* TODO2284/* TODO
1912 Add support for Markdown notation inside doc comments2285 Add support for Markdown notation inside doc comments
1913 Add support for nested block comments...2286 Add support for nested block comments...
@@ -1932,10 +2305,18 @@ Prism.languages.rust = { · 18 unmodified lines
1932 greedy: true2305 greedy: true
1933 },2306 },
1934 {2307 {
1935 pattern: /b?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,2308 pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
1936 greedy: true2309 greedy: true
1937 }2310 }
1938 ],2311 ],
2312 'char': {
2313 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
2314 alias: 'string'
2315 },
2316 'lifetime-annotation': {
2317 pattern: /'[^\s>']+/,
2318 alias: 'symbol'
2319 },
1939 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,2320 'keyword': /\b(?:abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|match|mod|move|mut|offsetof|once|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/,
1940 2321
1941 'attribute': {2322 'attribute': {
@@ -1955,7 +2336,7 @@ Prism.languages.rust = { · 13 unmodified lines
1955 },2336 },
1956 2337
1957 // Hex, oct, bin, dec numbers with visual separators and type suffix2338 // Hex, oct, bin, dec numbers with visual separators and type suffix
1958 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,2339 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:[iu](?:8|16|32|64)?|f32|f64))?\b/,
1959 2340
1960 // Closure params should not be confused with bitwise OR |2341 // Closure params should not be confused with bitwise OR |
1961 'closure-params': {2342 'closure-params': {
@@ -1966,107 +2347,8 @@ Prism.languages.rust = { · 4 unmodified lines
1966 }2347 }
1967 },2348 },
1968 'punctuation': /[{}[\];(),:]|\.+|->/,2349 'punctuation': /[{}[\];(),:]|\.+|->/,
1969 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/2350 'operator': /[-+*\/%!^]=?|=[=>]?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
1970};2351};
1971Prism.languages.scss = Prism.languages.extend('css', {
1972 'comment': {
1973 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
1974 lookbehind: true
1975 },
1976 'atrule': {
1977 pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
1978 inside: {
1979 'rule': /@[\w-]+/
1980 // See rest below
1981 }
1982 },
1983 // url, compassified
1984 'url': /(?:[-a-z]+-)*url(?=\()/i,
1985 // CSS selector regex is not appropriate for Sass
1986 // since there can be lot more things (var, @ directive, nesting..)
1987 // a selector must start at the end of a property or after a brace (end of other rules or nesting)
1988 // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
1989 // 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
1990 // can "pass" as a selector- e.g: proper#{$erty})
1991 // this one was hard to do, so please be careful if you edit this one :)
1992 'selector': {
1993 // Initial look-ahead is used to prevent matching of blank selectors
1994 pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
1995 inside: {
1996 'parent': {
1997 pattern: /&/,
1998 alias: 'important'
1999 },
2000 'placeholder': /%[-\w]+/,
2001 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2002 }
2003 }
2004});
2005
2006Prism.languages.insertBefore('scss', 'atrule', {
2007 'keyword': [
2008 /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
2009 {
2010 pattern: /( +)(?:from|through)(?= )/,
2011 lookbehind: true
2012 }
2013 ]
2014});
2015
2016Prism.languages.scss.property = {
2017 pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
2018 inside: {
2019 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2020 }
2021};
2022
2023Prism.languages.insertBefore('scss', 'important', {
2024 // var and interpolated vars
2025 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
2026});
2027
2028Prism.languages.insertBefore('scss', 'function', {
2029 'placeholder': {
2030 pattern: /%[-\w]+/,
2031 alias: 'selector'
2032 },
2033 'statement': {
2034 pattern: /\B!(?:default|optional)\b/i,
2035 alias: 'keyword'
2036 },
2037 'boolean': /\b(?:true|false)\b/,
2038 'null': /\bnull\b/,
2039 'operator': {
2040 pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
2041 lookbehind: true
2042 }
2043});
2044
2045Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
2046Prism.languages.sql= {
2047 'comment': {
2048 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
2049 lookbehind: true
2050 },
2051 'string' : {
2052 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
2053 greedy: true,
2054 lookbehind: true
2055 },
2056 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
2057 'function': /\b(?:COUNT|SUM|AVG|MIN|MAX|FIRST|LAST|UCASE|LCASE|MID|LEN|ROUND|NOW|FORMAT)(?=\s*\()/i, // Should we highlight user defined functions too?
2058 '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 VARYING|CHARACTER (?:SET|VARYING)|CHARSET|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COLUMNS|COMMENT|COMMIT|COMMITTED|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|DATA(?:BASES?)?|DATE(?:TIME)?|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITER(?:S)?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE(?: PRECISION)?|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE KEY|ELSE|ENABLE|ENCLOSED BY|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPE(?:D BY)?|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|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTO|INVOKER|ISOLATION LEVEL|JOIN|KEYS?|KILL|LANGUAGE SQL|LAST|LEFT|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MODIFIES SQL DATA|MODIFY|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL(?: CHAR VARYING| CHARACTER(?: VARYING)?| VARCHAR)?|NATURAL|NCHAR(?: VARCHAR)?|NEXT|NO(?: SQL|CHECK|CYCLE)?|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|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READ(?:S SQL DATA|TEXT)?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEATABLE|REPLICATION|REQUIRE|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE MODE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|START(?:ING BY)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED BY|TEXT(?:SIZE)?|THEN|TIMESTAMP|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNPIVOT|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?)\b/i,
2059 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
2060 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
2061 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
2062 'punctuation': /[;[\]()`,.]/
2063};
2064Prism.languages.typescript = Prism.languages.extend('javascript', {
2065 // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
2066 '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|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
2067});
2068
2069Prism.languages.ts = Prism.languages.typescript;
2070Prism.languages.yaml = {2352Prism.languages.yaml = {
2071 'scalar': {2353 'scalar': {
2072 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,2354 pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
@@ -2105,11 +2387,10 @@ Prism.languages.yaml = { · 32 unmodified lines
2105 greedy: true2387 greedy: true
2106 },2388 },
2107 'number': {2389 'number': {
2108 pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+\-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,2390 pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
2109 lookbehind: true2391 lookbehind: true
2110 },2392 },
2111 'tag': /![^\s]+/,2393 'tag': /![^\s]+/,
2112 'important': /[&*][\w]+/,2394 'important': /[&*][\w]+/,
2113 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./2395 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
2114};2396};
2115
assets/javascripts/views/content/root_page.coffee+0−4
@@ -19,10 +19,6 @@ class app.views.RootPage extends app.View · 18 unmodified lines
19 else19 else
20 'intro'20 'intro'
21 21
22 # temporary
23 if location.host is 'devdocs.io' and location.protocol is 'http:'
24 tmpl = 'httpWarning'
25
26 @append @tmpl(tmpl)22 @append @tmpl(tmpl)
27 return23 return
28 24
assets/javascripts/views/content/settings_page.coffee+3−4
@@ -24,10 +24,9 @@ class app.views.SettingsPage extends app.View · 23 unmodified lines
24 'Preferences'24 'Preferences'
25 25
26 toggleDark: (enable) ->26 toggleDark: (enable) ->
27 css = $('link[rel="stylesheet"][data-alt]')27 html = document.documentElement
28 alt = css.getAttribute('data-alt')28 html.classList.toggle('_theme-default')
29 css.setAttribute('data-alt', css.getAttribute('href'))29 html.classList.toggle('_theme-dark')
30 css.setAttribute('href', alt)
31 app.settings.set('dark', !!enable)30 app.settings.set('dark', !!enable)
32 app.appCache?.updateInBackground()31 app.appCache?.updateInBackground()
33 return32 return
assets/javascripts/views/search/search.coffee+5−0
@@ -17,6 +17,7 @@ class app.views.Search extends app.View · 16 unmodified lines
17 typing: 'focus'17 typing: 'focus'
18 altG: 'google'18 altG: 'google'
19 altS: 'stackoverflow'19 altS: 'stackoverflow'
20 altD: 'duckduckgo'
20 21
21 @routes:22 @routes:
22 after: 'afterRoute'23 after: 'afterRoute'
@@ -113,6 +114,10 @@ class app.views.Search extends app.View · 90 unmodified lines
113 @externalSearch "https://stackoverflow.com/search?q="114 @externalSearch "https://stackoverflow.com/search?q="
114 return115 return
115 116
117 duckduckgo: =>
118 @externalSearch "https://duckduckgo.com/?t=devdocs&q="
119 return
120
116 onResults: (results) =>121 onResults: (results) =>
117 @hasResults = true if results.length122 @hasResults = true if results.length
118 @trigger 'results', results, @flags123 @trigger 'results', results, @flags