prism.js 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613
  1. /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+elixir+go+json+kotlin+lua+nginx+perl+php+python+crystal+rust+scss+sql+typescript */
  2. var _self = (typeof window !== 'undefined')
  3. ? window // if in browser
  4. : (
  5. (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
  6. ? self // if in worker
  7. : {} // if in node js
  8. );
  9. /**
  10. * Prism: Lightweight, robust, elegant syntax highlighting
  11. * MIT license http://www.opensource.org/licenses/mit-license.php/
  12. * @author Lea Verou http://lea.verou.me
  13. */
  14. var Prism = (function(){
  15. // Private helper vars
  16. var lang = /\blang(?:uage)?-(\w+)\b/i;
  17. var uniqueId = 0;
  18. var _ = _self.Prism = {
  19. util: {
  20. encode: function (tokens) {
  21. if (tokens instanceof Token) {
  22. return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
  23. } else if (_.util.type(tokens) === 'Array') {
  24. return tokens.map(_.util.encode);
  25. } else {
  26. return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
  27. }
  28. },
  29. type: function (o) {
  30. return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
  31. },
  32. objId: function (obj) {
  33. if (!obj['__id']) {
  34. Object.defineProperty(obj, '__id', { value: ++uniqueId });
  35. }
  36. return obj['__id'];
  37. },
  38. // Deep clone a language definition (e.g. to extend it)
  39. clone: function (o) {
  40. var type = _.util.type(o);
  41. switch (type) {
  42. case 'Object':
  43. var clone = {};
  44. for (var key in o) {
  45. if (o.hasOwnProperty(key)) {
  46. clone[key] = _.util.clone(o[key]);
  47. }
  48. }
  49. return clone;
  50. case 'Array':
  51. // Check for existence for IE8
  52. return o.map && o.map(function(v) { return _.util.clone(v); });
  53. }
  54. return o;
  55. }
  56. },
  57. languages: {
  58. extend: function (id, redef) {
  59. var lang = _.util.clone(_.languages[id]);
  60. for (var key in redef) {
  61. lang[key] = redef[key];
  62. }
  63. return lang;
  64. },
  65. /**
  66. * Insert a token before another token in a language literal
  67. * As this needs to recreate the object (we cannot actually insert before keys in object literals),
  68. * we cannot just provide an object, we need anobject and a key.
  69. * @param inside The key (or language id) of the parent
  70. * @param before The key to insert before. If not provided, the function appends instead.
  71. * @param insert Object with the key/value pairs to insert
  72. * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
  73. */
  74. insertBefore: function (inside, before, insert, root) {
  75. root = root || _.languages;
  76. var grammar = root[inside];
  77. if (arguments.length == 2) {
  78. insert = arguments[1];
  79. for (var newToken in insert) {
  80. if (insert.hasOwnProperty(newToken)) {
  81. grammar[newToken] = insert[newToken];
  82. }
  83. }
  84. return grammar;
  85. }
  86. var ret = {};
  87. for (var token in grammar) {
  88. if (grammar.hasOwnProperty(token)) {
  89. if (token == before) {
  90. for (var newToken in insert) {
  91. if (insert.hasOwnProperty(newToken)) {
  92. ret[newToken] = insert[newToken];
  93. }
  94. }
  95. }
  96. ret[token] = grammar[token];
  97. }
  98. }
  99. // Update references in other language definitions
  100. _.languages.DFS(_.languages, function(key, value) {
  101. if (value === root[inside] && key != inside) {
  102. this[key] = ret;
  103. }
  104. });
  105. return root[inside] = ret;
  106. },
  107. // Traverse a language definition with Depth First Search
  108. DFS: function(o, callback, type, visited) {
  109. visited = visited || {};
  110. for (var i in o) {
  111. if (o.hasOwnProperty(i)) {
  112. callback.call(o, i, o[i], type || i);
  113. if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
  114. visited[_.util.objId(o[i])] = true;
  115. _.languages.DFS(o[i], callback, null, visited);
  116. }
  117. else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
  118. visited[_.util.objId(o[i])] = true;
  119. _.languages.DFS(o[i], callback, i, visited);
  120. }
  121. }
  122. }
  123. }
  124. },
  125. plugins: {},
  126. highlightAll: function(async, callback) {
  127. var env = {
  128. callback: callback,
  129. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  130. };
  131. _.hooks.run("before-highlightall", env);
  132. var elements = env.elements || document.querySelectorAll(env.selector);
  133. for (var i=0, element; element = elements[i++];) {
  134. _.highlightElement(element, async === true, env.callback);
  135. }
  136. },
  137. highlightElement: function(element, async, callback) {
  138. // Find language
  139. var language, grammar, parent = element;
  140. while (parent && !lang.test(parent.className)) {
  141. parent = parent.parentNode;
  142. }
  143. if (parent) {
  144. language = (parent.className.match(lang) || [,''])[1].toLowerCase();
  145. grammar = _.languages[language];
  146. }
  147. // Set language on the element, if not present
  148. element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  149. // Set language on the parent, for styling
  150. parent = element.parentNode;
  151. if (/pre/i.test(parent.nodeName)) {
  152. parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  153. }
  154. var code = element.textContent;
  155. var env = {
  156. element: element,
  157. language: language,
  158. grammar: grammar,
  159. code: code
  160. };
  161. _.hooks.run('before-sanity-check', env);
  162. if (!env.code || !env.grammar) {
  163. _.hooks.run('complete', env);
  164. return;
  165. }
  166. _.hooks.run('before-highlight', env);
  167. // if (async && _self.Worker) {
  168. // var worker = new Worker(_.filename);
  169. // worker.onmessage = function(evt) {
  170. // env.highlightedCode = evt.data;
  171. // _.hooks.run('before-insert', env);
  172. // env.element.innerHTML = env.highlightedCode;
  173. // callback && callback.call(env.element);
  174. // _.hooks.run('after-highlight', env);
  175. // _.hooks.run('complete', env);
  176. // };
  177. // worker.postMessage(JSON.stringify({
  178. // language: env.language,
  179. // code: env.code,
  180. // immediateClose: true
  181. // }));
  182. // }
  183. // else {
  184. env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
  185. _.hooks.run('before-insert', env);
  186. env.element.innerHTML = env.highlightedCode;
  187. callback && callback.call(element);
  188. _.hooks.run('after-highlight', env);
  189. _.hooks.run('complete', env);
  190. // }
  191. },
  192. highlight: function (text, grammar, language) {
  193. var tokens = _.tokenize(text, grammar);
  194. return Token.stringify(_.util.encode(tokens), language);
  195. },
  196. tokenize: function(text, grammar, language) {
  197. var Token = _.Token;
  198. var strarr = [text];
  199. var rest = grammar.rest;
  200. if (rest) {
  201. for (var token in rest) {
  202. grammar[token] = rest[token];
  203. }
  204. delete grammar.rest;
  205. }
  206. tokenloop: for (var token in grammar) {
  207. if(!grammar.hasOwnProperty(token) || !grammar[token]) {
  208. continue;
  209. }
  210. var patterns = grammar[token];
  211. patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
  212. for (var j = 0; j < patterns.length; ++j) {
  213. var pattern = patterns[j],
  214. inside = pattern.inside,
  215. lookbehind = !!pattern.lookbehind,
  216. greedy = !!pattern.greedy,
  217. lookbehindLength = 0,
  218. alias = pattern.alias;
  219. if (greedy && !pattern.pattern.global) {
  220. // Without the global flag, lastIndex won't work
  221. var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
  222. pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
  223. }
  224. pattern = pattern.pattern || pattern;
  225. // Don’t cache length as it changes during the loop
  226. for (var i=0, pos = 0; i<strarr.length; pos += (strarr[i].matchedStr || strarr[i]).length, ++i) {
  227. var str = strarr[i];
  228. if (strarr.length > text.length) {
  229. // Something went terribly wrong, ABORT, ABORT!
  230. break tokenloop;
  231. }
  232. if (str instanceof Token) {
  233. continue;
  234. }
  235. pattern.lastIndex = 0;
  236. var match = pattern.exec(str),
  237. delNum = 1;
  238. // Greedy patterns can override/remove up to two previously matched tokens
  239. if (!match && greedy && i != strarr.length - 1) {
  240. pattern.lastIndex = pos;
  241. match = pattern.exec(text);
  242. if (!match) {
  243. break;
  244. }
  245. var from = match.index + (lookbehind ? match[1].length : 0),
  246. to = match.index + match[0].length,
  247. k = i,
  248. p = pos;
  249. for (var len = strarr.length; k < len && p < to; ++k) {
  250. p += (strarr[k].matchedStr || strarr[k]).length;
  251. // Move the index i to the element in strarr that is closest to from
  252. if (from >= p) {
  253. ++i;
  254. pos = p;
  255. }
  256. }
  257. /*
  258. * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
  259. * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
  260. */
  261. if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
  262. continue;
  263. }
  264. // Number of tokens to delete and replace with the new match
  265. delNum = k - i;
  266. str = text.slice(pos, p);
  267. match.index -= pos;
  268. }
  269. if (!match) {
  270. continue;
  271. }
  272. if(lookbehind) {
  273. lookbehindLength = match[1].length;
  274. }
  275. var from = match.index + lookbehindLength,
  276. match = match[0].slice(lookbehindLength),
  277. to = from + match.length,
  278. before = str.slice(0, from),
  279. after = str.slice(to);
  280. var args = [i, delNum];
  281. if (before) {
  282. args.push(before);
  283. }
  284. var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
  285. args.push(wrapped);
  286. if (after) {
  287. args.push(after);
  288. }
  289. Array.prototype.splice.apply(strarr, args);
  290. }
  291. }
  292. }
  293. return strarr;
  294. },
  295. hooks: {
  296. all: {},
  297. add: function (name, callback) {
  298. var hooks = _.hooks.all;
  299. hooks[name] = hooks[name] || [];
  300. hooks[name].push(callback);
  301. },
  302. run: function (name, env) {
  303. var callbacks = _.hooks.all[name];
  304. if (!callbacks || !callbacks.length) {
  305. return;
  306. }
  307. for (var i=0, callback; callback = callbacks[i++];) {
  308. callback(env);
  309. }
  310. }
  311. }
  312. };
  313. var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
  314. this.type = type;
  315. this.content = content;
  316. this.alias = alias;
  317. // Copy of the full string this token was created from
  318. this.matchedStr = matchedStr || null;
  319. this.greedy = !!greedy;
  320. };
  321. Token.stringify = function(o, language, parent) {
  322. if (typeof o == 'string') {
  323. return o;
  324. }
  325. if (_.util.type(o) === 'Array') {
  326. return o.map(function(element) {
  327. return Token.stringify(element, language, o);
  328. }).join('');
  329. }
  330. var env = {
  331. type: o.type,
  332. content: Token.stringify(o.content, language, parent),
  333. tag: 'span',
  334. classes: ['token', o.type],
  335. attributes: {},
  336. language: language,
  337. parent: parent
  338. };
  339. if (env.type == 'comment') {
  340. env.attributes['spellcheck'] = 'true';
  341. }
  342. if (o.alias) {
  343. var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
  344. Array.prototype.push.apply(env.classes, aliases);
  345. }
  346. _.hooks.run('wrap', env);
  347. var attributes = '';
  348. for (var name in env.attributes) {
  349. attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
  350. }
  351. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
  352. };
  353. // if (!_self.document) {
  354. // if (!_self.addEventListener) {
  355. // // in Node.js
  356. // return _self.Prism;
  357. // }
  358. // // In worker
  359. // _self.addEventListener('message', function(evt) {
  360. // var message = JSON.parse(evt.data),
  361. // lang = message.language,
  362. // code = message.code,
  363. // immediateClose = message.immediateClose;
  364. // _self.postMessage(_.highlight(code, _.languages[lang], lang));
  365. // if (immediateClose) {
  366. // _self.close();
  367. // }
  368. // }, false);
  369. // return _self.Prism;
  370. // }
  371. // //Get current script and highlight
  372. // var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
  373. // if (script) {
  374. // _.filename = script.src;
  375. // if (document.addEventListener && !script.hasAttribute('data-manual')) {
  376. // if(document.readyState !== "loading") {
  377. // if (window.requestAnimationFrame) {
  378. // window.requestAnimationFrame(_.highlightAll);
  379. // } else {
  380. // window.setTimeout(_.highlightAll, 16);
  381. // }
  382. // }
  383. // else {
  384. // document.addEventListener('DOMContentLoaded', _.highlightAll);
  385. // }
  386. // }
  387. // }
  388. return _self.Prism;
  389. })();
  390. if (typeof module !== 'undefined' && module.exports) {
  391. module.exports = Prism;
  392. }
  393. // hack for components to work correctly in node.js
  394. if (typeof global !== 'undefined') {
  395. global.Prism = Prism;
  396. }
  397. ;
  398. Prism.languages.markup = {
  399. 'comment': /<!--[\w\W]*?-->/,
  400. 'prolog': /<\?[\w\W]+?\?>/,
  401. 'doctype': /<!DOCTYPE[\w\W]+?>/,
  402. 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
  403. 'tag': {
  404. pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
  405. inside: {
  406. 'tag': {
  407. pattern: /^<\/?[^\s>\/]+/i,
  408. inside: {
  409. 'punctuation': /^<\/?/,
  410. 'namespace': /^[^\s>\/:]+:/
  411. }
  412. },
  413. 'attr-value': {
  414. pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
  415. inside: {
  416. 'punctuation': /[=>"']/
  417. }
  418. },
  419. 'punctuation': /\/?>/,
  420. 'attr-name': {
  421. pattern: /[^\s>\/]+/,
  422. inside: {
  423. 'namespace': /^[^\s>\/:]+:/
  424. }
  425. }
  426. }
  427. },
  428. 'entity': /&#?[\da-z]{1,8};/i
  429. };
  430. // Plugin to make entity title show the real entity, idea by Roman Komarov
  431. Prism.hooks.add('wrap', function(env) {
  432. if (env.type === 'entity') {
  433. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  434. }
  435. });
  436. Prism.languages.xml = Prism.languages.markup;
  437. Prism.languages.html = Prism.languages.markup;
  438. Prism.languages.mathml = Prism.languages.markup;
  439. Prism.languages.svg = Prism.languages.markup;
  440. Prism.languages.css = {
  441. 'comment': /\/\*[\w\W]*?\*\//,
  442. 'atrule': {
  443. pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
  444. inside: {
  445. 'rule': /@[\w-]+/
  446. // See rest below
  447. }
  448. },
  449. 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
  450. 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
  451. 'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
  452. 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
  453. 'important': /\B!important\b/i,
  454. 'function': /[-a-z0-9]+(?=\()/i,
  455. 'punctuation': /[(){};:]/
  456. };
  457. Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
  458. if (Prism.languages.markup) {
  459. Prism.languages.insertBefore('markup', 'tag', {
  460. 'style': {
  461. pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
  462. lookbehind: true,
  463. inside: Prism.languages.css,
  464. alias: 'language-css'
  465. }
  466. });
  467. Prism.languages.insertBefore('inside', 'attr-value', {
  468. 'style-attr': {
  469. pattern: /\s*style=("|').*?\1/i,
  470. inside: {
  471. 'attr-name': {
  472. pattern: /^\s*style/i,
  473. inside: Prism.languages.markup.tag.inside
  474. },
  475. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  476. 'attr-value': {
  477. pattern: /.+/i,
  478. inside: Prism.languages.css
  479. }
  480. },
  481. alias: 'language-css'
  482. }
  483. }, Prism.languages.markup.tag);
  484. };
  485. Prism.languages.clike = {
  486. 'comment': [
  487. {
  488. pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  489. lookbehind: true
  490. },
  491. {
  492. pattern: /(^|[^\\:])\/\/.*/,
  493. lookbehind: true
  494. }
  495. ],
  496. 'string': {
  497. pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  498. greedy: true
  499. },
  500. 'class-name': {
  501. pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
  502. lookbehind: true,
  503. inside: {
  504. punctuation: /(\.|\\)/
  505. }
  506. },
  507. 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  508. 'boolean': /\b(true|false)\b/,
  509. 'function': /[a-z0-9_]+(?=\()/i,
  510. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
  511. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
  512. 'punctuation': /[{}[\];(),.:]/
  513. };
  514. Prism.languages.javascript = Prism.languages.extend('clike', {
  515. '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/,
  516. 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
  517. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  518. 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
  519. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/
  520. });
  521. Prism.languages.insertBefore('javascript', 'keyword', {
  522. 'regex': {
  523. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
  524. lookbehind: true,
  525. greedy: true
  526. }
  527. });
  528. Prism.languages.insertBefore('javascript', 'string', {
  529. 'template-string': {
  530. pattern: /`(?:\\\\|\\?[^\\])*?`/,
  531. greedy: true,
  532. inside: {
  533. 'interpolation': {
  534. pattern: /\$\{[^}]+\}/,
  535. inside: {
  536. 'interpolation-punctuation': {
  537. pattern: /^\$\{|\}$/,
  538. alias: 'punctuation'
  539. },
  540. rest: Prism.languages.javascript
  541. }
  542. },
  543. 'string': /[\s\S]+/
  544. }
  545. }
  546. });
  547. if (Prism.languages.markup) {
  548. Prism.languages.insertBefore('markup', 'tag', {
  549. 'script': {
  550. pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
  551. lookbehind: true,
  552. inside: Prism.languages.javascript,
  553. alias: 'language-javascript'
  554. }
  555. });
  556. }
  557. Prism.languages.js = Prism.languages.javascript;
  558. Prism.languages.c = Prism.languages.extend('clike', {
  559. 'keyword': /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
  560. 'operator': /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
  561. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
  562. });
  563. Prism.languages.insertBefore('c', 'string', {
  564. 'macro': {
  565. // allow for multiline macro definitions
  566. // spaces after the # character compile fine with gcc
  567. pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,
  568. lookbehind: true,
  569. alias: 'property',
  570. inside: {
  571. // highlight the path of the include statement as a string
  572. 'string': {
  573. pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,
  574. lookbehind: true
  575. },
  576. // highlight macro directives as keywords
  577. 'directive': {
  578. pattern: /(#\s*)\b(define|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
  579. lookbehind: true,
  580. alias: 'keyword'
  581. }
  582. }
  583. },
  584. // highlight predefined macros as constants
  585. 'constant': /\b(__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|stdin|stdout|stderr)\b/
  586. });
  587. delete Prism.languages.c['class-name'];
  588. delete Prism.languages.c['boolean'];
  589. Prism.languages.cpp = Prism.languages.extend('c', {
  590. '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/,
  591. 'boolean': /\b(true|false)\b/,
  592. 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
  593. });
  594. Prism.languages.insertBefore('cpp', 'keyword', {
  595. 'class-name': {
  596. pattern: /(class\s+)[a-z0-9_]+/i,
  597. lookbehind: true
  598. }
  599. });
  600. (function(Prism) {
  601. // Ignore comments starting with { to privilege string interpolation highlighting
  602. var comment = /#(?!\{).+/,
  603. interpolation = {
  604. pattern: /#\{[^}]+\}/,
  605. alias: 'variable'
  606. };
  607. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  608. 'comment': comment,
  609. 'string': [
  610. // Strings are multiline
  611. {
  612. pattern: /'(?:\\?[^\\])*?'/,
  613. greedy: true,
  614. },
  615. {
  616. // Strings are multiline
  617. pattern: /"(?:\\?[^\\])*?"/,
  618. greedy: true,
  619. inside: {
  620. 'interpolation': interpolation
  621. }
  622. }
  623. ],
  624. 'keyword': /\b(and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,
  625. 'class-member': {
  626. pattern: /@(?!\d)\w+/,
  627. alias: 'variable'
  628. }
  629. });
  630. Prism.languages.insertBefore('coffeescript', 'comment', {
  631. 'multiline-comment': {
  632. pattern: /###[\s\S]+?###/,
  633. alias: 'comment'
  634. },
  635. // Block regexp can contain comments and interpolation
  636. 'block-regex': {
  637. pattern: /\/{3}[\s\S]*?\/{3}/,
  638. alias: 'regex',
  639. inside: {
  640. 'comment': comment,
  641. 'interpolation': interpolation
  642. }
  643. }
  644. });
  645. Prism.languages.insertBefore('coffeescript', 'string', {
  646. 'inline-javascript': {
  647. pattern: /`(?:\\?[\s\S])*?`/,
  648. inside: {
  649. 'delimiter': {
  650. pattern: /^`|`$/,
  651. alias: 'punctuation'
  652. },
  653. rest: Prism.languages.javascript
  654. }
  655. },
  656. // Block strings
  657. 'multiline-string': [
  658. {
  659. pattern: /'''[\s\S]*?'''/,
  660. greedy: true,
  661. alias: 'string'
  662. },
  663. {
  664. pattern: /"""[\s\S]*?"""/,
  665. greedy: true,
  666. alias: 'string',
  667. inside: {
  668. interpolation: interpolation
  669. }
  670. }
  671. ]
  672. });
  673. Prism.languages.insertBefore('coffeescript', 'keyword', {
  674. // Object property
  675. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  676. });
  677. delete Prism.languages.coffeescript['template-string'];
  678. }(Prism));
  679. /**
  680. * Original by Samuel Flores
  681. *
  682. * Adds the following new token classes:
  683. * constant, builtin, variable, symbol, regex
  684. */
  685. (function(Prism) {
  686. Prism.languages.ruby = Prism.languages.extend('clike', {
  687. 'comment': /#(?!\{[^\r\n]*?\}).*/,
  688. '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/
  689. });
  690. var interpolation = {
  691. pattern: /#\{[^}]+\}/,
  692. inside: {
  693. 'delimiter': {
  694. pattern: /^#\{|\}$/,
  695. alias: 'tag'
  696. },
  697. rest: Prism.util.clone(Prism.languages.ruby)
  698. }
  699. };
  700. Prism.languages.insertBefore('ruby', 'keyword', {
  701. 'regex': [
  702. {
  703. pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
  704. inside: {
  705. 'interpolation': interpolation
  706. }
  707. },
  708. {
  709. pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
  710. inside: {
  711. 'interpolation': interpolation
  712. }
  713. },
  714. {
  715. // Here we need to specifically allow interpolation
  716. pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
  717. inside: {
  718. 'interpolation': interpolation
  719. }
  720. },
  721. {
  722. pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
  723. inside: {
  724. 'interpolation': interpolation
  725. }
  726. },
  727. {
  728. pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
  729. inside: {
  730. 'interpolation': interpolation
  731. }
  732. },
  733. {
  734. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
  735. lookbehind: true
  736. }
  737. ],
  738. 'variable': /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
  739. 'symbol': /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/
  740. });
  741. Prism.languages.insertBefore('ruby', 'number', {
  742. 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
  743. 'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
  744. });
  745. Prism.languages.ruby.string = [
  746. {
  747. pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
  748. inside: {
  749. 'interpolation': interpolation
  750. }
  751. },
  752. {
  753. pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
  754. inside: {
  755. 'interpolation': interpolation
  756. }
  757. },
  758. {
  759. // Here we need to specifically allow interpolation
  760. pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
  761. inside: {
  762. 'interpolation': interpolation
  763. }
  764. },
  765. {
  766. pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
  767. inside: {
  768. 'interpolation': interpolation
  769. }
  770. },
  771. {
  772. pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
  773. inside: {
  774. 'interpolation': interpolation
  775. }
  776. },
  777. {
  778. pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
  779. inside: {
  780. 'interpolation': interpolation
  781. }
  782. }
  783. ];
  784. }(Prism));
  785. Prism.languages.elixir = {
  786. // Negative look-ahead is needed for string interpolation
  787. // Negative look-behind is needed to avoid highlighting markdown headers in
  788. // multi-line doc strings
  789. 'comment': {
  790. pattern: /(^|[^#])#(?![{#]).*/m,
  791. lookbehind: true
  792. },
  793. // ~r"""foo""", ~r'''foo''', ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
  794. 'regex': /~[rR](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[uismxfr]*/,
  795. 'string': [
  796. {
  797. // ~s"""foo""", ~s'''foo''', ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo}, ~s<foo>
  798. pattern: /~[cCsSwW](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|#\{[^}]+\}|[^}])+\}|<(?:\\>|[^>])+>)[csa]?/,
  799. inside: {
  800. // See interpolation below
  801. }
  802. },
  803. {
  804. pattern: /("""|''')[\s\S]*?\1/,
  805. inside: {
  806. // See interpolation below
  807. }
  808. },
  809. {
  810. // Multi-line strings are allowed
  811. pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,
  812. inside: {
  813. // See interpolation below
  814. }
  815. }
  816. ],
  817. 'atom': {
  818. // Look-behind prevents bad highlighting of the :: operator
  819. pattern: /(^|[^:]):\w+/,
  820. lookbehind: true,
  821. alias: 'symbol'
  822. },
  823. // Look-ahead prevents bad highlighting of the :: operator
  824. 'attr-name': /\w+:(?!:)/,
  825. 'capture': {
  826. // Look-behind prevents bad highlighting of the && operator
  827. pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
  828. lookbehind: true,
  829. alias: 'function'
  830. },
  831. 'argument': {
  832. // Look-behind prevents bad highlighting of the && operator
  833. pattern: /(^|[^&])&\d+/,
  834. lookbehind: true,
  835. alias: 'variable'
  836. },
  837. 'attribute': {
  838. pattern: /@[\S]+/,
  839. alias: 'variable'
  840. },
  841. 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
  842. 'keyword': /\b(?:after|alias|and|case|catch|cond|def(?:callback|exception|impl|module|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|require|rescue|try|unless|use|when)\b/,
  843. 'boolean': /\b(?:true|false|nil)\b/,
  844. 'operator': [
  845. /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
  846. {
  847. // We don't want to match <<
  848. pattern: /([^<])<(?!<)/,
  849. lookbehind: true
  850. },
  851. {
  852. // We don't want to match >>
  853. pattern: /([^>])>(?!>)/,
  854. lookbehind: true
  855. }
  856. ],
  857. 'punctuation': /<<|>>|[.,%\[\]{}()]/
  858. };
  859. Prism.languages.elixir.string.forEach(function(o) {
  860. o.inside = {
  861. 'interpolation': {
  862. pattern: /#\{[^}]+\}/,
  863. inside: {
  864. 'delimiter': {
  865. pattern: /^#\{|\}$/,
  866. alias: 'punctuation'
  867. },
  868. rest: Prism.util.clone(Prism.languages.elixir)
  869. }
  870. }
  871. };
  872. });
  873. Prism.languages.go = Prism.languages.extend('clike', {
  874. 'keyword': /\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
  875. '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/,
  876. 'boolean': /\b(_|iota|nil|true|false)\b/,
  877. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  878. 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
  879. 'string': /("|'|`)(\\?.|\r|\n)*?\1/
  880. });
  881. delete Prism.languages.go['class-name'];
  882. Prism.languages.json = {
  883. 'property': /".*?"(?=\s*:)/ig,
  884. 'string': /"(?!:)(\\?[^"])*?"(?!:)/g,
  885. 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,
  886. 'punctuation': /[{}[\]);,]/g,
  887. 'operator': /:/g,
  888. 'boolean': /\b(true|false)\b/gi,
  889. 'null': /\bnull\b/gi,
  890. };
  891. Prism.languages.jsonp = Prism.languages.json;
  892. (function (Prism) {
  893. Prism.languages.kotlin = Prism.languages.extend('clike', {
  894. 'keyword': {
  895. // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
  896. 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/,
  897. lookbehind: true
  898. },
  899. 'function': [
  900. /\w+(?=\s*\()/,
  901. {
  902. pattern: /(\.)\w+(?=\s*\{)/,
  903. lookbehind: true
  904. }
  905. ],
  906. 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,
  907. 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
  908. });
  909. delete Prism.languages.kotlin["class-name"];
  910. Prism.languages.insertBefore('kotlin', 'string', {
  911. 'raw-string': {
  912. pattern: /(["'])\1\1[\s\S]*?\1{3}/,
  913. alias: 'string'
  914. // See interpolation below
  915. }
  916. });
  917. Prism.languages.insertBefore('kotlin', 'keyword', {
  918. 'annotation': {
  919. pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
  920. alias: 'builtin'
  921. }
  922. });
  923. Prism.languages.insertBefore('kotlin', 'function', {
  924. 'label': {
  925. pattern: /\w+@|@\w+/,
  926. alias: 'symbol'
  927. }
  928. });
  929. var interpolation = [
  930. {
  931. pattern: /\$\{[^}]+\}/,
  932. inside: {
  933. delimiter: {
  934. pattern: /^\$\{|\}$/,
  935. alias: 'variable'
  936. },
  937. rest: Prism.util.clone(Prism.languages.kotlin)
  938. }
  939. },
  940. {
  941. pattern: /\$\w+/,
  942. alias: 'variable'
  943. }
  944. ];
  945. Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
  946. interpolation: interpolation
  947. };
  948. }(Prism));
  949. Prism.languages.lua = {
  950. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  951. // \z may be used to skip the following space
  952. 'string': {
  953. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  954. greedy: true
  955. },
  956. 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  957. 'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
  958. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  959. 'operator': [
  960. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  961. {
  962. // Match ".." but don't break "..."
  963. pattern: /(^|[^.])\.\.(?!\.)/,
  964. lookbehind: true
  965. }
  966. ],
  967. 'punctuation': /[\[\](){},;]|\.+|:+/
  968. };
  969. Prism.languages.nginx = Prism.languages.extend('clike', {
  970. 'comment': {
  971. pattern: /(^|[^"{\\])#.*/,
  972. lookbehind: true
  973. },
  974. 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|server|events|location|include|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i,
  975. });
  976. Prism.languages.insertBefore('nginx', 'keyword', {
  977. 'variable': /\$[a-z_]+/i
  978. });
  979. Prism.languages.perl = {
  980. 'comment': [
  981. {
  982. // POD
  983. pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
  984. lookbehind: true
  985. },
  986. {
  987. pattern: /(^|[^\\$])#.*/,
  988. lookbehind: true
  989. }
  990. ],
  991. // TODO Could be nice to handle Heredoc too.
  992. 'string': [
  993. // q/.../
  994. /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
  995. // q a...a
  996. /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\1/,
  997. // q(...)
  998. /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
  999. // q{...}
  1000. /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
  1001. // q[...]
  1002. /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
  1003. // q<...>
  1004. /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
  1005. // "...", `...`
  1006. /("|`)(?:[^\\]|\\[\s\S])*?\1/,
  1007. // '...'
  1008. // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  1009. /'(?:[^'\\\r\n]|\\.)*'/
  1010. ],
  1011. 'regex': [
  1012. // m/.../
  1013. /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[msixpodualngc]*/,
  1014. // m a...a
  1015. /\b(?:m|qr)\s+([a-zA-Z0-9])(?:[^\\]|\\.)*?\1[msixpodualngc]*/,
  1016. // m(...)
  1017. /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
  1018. // m{...}
  1019. /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
  1020. // m[...]
  1021. /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
  1022. // m<...>
  1023. /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  1024. // The lookbehinds prevent -s from breaking
  1025. // FIXME We don't handle change of separator like s(...)[...]
  1026. // s/.../.../
  1027. {
  1028. pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  1029. lookbehind: true
  1030. },
  1031. // s a...a...a
  1032. {
  1033. pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  1034. lookbehind: true
  1035. },
  1036. // s(...)(...)
  1037. {
  1038. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  1039. lookbehind: true
  1040. },
  1041. // s{...}{...}
  1042. {
  1043. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  1044. lookbehind: true
  1045. },
  1046. // s[...][...]
  1047. {
  1048. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  1049. lookbehind: true
  1050. },
  1051. // s<...><...>
  1052. {
  1053. pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  1054. lookbehind: true
  1055. },
  1056. // /.../
  1057. // The look-ahead tries to prevent two divisions on
  1058. // the same line from being highlighted as regex.
  1059. // This does not support multi-line regex.
  1060. /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/
  1061. ],
  1062. // FIXME Not sure about the handling of ::, ', and #
  1063. 'variable': [
  1064. // ${^POSTMATCH}
  1065. /[&*$@%]\{\^[A-Z]+\}/,
  1066. // $^V
  1067. /[&*$@%]\^[A-Z_]/,
  1068. // ${...}
  1069. /[&*$@%]#?(?=\{)/,
  1070. // $foo
  1071. /[&*$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/i,
  1072. // $1
  1073. /[&*$@%]\d+/,
  1074. // $_, @_, %!
  1075. // The negative lookahead prevents from breaking the %= operator
  1076. /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
  1077. ],
  1078. 'filehandle': {
  1079. // <>, <FOO>, _
  1080. pattern: /<(?![<=])\S*>|\b_\b/,
  1081. alias: 'symbol'
  1082. },
  1083. 'vstring': {
  1084. // v1.2, 1.2.3
  1085. pattern: /v\d+(\.\d+)*|\d+(\.\d+){2,}/,
  1086. alias: 'string'
  1087. },
  1088. 'function': {
  1089. pattern: /sub [a-z0-9_]+/i,
  1090. inside: {
  1091. keyword: /sub/
  1092. }
  1093. },
  1094. '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/,
  1095. 'number': /\b-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)\b/,
  1096. 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
  1097. 'punctuation': /[{}[\];(),:]/
  1098. };
  1099. /**
  1100. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  1101. * Modified by Miles Johnson: http://milesj.me
  1102. *
  1103. * Supports the following:
  1104. * - Extends clike syntax
  1105. * - Support for PHP 5.3+ (namespaces, traits, generators, etc)
  1106. * - Smarter constant and function matching
  1107. *
  1108. * Adds the following new token classes:
  1109. * constant, delimiter, variable, function, package
  1110. */
  1111. Prism.languages.php = Prism.languages.extend('clike', {
  1112. '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,
  1113. 'constant': /\b[A-Z0-9_]{2,}\b/,
  1114. 'comment': {
  1115. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
  1116. lookbehind: true,
  1117. greedy: true
  1118. }
  1119. });
  1120. // Shell-like comments are matched after strings, because they are less
  1121. // common than strings containing hashes...
  1122. Prism.languages.insertBefore('php', 'class-name', {
  1123. 'shell-comment': {
  1124. pattern: /(^|[^\\])#.*/,
  1125. lookbehind: true,
  1126. alias: 'comment'
  1127. }
  1128. });
  1129. Prism.languages.insertBefore('php', 'keyword', {
  1130. 'delimiter': /\?>|<\?(?:php)?/i,
  1131. 'variable': /\$\w+\b/i,
  1132. 'package': {
  1133. pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
  1134. lookbehind: true,
  1135. inside: {
  1136. punctuation: /\\/
  1137. }
  1138. }
  1139. });
  1140. // Must be defined after the function pattern
  1141. Prism.languages.insertBefore('php', 'operator', {
  1142. 'property': {
  1143. pattern: /(->)[\w]+/,
  1144. lookbehind: true
  1145. }
  1146. });
  1147. // Add HTML support of the markup language exists
  1148. if (Prism.languages.markup) {
  1149. // Tokenize all inline PHP blocks that are wrapped in <?php ?>
  1150. // This allows for easy PHP + markup highlighting
  1151. Prism.hooks.add('before-highlight', function(env) {
  1152. if (env.language !== 'php') {
  1153. return;
  1154. }
  1155. env.tokenStack = [];
  1156. env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function(match) {
  1157. env.tokenStack.push(match);
  1158. return '{{{PHP' + env.tokenStack.length + '}}}';
  1159. });
  1160. });
  1161. // Re-insert the tokens after highlighting
  1162. Prism.hooks.add('after-highlight', function(env) {
  1163. if (env.language !== 'php') {
  1164. return;
  1165. }
  1166. for (var i = 0, t; t = env.tokenStack[i]; i++) {
  1167. // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
  1168. env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
  1169. }
  1170. env.element.innerHTML = env.highlightedCode;
  1171. });
  1172. // Wrap tokens in classes that are missing them
  1173. Prism.hooks.add('wrap', function(env) {
  1174. if (env.language === 'php' && env.type === 'markup') {
  1175. env.content = env.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g, "<span class=\"token php\">$1</span>");
  1176. }
  1177. });
  1178. // Add the rules before all others
  1179. Prism.languages.insertBefore('php', 'comment', {
  1180. 'markup': {
  1181. pattern: /<[^?]\/?(.*?)>/,
  1182. inside: Prism.languages.markup
  1183. },
  1184. 'php': /\{\{\{PHP[0-9]+\}\}\}/
  1185. });
  1186. }
  1187. ;
  1188. Prism.languages.python= {
  1189. 'triple-quoted-string': {
  1190. pattern: /"""[\s\S]+?"""|'''[\s\S]+?'''/,
  1191. alias: 'string'
  1192. },
  1193. 'comment': {
  1194. pattern: /(^|[^\\])#.*/,
  1195. lookbehind: true
  1196. },
  1197. 'string': {
  1198. pattern: /("|')(?:\\\\|\\?[^\\\r\n])*?\1/,
  1199. greedy: true
  1200. },
  1201. 'function' : {
  1202. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
  1203. lookbehind: true
  1204. },
  1205. 'class-name': {
  1206. pattern: /(\bclass\s+)[a-z0-9_]+/i,
  1207. lookbehind: true
  1208. },
  1209. 'keyword' : /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
  1210. 'boolean' : /\b(?:True|False)\b/,
  1211. 'number' : /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
  1212. 'operator' : /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
  1213. 'punctuation' : /[{}[\];(),.:]/
  1214. };
  1215. (function(Prism) {
  1216. Prism.languages.crystal = Prism.languages.extend('ruby', {
  1217. keyword: [
  1218. /\b(?:abstract|alias|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|rescue|return|require|self|sizeof|struct|super|then|type|typeof|union|unless|until|when|while|with|yield|__DIR__|__FILE__|__LINE__)\b/,
  1219. {
  1220. pattern: /(\.\s*)(?:is_a|responds_to)\?/,
  1221. lookbehind: true
  1222. }
  1223. ],
  1224. number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:[0-9](?:[0-9_]*[0-9])?)(?:\.[0-9_]*[0-9])?(?:[eE][+-]?[0-9_]*[0-9])?)(?:_(?:[uif](?:8|16|32|64))?)?\b/,
  1225. });
  1226. var rest = Prism.util.clone(Prism.languages.crystal);
  1227. Prism.languages.insertBefore('crystal', 'string', {
  1228. attribute: {
  1229. pattern: /@\[.+?\]/,
  1230. alias: 'attr-name',
  1231. inside: {
  1232. delimiter: {
  1233. pattern: /^@\[|\]$/,
  1234. alias: 'tag'
  1235. },
  1236. rest: rest
  1237. }
  1238. },
  1239. expansion: [
  1240. {
  1241. pattern: /\{\{.+?\}\}/,
  1242. inside: {
  1243. delimiter: {
  1244. pattern: /^\{\{|\}\}$/,
  1245. alias: 'tag'
  1246. },
  1247. rest: rest
  1248. }
  1249. },
  1250. {
  1251. pattern: /\{%.+?%\}/,
  1252. inside: {
  1253. delimiter: {
  1254. pattern: /^\{%|%\}$/,
  1255. alias: 'tag'
  1256. },
  1257. rest: rest
  1258. }
  1259. }
  1260. ]
  1261. });
  1262. }(Prism));
  1263. /* TODO
  1264. Add support for Markdown notation inside doc comments
  1265. Add support for nested block comments...
  1266. Match closure params even when not followed by dash or brace
  1267. Add better support for macro definition
  1268. */
  1269. Prism.languages.rust = {
  1270. 'comment': [
  1271. {
  1272. pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  1273. lookbehind: true
  1274. },
  1275. {
  1276. pattern: /(^|[^\\:])\/\/.*/,
  1277. lookbehind: true
  1278. }
  1279. ],
  1280. 'string': [
  1281. /b?r(#*)"(?:\\?.)*?"\1/,
  1282. /b?("|')(?:\\?.)*?\1/
  1283. ],
  1284. '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/,
  1285. 'attribute': {
  1286. pattern: /#!?\[.+?\]/,
  1287. alias: 'attr-name'
  1288. },
  1289. 'function': [
  1290. /[a-z0-9_]+(?=\s*\()/i,
  1291. // Macros can use parens or brackets
  1292. /[a-z0-9_]+!(?=\s*\(|\[)/i
  1293. ],
  1294. 'macro-rules': {
  1295. pattern: /[a-z0-9_]+!/i,
  1296. alias: 'function'
  1297. },
  1298. // Hex, oct, bin, dec numbers with visual separators and type suffix
  1299. '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/,
  1300. // Closure params should not be confused with bitwise OR |
  1301. 'closure-params': {
  1302. pattern: /\|[^|]*\|(?=\s*[{-])/,
  1303. inside: {
  1304. 'punctuation': /[\|:,]/,
  1305. 'operator': /[&*]/
  1306. }
  1307. },
  1308. 'punctuation': /[{}[\];(),:]|\.+|->/,
  1309. 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
  1310. };
  1311. Prism.languages.scss = Prism.languages.extend('css', {
  1312. 'comment': {
  1313. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
  1314. lookbehind: true
  1315. },
  1316. 'atrule': {
  1317. pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
  1318. inside: {
  1319. 'rule': /@[\w-]+/
  1320. // See rest below
  1321. }
  1322. },
  1323. // url, compassified
  1324. 'url': /(?:[-a-z]+-)*url(?=\()/i,
  1325. // CSS selector regex is not appropriate for Sass
  1326. // since there can be lot more things (var, @ directive, nesting..)
  1327. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  1328. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  1329. // 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
  1330. // can "pass" as a selector- e.g: proper#{$erty})
  1331. // this one was hard to do, so please be careful if you edit this one :)
  1332. 'selector': {
  1333. // Initial look-ahead is used to prevent matching of blank selectors
  1334. pattern: /(?=\S)[^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m,
  1335. inside: {
  1336. 'parent': {
  1337. pattern: /&/,
  1338. alias: 'important'
  1339. },
  1340. 'placeholder': /%[-_\w]+/,
  1341. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1342. }
  1343. }
  1344. });
  1345. Prism.languages.insertBefore('scss', 'atrule', {
  1346. 'keyword': [
  1347. /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
  1348. {
  1349. pattern: /( +)(?:from|through)(?= )/,
  1350. lookbehind: true
  1351. }
  1352. ]
  1353. });
  1354. Prism.languages.scss.property = {
  1355. pattern: /(?:[\w-]|\$[-_\w]+|#\{\$[-_\w]+\})+(?=\s*:)/i,
  1356. inside: {
  1357. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1358. }
  1359. };
  1360. Prism.languages.insertBefore('scss', 'important', {
  1361. // var and interpolated vars
  1362. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1363. });
  1364. Prism.languages.insertBefore('scss', 'function', {
  1365. 'placeholder': {
  1366. pattern: /%[-_\w]+/,
  1367. alias: 'selector'
  1368. },
  1369. 'statement': {
  1370. pattern: /\B!(?:default|optional)\b/i,
  1371. alias: 'keyword'
  1372. },
  1373. 'boolean': /\b(?:true|false)\b/,
  1374. 'null': /\bnull\b/,
  1375. 'operator': {
  1376. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
  1377. lookbehind: true
  1378. }
  1379. });
  1380. Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
  1381. Prism.languages.sql= {
  1382. 'comment': {
  1383. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|(?:--|\/\/|#).*)/,
  1384. lookbehind: true
  1385. },
  1386. 'string' : {
  1387. pattern: /(^|[^@\\])("|')(?:\\?[\s\S])*?\2/,
  1388. lookbehind: true
  1389. },
  1390. 'variable': /@[\w.$]+|@("|'|`)(?:\\?[\s\S])+?\1/,
  1391. '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?
  1392. '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,
  1393. 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
  1394. 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
  1395. 'operator': /[-+*\/=%^~]|&&?|\|?\||!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  1396. 'punctuation': /[;[\]()`,.]/
  1397. };
  1398. Prism.languages.typescript = Prism.languages.extend('javascript', {
  1399. 'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield|module|declare|constructor|string|Function|any|number|boolean|Array|enum)\b/
  1400. });