1
0

prism.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706
  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. manual: _self.Prism && _self.Prism.manual,
  20. util: {
  21. encode: function (tokens) {
  22. if (tokens instanceof Token) {
  23. return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
  24. } else if (_.util.type(tokens) === 'Array') {
  25. return tokens.map(_.util.encode);
  26. } else {
  27. return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
  28. }
  29. },
  30. type: function (o) {
  31. return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
  32. },
  33. objId: function (obj) {
  34. if (!obj['__id']) {
  35. Object.defineProperty(obj, '__id', { value: ++uniqueId });
  36. }
  37. return obj['__id'];
  38. },
  39. // Deep clone a language definition (e.g. to extend it)
  40. clone: function (o) {
  41. var type = _.util.type(o);
  42. switch (type) {
  43. case 'Object':
  44. var clone = {};
  45. for (var key in o) {
  46. if (o.hasOwnProperty(key)) {
  47. clone[key] = _.util.clone(o[key]);
  48. }
  49. }
  50. return clone;
  51. case 'Array':
  52. // Check for existence for IE8
  53. return o.map && o.map(function(v) { return _.util.clone(v); });
  54. }
  55. return o;
  56. }
  57. },
  58. languages: {
  59. extend: function (id, redef) {
  60. var lang = _.util.clone(_.languages[id]);
  61. for (var key in redef) {
  62. lang[key] = redef[key];
  63. }
  64. return lang;
  65. },
  66. /**
  67. * Insert a token before another token in a language literal
  68. * As this needs to recreate the object (we cannot actually insert before keys in object literals),
  69. * we cannot just provide an object, we need anobject and a key.
  70. * @param inside The key (or language id) of the parent
  71. * @param before The key to insert before. If not provided, the function appends instead.
  72. * @param insert Object with the key/value pairs to insert
  73. * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
  74. */
  75. insertBefore: function (inside, before, insert, root) {
  76. root = root || _.languages;
  77. var grammar = root[inside];
  78. if (arguments.length == 2) {
  79. insert = arguments[1];
  80. for (var newToken in insert) {
  81. if (insert.hasOwnProperty(newToken)) {
  82. grammar[newToken] = insert[newToken];
  83. }
  84. }
  85. return grammar;
  86. }
  87. var ret = {};
  88. for (var token in grammar) {
  89. if (grammar.hasOwnProperty(token)) {
  90. if (token == before) {
  91. for (var newToken in insert) {
  92. if (insert.hasOwnProperty(newToken)) {
  93. ret[newToken] = insert[newToken];
  94. }
  95. }
  96. }
  97. ret[token] = grammar[token];
  98. }
  99. }
  100. // Update references in other language definitions
  101. _.languages.DFS(_.languages, function(key, value) {
  102. if (value === root[inside] && key != inside) {
  103. this[key] = ret;
  104. }
  105. });
  106. return root[inside] = ret;
  107. },
  108. // Traverse a language definition with Depth First Search
  109. DFS: function(o, callback, type, visited) {
  110. visited = visited || {};
  111. for (var i in o) {
  112. if (o.hasOwnProperty(i)) {
  113. callback.call(o, i, o[i], type || i);
  114. if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
  115. visited[_.util.objId(o[i])] = true;
  116. _.languages.DFS(o[i], callback, null, visited);
  117. }
  118. else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
  119. visited[_.util.objId(o[i])] = true;
  120. _.languages.DFS(o[i], callback, i, visited);
  121. }
  122. }
  123. }
  124. }
  125. },
  126. plugins: {},
  127. highlightAll: function(async, callback) {
  128. var env = {
  129. callback: callback,
  130. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  131. };
  132. _.hooks.run("before-highlightall", env);
  133. var elements = env.elements || document.querySelectorAll(env.selector);
  134. for (var i=0, element; element = elements[i++];) {
  135. _.highlightElement(element, async === true, env.callback);
  136. }
  137. },
  138. highlightElement: function(element, async, callback) {
  139. // Find language
  140. var language, grammar, parent = element;
  141. while (parent && !lang.test(parent.className)) {
  142. parent = parent.parentNode;
  143. }
  144. if (parent) {
  145. language = (parent.className.match(lang) || [,''])[1].toLowerCase();
  146. grammar = _.languages[language];
  147. }
  148. // Set language on the element, if not present
  149. element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  150. // Set language on the parent, for styling
  151. parent = element.parentNode;
  152. if (/pre/i.test(parent.nodeName)) {
  153. parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  154. }
  155. var code = element.textContent;
  156. var env = {
  157. element: element,
  158. language: language,
  159. grammar: grammar,
  160. code: code
  161. };
  162. _.hooks.run('before-sanity-check', env);
  163. if (!env.code || !env.grammar) {
  164. if (env.code) {
  165. env.element.textContent = env.code;
  166. }
  167. _.hooks.run('complete', env);
  168. return;
  169. }
  170. _.hooks.run('before-highlight', env);
  171. // if (async && _self.Worker) {
  172. // var worker = new Worker(_.filename);
  173. // worker.onmessage = function(evt) {
  174. // env.highlightedCode = evt.data;
  175. // _.hooks.run('before-insert', env);
  176. // env.element.innerHTML = env.highlightedCode;
  177. // callback && callback.call(env.element);
  178. // _.hooks.run('after-highlight', env);
  179. // _.hooks.run('complete', env);
  180. // };
  181. // worker.postMessage(JSON.stringify({
  182. // language: env.language,
  183. // code: env.code,
  184. // immediateClose: true
  185. // }));
  186. // }
  187. // else {
  188. env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
  189. _.hooks.run('before-insert', env);
  190. env.element.innerHTML = env.highlightedCode;
  191. callback && callback.call(element);
  192. _.hooks.run('after-highlight', env);
  193. _.hooks.run('complete', env);
  194. // }
  195. },
  196. highlight: function (text, grammar, language) {
  197. var tokens = _.tokenize(text, grammar);
  198. return Token.stringify(_.util.encode(tokens), language);
  199. },
  200. tokenize: function(text, grammar, language) {
  201. var Token = _.Token;
  202. var strarr = [text];
  203. var rest = grammar.rest;
  204. if (rest) {
  205. for (var token in rest) {
  206. grammar[token] = rest[token];
  207. }
  208. delete grammar.rest;
  209. }
  210. tokenloop: for (var token in grammar) {
  211. if(!grammar.hasOwnProperty(token) || !grammar[token]) {
  212. continue;
  213. }
  214. var patterns = grammar[token];
  215. patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
  216. for (var j = 0; j < patterns.length; ++j) {
  217. var pattern = patterns[j],
  218. inside = pattern.inside,
  219. lookbehind = !!pattern.lookbehind,
  220. greedy = !!pattern.greedy,
  221. lookbehindLength = 0,
  222. alias = pattern.alias;
  223. if (greedy && !pattern.pattern.global) {
  224. // Without the global flag, lastIndex won't work
  225. var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
  226. pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
  227. }
  228. pattern = pattern.pattern || pattern;
  229. // Don’t cache length as it changes during the loop
  230. for (var i=0, pos = 0; i<strarr.length; pos += strarr[i].length, ++i) {
  231. var str = strarr[i];
  232. if (strarr.length > text.length) {
  233. // Something went terribly wrong, ABORT, ABORT!
  234. break tokenloop;
  235. }
  236. if (str instanceof Token) {
  237. continue;
  238. }
  239. pattern.lastIndex = 0;
  240. var match = pattern.exec(str),
  241. delNum = 1;
  242. // Greedy patterns can override/remove up to two previously matched tokens
  243. if (!match && greedy && i != strarr.length - 1) {
  244. pattern.lastIndex = pos;
  245. match = pattern.exec(text);
  246. if (!match) {
  247. break;
  248. }
  249. var from = match.index + (lookbehind ? match[1].length : 0),
  250. to = match.index + match[0].length,
  251. k = i,
  252. p = pos;
  253. for (var len = strarr.length; k < len && p < to; ++k) {
  254. p += strarr[k].length;
  255. // Move the index i to the element in strarr that is closest to from
  256. if (from >= p) {
  257. ++i;
  258. pos = p;
  259. }
  260. }
  261. /*
  262. * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
  263. * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
  264. */
  265. if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
  266. continue;
  267. }
  268. // Number of tokens to delete and replace with the new match
  269. delNum = k - i;
  270. str = text.slice(pos, p);
  271. match.index -= pos;
  272. }
  273. if (!match) {
  274. continue;
  275. }
  276. if(lookbehind) {
  277. lookbehindLength = match[1].length;
  278. }
  279. var from = match.index + lookbehindLength,
  280. match = match[0].slice(lookbehindLength),
  281. to = from + match.length,
  282. before = str.slice(0, from),
  283. after = str.slice(to);
  284. var args = [i, delNum];
  285. if (before) {
  286. args.push(before);
  287. }
  288. var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
  289. args.push(wrapped);
  290. if (after) {
  291. args.push(after);
  292. }
  293. Array.prototype.splice.apply(strarr, args);
  294. }
  295. }
  296. }
  297. return strarr;
  298. },
  299. hooks: {
  300. all: {},
  301. add: function (name, callback) {
  302. var hooks = _.hooks.all;
  303. hooks[name] = hooks[name] || [];
  304. hooks[name].push(callback);
  305. },
  306. run: function (name, env) {
  307. var callbacks = _.hooks.all[name];
  308. if (!callbacks || !callbacks.length) {
  309. return;
  310. }
  311. for (var i=0, callback; callback = callbacks[i++];) {
  312. callback(env);
  313. }
  314. }
  315. }
  316. };
  317. var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
  318. this.type = type;
  319. this.content = content;
  320. this.alias = alias;
  321. // Copy of the full string this token was created from
  322. this.length = (matchedStr || "").length|0;
  323. this.greedy = !!greedy;
  324. };
  325. Token.stringify = function(o, language, parent) {
  326. if (typeof o == 'string') {
  327. return o;
  328. }
  329. if (_.util.type(o) === 'Array') {
  330. return o.map(function(element) {
  331. return Token.stringify(element, language, o);
  332. }).join('');
  333. }
  334. var env = {
  335. type: o.type,
  336. content: Token.stringify(o.content, language, parent),
  337. tag: 'span',
  338. classes: ['token', o.type],
  339. attributes: {},
  340. language: language,
  341. parent: parent
  342. };
  343. if (env.type == 'comment') {
  344. env.attributes['spellcheck'] = 'true';
  345. }
  346. if (o.alias) {
  347. var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
  348. Array.prototype.push.apply(env.classes, aliases);
  349. }
  350. _.hooks.run('wrap', env);
  351. var attributes = Object.keys(env.attributes).map(function(name) {
  352. return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
  353. }).join(' ');
  354. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
  355. };
  356. // if (!_self.document) {
  357. // if (!_self.addEventListener) {
  358. // // in Node.js
  359. // return _self.Prism;
  360. // }
  361. // // In worker
  362. // _self.addEventListener('message', function(evt) {
  363. // var message = JSON.parse(evt.data),
  364. // lang = message.language,
  365. // code = message.code,
  366. // immediateClose = message.immediateClose;
  367. // _self.postMessage(_.highlight(code, _.languages[lang], lang));
  368. // if (immediateClose) {
  369. // _self.close();
  370. // }
  371. // }, false);
  372. // return _self.Prism;
  373. // }
  374. // //Get current script and highlight
  375. // var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
  376. // if (script) {
  377. // _.filename = script.src;
  378. // if (document.addEventListener && !_.manual && !script.hasAttribute('data-manual')) {
  379. // if(document.readyState !== "loading") {
  380. // if (window.requestAnimationFrame) {
  381. // window.requestAnimationFrame(_.highlightAll);
  382. // } else {
  383. // window.setTimeout(_.highlightAll, 16);
  384. // }
  385. // }
  386. // else {
  387. // document.addEventListener('DOMContentLoaded', _.highlightAll);
  388. // }
  389. // }
  390. // }
  391. return _self.Prism;
  392. })();
  393. if (typeof module !== 'undefined' && module.exports) {
  394. module.exports = Prism;
  395. }
  396. // hack for components to work correctly in node.js
  397. if (typeof global !== 'undefined') {
  398. global.Prism = Prism;
  399. }
  400. ;
  401. Prism.languages.markup = {
  402. 'comment': /<!--[\w\W]*?-->/,
  403. 'prolog': /<\?[\w\W]+?\?>/,
  404. 'doctype': /<!DOCTYPE[\w\W]+?>/i,
  405. 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
  406. 'tag': {
  407. pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
  408. inside: {
  409. 'tag': {
  410. pattern: /^<\/?[^\s>\/]+/i,
  411. inside: {
  412. 'punctuation': /^<\/?/,
  413. 'namespace': /^[^\s>\/:]+:/
  414. }
  415. },
  416. 'attr-value': {
  417. pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
  418. inside: {
  419. 'punctuation': /[=>"']/
  420. }
  421. },
  422. 'punctuation': /\/?>/,
  423. 'attr-name': {
  424. pattern: /[^\s>\/]+/,
  425. inside: {
  426. 'namespace': /^[^\s>\/:]+:/
  427. }
  428. }
  429. }
  430. },
  431. 'entity': /&#?[\da-z]{1,8};/i
  432. };
  433. // Plugin to make entity title show the real entity, idea by Roman Komarov
  434. Prism.hooks.add('wrap', function(env) {
  435. if (env.type === 'entity') {
  436. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  437. }
  438. });
  439. Prism.languages.xml = Prism.languages.markup;
  440. Prism.languages.html = Prism.languages.markup;
  441. Prism.languages.mathml = Prism.languages.markup;
  442. Prism.languages.svg = Prism.languages.markup;
  443. Prism.languages.css = {
  444. 'comment': /\/\*[\w\W]*?\*\//,
  445. 'atrule': {
  446. pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
  447. inside: {
  448. 'rule': /@[\w-]+/
  449. // See rest below
  450. }
  451. },
  452. 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
  453. 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
  454. 'string': {
  455. pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
  456. greedy: true
  457. },
  458. 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
  459. 'important': /\B!important\b/i,
  460. 'function': /[-a-z0-9]+(?=\()/i,
  461. 'punctuation': /[(){};:]/
  462. };
  463. Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
  464. if (Prism.languages.markup) {
  465. Prism.languages.insertBefore('markup', 'tag', {
  466. 'style': {
  467. pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
  468. lookbehind: true,
  469. inside: Prism.languages.css,
  470. alias: 'language-css'
  471. }
  472. });
  473. Prism.languages.insertBefore('inside', 'attr-value', {
  474. 'style-attr': {
  475. pattern: /\s*style=("|').*?\1/i,
  476. inside: {
  477. 'attr-name': {
  478. pattern: /^\s*style/i,
  479. inside: Prism.languages.markup.tag.inside
  480. },
  481. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  482. 'attr-value': {
  483. pattern: /.+/i,
  484. inside: Prism.languages.css
  485. }
  486. },
  487. alias: 'language-css'
  488. }
  489. }, Prism.languages.markup.tag);
  490. };
  491. Prism.languages.clike = {
  492. 'comment': [
  493. {
  494. pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  495. lookbehind: true
  496. },
  497. {
  498. pattern: /(^|[^\\:])\/\/.*/,
  499. lookbehind: true
  500. }
  501. ],
  502. 'string': {
  503. pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  504. greedy: true
  505. },
  506. 'class-name': {
  507. pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
  508. lookbehind: true,
  509. inside: {
  510. punctuation: /(\.|\\)/
  511. }
  512. },
  513. 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  514. 'boolean': /\b(true|false)\b/,
  515. 'function': /[a-z0-9_]+(?=\()/i,
  516. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
  517. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
  518. 'punctuation': /[{}[\];(),.:]/
  519. };
  520. Prism.languages.javascript = Prism.languages.extend('clike', {
  521. '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/,
  522. 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
  523. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  524. 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
  525. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/
  526. });
  527. Prism.languages.insertBefore('javascript', 'keyword', {
  528. 'regex': {
  529. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
  530. lookbehind: true,
  531. greedy: true
  532. }
  533. });
  534. Prism.languages.insertBefore('javascript', 'string', {
  535. 'template-string': {
  536. pattern: /`(?:\\\\|\\?[^\\])*?`/,
  537. greedy: true,
  538. inside: {
  539. 'interpolation': {
  540. pattern: /\$\{[^}]+\}/,
  541. inside: {
  542. 'interpolation-punctuation': {
  543. pattern: /^\$\{|\}$/,
  544. alias: 'punctuation'
  545. },
  546. rest: Prism.languages.javascript
  547. }
  548. },
  549. 'string': /[\s\S]+/
  550. }
  551. }
  552. });
  553. if (Prism.languages.markup) {
  554. Prism.languages.insertBefore('markup', 'tag', {
  555. 'script': {
  556. pattern: /(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,
  557. lookbehind: true,
  558. inside: Prism.languages.javascript,
  559. alias: 'language-javascript'
  560. }
  561. });
  562. }
  563. Prism.languages.js = Prism.languages.javascript;
  564. Prism.languages.c = Prism.languages.extend('clike', {
  565. '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/,
  566. 'operator': /\-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|?\||[~^%?*\/]/,
  567. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
  568. });
  569. Prism.languages.insertBefore('c', 'string', {
  570. 'macro': {
  571. // allow for multiline macro definitions
  572. // spaces after the # character compile fine with gcc
  573. pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,
  574. lookbehind: true,
  575. alias: 'property',
  576. inside: {
  577. // highlight the path of the include statement as a string
  578. 'string': {
  579. pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,
  580. lookbehind: true
  581. },
  582. // highlight macro directives as keywords
  583. 'directive': {
  584. pattern: /(#\s*)\b(define|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
  585. lookbehind: true,
  586. alias: 'keyword'
  587. }
  588. }
  589. },
  590. // highlight predefined macros as constants
  591. 'constant': /\b(__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|stdin|stdout|stderr)\b/
  592. });
  593. delete Prism.languages.c['class-name'];
  594. delete Prism.languages.c['boolean'];
  595. Prism.languages.cpp = Prism.languages.extend('c', {
  596. '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/,
  597. 'boolean': /\b(true|false)\b/,
  598. '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/
  599. });
  600. Prism.languages.insertBefore('cpp', 'keyword', {
  601. 'class-name': {
  602. pattern: /(class\s+)[a-z0-9_]+/i,
  603. lookbehind: true
  604. }
  605. });
  606. (function(Prism) {
  607. // Ignore comments starting with { to privilege string interpolation highlighting
  608. var comment = /#(?!\{).+/,
  609. interpolation = {
  610. pattern: /#\{[^}]+\}/,
  611. alias: 'variable'
  612. };
  613. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  614. 'comment': comment,
  615. 'string': [
  616. // Strings are multiline
  617. {
  618. pattern: /'(?:\\?[^\\])*?'/,
  619. greedy: true
  620. },
  621. {
  622. // Strings are multiline
  623. pattern: /"(?:\\?[^\\])*?"/,
  624. greedy: true,
  625. inside: {
  626. 'interpolation': interpolation
  627. }
  628. }
  629. ],
  630. '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/,
  631. 'class-member': {
  632. pattern: /@(?!\d)\w+/,
  633. alias: 'variable'
  634. }
  635. });
  636. Prism.languages.insertBefore('coffeescript', 'comment', {
  637. 'multiline-comment': {
  638. pattern: /###[\s\S]+?###/,
  639. alias: 'comment'
  640. },
  641. // Block regexp can contain comments and interpolation
  642. 'block-regex': {
  643. pattern: /\/{3}[\s\S]*?\/{3}/,
  644. alias: 'regex',
  645. inside: {
  646. 'comment': comment,
  647. 'interpolation': interpolation
  648. }
  649. }
  650. });
  651. Prism.languages.insertBefore('coffeescript', 'string', {
  652. 'inline-javascript': {
  653. pattern: /`(?:\\?[\s\S])*?`/,
  654. inside: {
  655. 'delimiter': {
  656. pattern: /^`|`$/,
  657. alias: 'punctuation'
  658. },
  659. rest: Prism.languages.javascript
  660. }
  661. },
  662. // Block strings
  663. 'multiline-string': [
  664. {
  665. pattern: /'''[\s\S]*?'''/,
  666. greedy: true,
  667. alias: 'string'
  668. },
  669. {
  670. pattern: /"""[\s\S]*?"""/,
  671. greedy: true,
  672. alias: 'string',
  673. inside: {
  674. interpolation: interpolation
  675. }
  676. }
  677. ]
  678. });
  679. Prism.languages.insertBefore('coffeescript', 'keyword', {
  680. // Object property
  681. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  682. });
  683. delete Prism.languages.coffeescript['template-string'];
  684. }(Prism));
  685. /**
  686. * Original by Samuel Flores
  687. *
  688. * Adds the following new token classes:
  689. * constant, builtin, variable, symbol, regex
  690. */
  691. (function(Prism) {
  692. Prism.languages.ruby = Prism.languages.extend('clike', {
  693. 'comment': /#(?!\{[^\r\n]*?\}).*/,
  694. '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/
  695. });
  696. var interpolation = {
  697. pattern: /#\{[^}]+\}/,
  698. inside: {
  699. 'delimiter': {
  700. pattern: /^#\{|\}$/,
  701. alias: 'tag'
  702. },
  703. rest: Prism.util.clone(Prism.languages.ruby)
  704. }
  705. };
  706. Prism.languages.insertBefore('ruby', 'keyword', {
  707. 'regex': [
  708. {
  709. pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,
  710. greedy: true,
  711. inside: {
  712. 'interpolation': interpolation
  713. }
  714. },
  715. {
  716. pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
  717. greedy: true,
  718. inside: {
  719. 'interpolation': interpolation
  720. }
  721. },
  722. {
  723. // Here we need to specifically allow interpolation
  724. pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
  725. greedy: true,
  726. inside: {
  727. 'interpolation': interpolation
  728. }
  729. },
  730. {
  731. pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
  732. greedy: true,
  733. inside: {
  734. 'interpolation': interpolation
  735. }
  736. },
  737. {
  738. pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
  739. greedy: true,
  740. inside: {
  741. 'interpolation': interpolation
  742. }
  743. },
  744. {
  745. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
  746. lookbehind: true,
  747. greedy: true
  748. }
  749. ],
  750. 'variable': /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,
  751. 'symbol': /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/
  752. });
  753. Prism.languages.insertBefore('ruby', 'number', {
  754. 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
  755. 'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/
  756. });
  757. Prism.languages.ruby.string = [
  758. {
  759. pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
  760. greedy: true,
  761. inside: {
  762. 'interpolation': interpolation
  763. }
  764. },
  765. {
  766. pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
  767. greedy: true,
  768. inside: {
  769. 'interpolation': interpolation
  770. }
  771. },
  772. {
  773. // Here we need to specifically allow interpolation
  774. pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
  775. greedy: true,
  776. inside: {
  777. 'interpolation': interpolation
  778. }
  779. },
  780. {
  781. pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
  782. greedy: true,
  783. inside: {
  784. 'interpolation': interpolation
  785. }
  786. },
  787. {
  788. pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
  789. greedy: true,
  790. inside: {
  791. 'interpolation': interpolation
  792. }
  793. },
  794. {
  795. pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,
  796. greedy: true,
  797. inside: {
  798. 'interpolation': interpolation
  799. }
  800. }
  801. ];
  802. }(Prism));
  803. Prism.languages.elixir = {
  804. // Negative look-ahead is needed for string interpolation
  805. // Negative look-behind is needed to avoid highlighting markdown headers in
  806. // multi-line doc strings
  807. 'comment': {
  808. pattern: /(^|[^#])#(?![{#]).*/m,
  809. lookbehind: true
  810. },
  811. // ~r"""foo""", ~r'''foo''', ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
  812. 'regex': /~[rR](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[uismxfr]*/,
  813. 'string': [
  814. {
  815. // ~s"""foo""", ~s'''foo''', ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo}, ~s<foo>
  816. pattern: /~[cCsSwW](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|#\{[^}]+\}|[^}])+\}|<(?:\\>|[^>])+>)[csa]?/,
  817. greedy: true,
  818. inside: {
  819. // See interpolation below
  820. }
  821. },
  822. {
  823. pattern: /("""|''')[\s\S]*?\1/,
  824. greedy: true,
  825. inside: {
  826. // See interpolation below
  827. }
  828. },
  829. {
  830. // Multi-line strings are allowed
  831. pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,
  832. greedy: true,
  833. inside: {
  834. // See interpolation below
  835. }
  836. }
  837. ],
  838. 'atom': {
  839. // Look-behind prevents bad highlighting of the :: operator
  840. pattern: /(^|[^:]):\w+/,
  841. lookbehind: true,
  842. alias: 'symbol'
  843. },
  844. // Look-ahead prevents bad highlighting of the :: operator
  845. 'attr-name': /\w+:(?!:)/,
  846. 'capture': {
  847. // Look-behind prevents bad highlighting of the && operator
  848. pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
  849. lookbehind: true,
  850. alias: 'function'
  851. },
  852. 'argument': {
  853. // Look-behind prevents bad highlighting of the && operator
  854. pattern: /(^|[^&])&\d+/,
  855. lookbehind: true,
  856. alias: 'variable'
  857. },
  858. 'attribute': {
  859. pattern: /@[\S]+/,
  860. alias: 'variable'
  861. },
  862. 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
  863. '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/,
  864. 'boolean': /\b(?:true|false|nil)\b/,
  865. 'operator': [
  866. /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
  867. {
  868. // We don't want to match <<
  869. pattern: /([^<])<(?!<)/,
  870. lookbehind: true
  871. },
  872. {
  873. // We don't want to match >>
  874. pattern: /([^>])>(?!>)/,
  875. lookbehind: true
  876. }
  877. ],
  878. 'punctuation': /<<|>>|[.,%\[\]{}()]/
  879. };
  880. Prism.languages.elixir.string.forEach(function(o) {
  881. o.inside = {
  882. 'interpolation': {
  883. pattern: /#\{[^}]+\}/,
  884. inside: {
  885. 'delimiter': {
  886. pattern: /^#\{|\}$/,
  887. alias: 'punctuation'
  888. },
  889. rest: Prism.util.clone(Prism.languages.elixir)
  890. }
  891. }
  892. };
  893. });
  894. Prism.languages.go = Prism.languages.extend('clike', {
  895. '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/,
  896. '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/,
  897. 'boolean': /\b(_|iota|nil|true|false)\b/,
  898. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  899. 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
  900. 'string': {
  901. pattern: /("|'|`)(\\?.|\r|\n)*?\1/,
  902. greedy: true
  903. }
  904. });
  905. delete Prism.languages.go['class-name'];
  906. Prism.languages.json = {
  907. 'property': /"(?:\\.|[^\\"])*"(?=\s*:)/ig,
  908. 'string': /"(?!:)(?:\\.|[^\\"])*"(?!:)/g,
  909. 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,
  910. 'punctuation': /[{}[\]);,]/g,
  911. 'operator': /:/g,
  912. 'boolean': /\b(true|false)\b/gi,
  913. 'null': /\bnull\b/gi
  914. };
  915. Prism.languages.jsonp = Prism.languages.json;
  916. (function (Prism) {
  917. Prism.languages.kotlin = Prism.languages.extend('clike', {
  918. 'keyword': {
  919. // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
  920. 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/,
  921. lookbehind: true
  922. },
  923. 'function': [
  924. /\w+(?=\s*\()/,
  925. {
  926. pattern: /(\.)\w+(?=\s*\{)/,
  927. lookbehind: true
  928. }
  929. ],
  930. 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,
  931. 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
  932. });
  933. delete Prism.languages.kotlin["class-name"];
  934. Prism.languages.insertBefore('kotlin', 'string', {
  935. 'raw-string': {
  936. pattern: /(["'])\1\1[\s\S]*?\1{3}/,
  937. alias: 'string'
  938. // See interpolation below
  939. }
  940. });
  941. Prism.languages.insertBefore('kotlin', 'keyword', {
  942. 'annotation': {
  943. pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
  944. alias: 'builtin'
  945. }
  946. });
  947. Prism.languages.insertBefore('kotlin', 'function', {
  948. 'label': {
  949. pattern: /\w+@|@\w+/,
  950. alias: 'symbol'
  951. }
  952. });
  953. var interpolation = [
  954. {
  955. pattern: /\$\{[^}]+\}/,
  956. inside: {
  957. delimiter: {
  958. pattern: /^\$\{|\}$/,
  959. alias: 'variable'
  960. },
  961. rest: Prism.util.clone(Prism.languages.kotlin)
  962. }
  963. },
  964. {
  965. pattern: /\$\w+/,
  966. alias: 'variable'
  967. }
  968. ];
  969. Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
  970. interpolation: interpolation
  971. };
  972. }(Prism));
  973. Prism.languages.lua = {
  974. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  975. // \z may be used to skip the following space
  976. 'string': {
  977. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  978. greedy: true
  979. },
  980. 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  981. '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/,
  982. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  983. 'operator': [
  984. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  985. {
  986. // Match ".." but don't break "..."
  987. pattern: /(^|[^.])\.\.(?!\.)/,
  988. lookbehind: true
  989. }
  990. ],
  991. 'punctuation': /[\[\](){},;]|\.+|:+/
  992. };
  993. Prism.languages.nginx = Prism.languages.extend('clike', {
  994. 'comment': {
  995. pattern: /(^|[^"{\\])#.*/,
  996. lookbehind: true
  997. },
  998. '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,
  999. });
  1000. Prism.languages.insertBefore('nginx', 'keyword', {
  1001. 'variable': /\$[a-z_]+/i
  1002. });
  1003. Prism.languages.perl = {
  1004. 'comment': [
  1005. {
  1006. // POD
  1007. pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
  1008. lookbehind: true
  1009. },
  1010. {
  1011. pattern: /(^|[^\\$])#.*/,
  1012. lookbehind: true
  1013. }
  1014. ],
  1015. // TODO Could be nice to handle Heredoc too.
  1016. 'string': [
  1017. // q/.../
  1018. {
  1019. pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
  1020. greedy: true
  1021. },
  1022. // q a...a
  1023. {
  1024. pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\1/,
  1025. greedy: true
  1026. },
  1027. // q(...)
  1028. {
  1029. pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
  1030. greedy: true
  1031. },
  1032. // q{...}
  1033. {
  1034. pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
  1035. greedy: true
  1036. },
  1037. // q[...]
  1038. {
  1039. pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
  1040. greedy: true
  1041. },
  1042. // q<...>
  1043. {
  1044. pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
  1045. greedy: true
  1046. },
  1047. // "...", `...`
  1048. {
  1049. pattern: /("|`)(?:[^\\]|\\[\s\S])*?\1/,
  1050. greedy: true
  1051. },
  1052. // '...'
  1053. // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  1054. {
  1055. pattern: /'(?:[^'\\\r\n]|\\.)*'/,
  1056. greedy: true
  1057. }
  1058. ],
  1059. 'regex': [
  1060. // m/.../
  1061. {
  1062. pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[msixpodualngc]*/,
  1063. greedy: true
  1064. },
  1065. // m a...a
  1066. {
  1067. pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:[^\\]|\\.)*?\1[msixpodualngc]*/,
  1068. greedy: true
  1069. },
  1070. // m(...)
  1071. {
  1072. pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
  1073. greedy: true
  1074. },
  1075. // m{...}
  1076. {
  1077. pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
  1078. greedy: true
  1079. },
  1080. // m[...]
  1081. {
  1082. pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
  1083. greedy: true
  1084. },
  1085. // m<...>
  1086. {
  1087. pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  1088. greedy: true
  1089. },
  1090. // The lookbehinds prevent -s from breaking
  1091. // FIXME We don't handle change of separator like s(...)[...]
  1092. // s/.../.../
  1093. {
  1094. pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  1095. lookbehind: true,
  1096. greedy: true
  1097. },
  1098. // s a...a...a
  1099. {
  1100. pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  1101. lookbehind: true,
  1102. greedy: true
  1103. },
  1104. // s(...)(...)
  1105. {
  1106. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  1107. lookbehind: true,
  1108. greedy: true
  1109. },
  1110. // s{...}{...}
  1111. {
  1112. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  1113. lookbehind: true,
  1114. greedy: true
  1115. },
  1116. // s[...][...]
  1117. {
  1118. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  1119. lookbehind: true,
  1120. greedy: true
  1121. },
  1122. // s<...><...>
  1123. {
  1124. pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  1125. lookbehind: true,
  1126. greedy: true
  1127. },
  1128. // /.../
  1129. // The look-ahead tries to prevent two divisions on
  1130. // the same line from being highlighted as regex.
  1131. // This does not support multi-line regex.
  1132. {
  1133. pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
  1134. greedy: true
  1135. }
  1136. ],
  1137. // FIXME Not sure about the handling of ::, ', and #
  1138. 'variable': [
  1139. // ${^POSTMATCH}
  1140. /[&*$@%]\{\^[A-Z]+\}/,
  1141. // $^V
  1142. /[&*$@%]\^[A-Z_]/,
  1143. // ${...}
  1144. /[&*$@%]#?(?=\{)/,
  1145. // $foo
  1146. /[&*$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/i,
  1147. // $1
  1148. /[&*$@%]\d+/,
  1149. // $_, @_, %!
  1150. // The negative lookahead prevents from breaking the %= operator
  1151. /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
  1152. ],
  1153. 'filehandle': {
  1154. // <>, <FOO>, _
  1155. pattern: /<(?![<=])\S*>|\b_\b/,
  1156. alias: 'symbol'
  1157. },
  1158. 'vstring': {
  1159. // v1.2, 1.2.3
  1160. pattern: /v\d+(\.\d+)*|\d+(\.\d+){2,}/,
  1161. alias: 'string'
  1162. },
  1163. 'function': {
  1164. pattern: /sub [a-z0-9_]+/i,
  1165. inside: {
  1166. keyword: /sub/
  1167. }
  1168. },
  1169. '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/,
  1170. 'number': /\b-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)\b/,
  1171. 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
  1172. 'punctuation': /[{}[\];(),:]/
  1173. };
  1174. /**
  1175. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  1176. * Modified by Miles Johnson: http://milesj.me
  1177. *
  1178. * Supports the following:
  1179. * - Extends clike syntax
  1180. * - Support for PHP 5.3+ (namespaces, traits, generators, etc)
  1181. * - Smarter constant and function matching
  1182. *
  1183. * Adds the following new token classes:
  1184. * constant, delimiter, variable, function, package
  1185. */
  1186. Prism.languages.php = Prism.languages.extend('clike', {
  1187. '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,
  1188. 'constant': /\b[A-Z0-9_]{2,}\b/,
  1189. 'comment': {
  1190. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
  1191. lookbehind: true,
  1192. greedy: true
  1193. }
  1194. });
  1195. // Shell-like comments are matched after strings, because they are less
  1196. // common than strings containing hashes...
  1197. Prism.languages.insertBefore('php', 'class-name', {
  1198. 'shell-comment': {
  1199. pattern: /(^|[^\\])#.*/,
  1200. lookbehind: true,
  1201. alias: 'comment'
  1202. }
  1203. });
  1204. Prism.languages.insertBefore('php', 'keyword', {
  1205. 'delimiter': /\?>|<\?(?:php)?/i,
  1206. 'variable': /\$\w+\b/i,
  1207. 'package': {
  1208. pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
  1209. lookbehind: true,
  1210. inside: {
  1211. punctuation: /\\/
  1212. }
  1213. }
  1214. });
  1215. // Must be defined after the function pattern
  1216. Prism.languages.insertBefore('php', 'operator', {
  1217. 'property': {
  1218. pattern: /(->)[\w]+/,
  1219. lookbehind: true
  1220. }
  1221. });
  1222. // Add HTML support of the markup language exists
  1223. if (Prism.languages.markup) {
  1224. // Tokenize all inline PHP blocks that are wrapped in <?php ?>
  1225. // This allows for easy PHP + markup highlighting
  1226. Prism.hooks.add('before-highlight', function(env) {
  1227. if (env.language !== 'php') {
  1228. return;
  1229. }
  1230. env.tokenStack = [];
  1231. env.backupCode = env.code;
  1232. env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function(match) {
  1233. env.tokenStack.push(match);
  1234. return '{{{PHP' + env.tokenStack.length + '}}}';
  1235. });
  1236. });
  1237. // Restore env.code for other plugins (e.g. line-numbers)
  1238. Prism.hooks.add('before-insert', function(env) {
  1239. if (env.language === 'php') {
  1240. env.code = env.backupCode;
  1241. delete env.backupCode;
  1242. }
  1243. });
  1244. // Re-insert the tokens after highlighting
  1245. Prism.hooks.add('after-highlight', function(env) {
  1246. if (env.language !== 'php') {
  1247. return;
  1248. }
  1249. for (var i = 0, t; t = env.tokenStack[i]; i++) {
  1250. // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
  1251. env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
  1252. }
  1253. env.element.innerHTML = env.highlightedCode;
  1254. });
  1255. // Wrap tokens in classes that are missing them
  1256. Prism.hooks.add('wrap', function(env) {
  1257. if (env.language === 'php' && env.type === 'markup') {
  1258. env.content = env.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g, "<span class=\"token php\">$1</span>");
  1259. }
  1260. });
  1261. // Add the rules before all others
  1262. Prism.languages.insertBefore('php', 'comment', {
  1263. 'markup': {
  1264. pattern: /<[^?]\/?(.*?)>/,
  1265. inside: Prism.languages.markup
  1266. },
  1267. 'php': /\{\{\{PHP[0-9]+\}\}\}/
  1268. });
  1269. }
  1270. ;
  1271. Prism.languages.python= {
  1272. 'triple-quoted-string': {
  1273. pattern: /"""[\s\S]+?"""|'''[\s\S]+?'''/,
  1274. alias: 'string'
  1275. },
  1276. 'comment': {
  1277. pattern: /(^|[^\\])#.*/,
  1278. lookbehind: true
  1279. },
  1280. 'string': {
  1281. pattern: /("|')(?:\\\\|\\?[^\\\r\n])*?\1/,
  1282. greedy: true
  1283. },
  1284. 'function' : {
  1285. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
  1286. lookbehind: true
  1287. },
  1288. 'class-name': {
  1289. pattern: /(\bclass\s+)[a-z0-9_]+/i,
  1290. lookbehind: true
  1291. },
  1292. '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/,
  1293. 'boolean' : /\b(?:True|False)\b/,
  1294. 'number' : /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
  1295. 'operator' : /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
  1296. 'punctuation' : /[{}[\];(),.:]/
  1297. };
  1298. (function(Prism) {
  1299. Prism.languages.crystal = Prism.languages.extend('ruby', {
  1300. keyword: [
  1301. /\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/,
  1302. {
  1303. pattern: /(\.\s*)(?:is_a|responds_to)\?/,
  1304. lookbehind: true
  1305. }
  1306. ],
  1307. 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/,
  1308. });
  1309. var rest = Prism.util.clone(Prism.languages.crystal);
  1310. Prism.languages.insertBefore('crystal', 'string', {
  1311. attribute: {
  1312. pattern: /@\[.+?\]/,
  1313. alias: 'attr-name',
  1314. inside: {
  1315. delimiter: {
  1316. pattern: /^@\[|\]$/,
  1317. alias: 'tag'
  1318. },
  1319. rest: rest
  1320. }
  1321. },
  1322. expansion: [
  1323. {
  1324. pattern: /\{\{.+?\}\}/,
  1325. inside: {
  1326. delimiter: {
  1327. pattern: /^\{\{|\}\}$/,
  1328. alias: 'tag'
  1329. },
  1330. rest: rest
  1331. }
  1332. },
  1333. {
  1334. pattern: /\{%.+?%\}/,
  1335. inside: {
  1336. delimiter: {
  1337. pattern: /^\{%|%\}$/,
  1338. alias: 'tag'
  1339. },
  1340. rest: rest
  1341. }
  1342. }
  1343. ]
  1344. });
  1345. }(Prism));
  1346. /* TODO
  1347. Add support for Markdown notation inside doc comments
  1348. Add support for nested block comments...
  1349. Match closure params even when not followed by dash or brace
  1350. Add better support for macro definition
  1351. */
  1352. Prism.languages.rust = {
  1353. 'comment': [
  1354. {
  1355. pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
  1356. lookbehind: true
  1357. },
  1358. {
  1359. pattern: /(^|[^\\:])\/\/.*/,
  1360. lookbehind: true
  1361. }
  1362. ],
  1363. 'string': [
  1364. {
  1365. pattern: /b?r(#*)"(?:\\?.)*?"\1/,
  1366. greedy: true
  1367. },
  1368. {
  1369. pattern: /b?("|')(?:\\?.)*?\1/,
  1370. greedy: true
  1371. }
  1372. ],
  1373. '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/,
  1374. 'attribute': {
  1375. pattern: /#!?\[.+?\]/,
  1376. greedy: true,
  1377. alias: 'attr-name'
  1378. },
  1379. 'function': [
  1380. /[a-z0-9_]+(?=\s*\()/i,
  1381. // Macros can use parens or brackets
  1382. /[a-z0-9_]+!(?=\s*\(|\[)/i
  1383. ],
  1384. 'macro-rules': {
  1385. pattern: /[a-z0-9_]+!/i,
  1386. alias: 'function'
  1387. },
  1388. // Hex, oct, bin, dec numbers with visual separators and type suffix
  1389. '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/,
  1390. // Closure params should not be confused with bitwise OR |
  1391. 'closure-params': {
  1392. pattern: /\|[^|]*\|(?=\s*[{-])/,
  1393. inside: {
  1394. 'punctuation': /[\|:,]/,
  1395. 'operator': /[&*]/
  1396. }
  1397. },
  1398. 'punctuation': /[{}[\];(),:]|\.+|->/,
  1399. 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
  1400. };
  1401. Prism.languages.scss = Prism.languages.extend('css', {
  1402. 'comment': {
  1403. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,
  1404. lookbehind: true
  1405. },
  1406. 'atrule': {
  1407. pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
  1408. inside: {
  1409. 'rule': /@[\w-]+/
  1410. // See rest below
  1411. }
  1412. },
  1413. // url, compassified
  1414. 'url': /(?:[-a-z]+-)*url(?=\()/i,
  1415. // CSS selector regex is not appropriate for Sass
  1416. // since there can be lot more things (var, @ directive, nesting..)
  1417. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  1418. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  1419. // 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
  1420. // can "pass" as a selector- e.g: proper#{$erty})
  1421. // this one was hard to do, so please be careful if you edit this one :)
  1422. 'selector': {
  1423. // Initial look-ahead is used to prevent matching of blank selectors
  1424. pattern: /(?=\S)[^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m,
  1425. inside: {
  1426. 'parent': {
  1427. pattern: /&/,
  1428. alias: 'important'
  1429. },
  1430. 'placeholder': /%[-_\w]+/,
  1431. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1432. }
  1433. }
  1434. });
  1435. Prism.languages.insertBefore('scss', 'atrule', {
  1436. 'keyword': [
  1437. /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
  1438. {
  1439. pattern: /( +)(?:from|through)(?= )/,
  1440. lookbehind: true
  1441. }
  1442. ]
  1443. });
  1444. Prism.languages.scss.property = {
  1445. pattern: /(?:[\w-]|\$[-_\w]+|#\{\$[-_\w]+\})+(?=\s*:)/i,
  1446. inside: {
  1447. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1448. }
  1449. };
  1450. Prism.languages.insertBefore('scss', 'important', {
  1451. // var and interpolated vars
  1452. 'variable': /\$[-_\w]+|#\{\$[-_\w]+\}/
  1453. });
  1454. Prism.languages.insertBefore('scss', 'function', {
  1455. 'placeholder': {
  1456. pattern: /%[-_\w]+/,
  1457. alias: 'selector'
  1458. },
  1459. 'statement': {
  1460. pattern: /\B!(?:default|optional)\b/i,
  1461. alias: 'keyword'
  1462. },
  1463. 'boolean': /\b(?:true|false)\b/,
  1464. 'null': /\bnull\b/,
  1465. 'operator': {
  1466. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
  1467. lookbehind: true
  1468. }
  1469. });
  1470. Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
  1471. Prism.languages.sql= {
  1472. 'comment': {
  1473. pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|(?:--|\/\/|#).*)/,
  1474. lookbehind: true
  1475. },
  1476. 'string' : {
  1477. pattern: /(^|[^@\\])("|')(?:\\?[\s\S])*?\2/,
  1478. greedy: true,
  1479. lookbehind: true
  1480. },
  1481. 'variable': /@[\w.$]+|@("|'|`)(?:\\?[\s\S])+?\1/,
  1482. '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?
  1483. '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,
  1484. 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
  1485. 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
  1486. 'operator': /[-+*\/=%^~]|&&?|\|?\||!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  1487. 'punctuation': /[;[\]()`,.]/
  1488. };
  1489. Prism.languages.typescript = Prism.languages.extend('javascript', {
  1490. // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
  1491. '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|enum|symbol|namespace|abstract|require|type)\b/
  1492. });
  1493. Prism.languages.ts = Prism.languages.typescript;