prism.js 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139
  1. /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+django+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript+yaml */
  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. return 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. if (env.code) {
  164. _.hooks.run('before-highlight', env);
  165. env.element.textContent = env.code;
  166. _.hooks.run('after-highlight', env);
  167. }
  168. _.hooks.run('complete', env);
  169. return;
  170. }
  171. _.hooks.run('before-highlight', env);
  172. // if (async && _self.Worker) {
  173. // var worker = new Worker(_.filename);
  174. // worker.onmessage = function(evt) {
  175. // env.highlightedCode = evt.data;
  176. // _.hooks.run('before-insert', env);
  177. // env.element.innerHTML = env.highlightedCode;
  178. // callback && callback.call(env.element);
  179. // _.hooks.run('after-highlight', env);
  180. // _.hooks.run('complete', env);
  181. // };
  182. // worker.postMessage(JSON.stringify({
  183. // language: env.language,
  184. // code: env.code,
  185. // immediateClose: true
  186. // }));
  187. // }
  188. // else {
  189. env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
  190. _.hooks.run('before-insert', env);
  191. env.element.innerHTML = env.highlightedCode;
  192. callback && callback.call(element);
  193. _.hooks.run('after-highlight', env);
  194. _.hooks.run('complete', env);
  195. // }
  196. },
  197. highlight: function (text, grammar, language) {
  198. var tokens = _.tokenize(text, grammar);
  199. return Token.stringify(_.util.encode(tokens), language);
  200. },
  201. matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
  202. var Token = _.Token;
  203. for (var token in grammar) {
  204. if(!grammar.hasOwnProperty(token) || !grammar[token]) {
  205. continue;
  206. }
  207. if (token == target) {
  208. return;
  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 = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
  227. var str = strarr[i];
  228. if (strarr.length > text.length) {
  229. // Something went terribly wrong, ABORT, ABORT!
  230. return;
  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 || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
  250. p += 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. if (oneshot) {
  271. break;
  272. }
  273. continue;
  274. }
  275. if(lookbehind) {
  276. lookbehindLength = match[1].length;
  277. }
  278. var from = match.index + lookbehindLength,
  279. match = match[0].slice(lookbehindLength),
  280. to = from + match.length,
  281. before = str.slice(0, from),
  282. after = str.slice(to);
  283. var args = [i, delNum];
  284. if (before) {
  285. ++i;
  286. pos += before.length;
  287. args.push(before);
  288. }
  289. var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
  290. args.push(wrapped);
  291. if (after) {
  292. args.push(after);
  293. }
  294. Array.prototype.splice.apply(strarr, args);
  295. if (delNum != 1)
  296. _.matchGrammar(text, strarr, grammar, i, pos, true, token);
  297. if (oneshot)
  298. break;
  299. }
  300. }
  301. }
  302. },
  303. tokenize: function(text, grammar, language) {
  304. var strarr = [text];
  305. var rest = grammar.rest;
  306. if (rest) {
  307. for (var token in rest) {
  308. grammar[token] = rest[token];
  309. }
  310. delete grammar.rest;
  311. }
  312. _.matchGrammar(text, strarr, grammar, 0, 0, false);
  313. return strarr;
  314. },
  315. hooks: {
  316. all: {},
  317. add: function (name, callback) {
  318. var hooks = _.hooks.all;
  319. hooks[name] = hooks[name] || [];
  320. hooks[name].push(callback);
  321. },
  322. run: function (name, env) {
  323. var callbacks = _.hooks.all[name];
  324. if (!callbacks || !callbacks.length) {
  325. return;
  326. }
  327. for (var i=0, callback; callback = callbacks[i++];) {
  328. callback(env);
  329. }
  330. }
  331. }
  332. };
  333. var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
  334. this.type = type;
  335. this.content = content;
  336. this.alias = alias;
  337. // Copy of the full string this token was created from
  338. this.length = (matchedStr || "").length|0;
  339. this.greedy = !!greedy;
  340. };
  341. Token.stringify = function(o, language, parent) {
  342. if (typeof o == 'string') {
  343. return o;
  344. }
  345. if (_.util.type(o) === 'Array') {
  346. return o.map(function(element) {
  347. return Token.stringify(element, language, o);
  348. }).join('');
  349. }
  350. var env = {
  351. type: o.type,
  352. content: Token.stringify(o.content, language, parent),
  353. tag: 'span',
  354. classes: ['token', o.type],
  355. attributes: {},
  356. language: language,
  357. parent: parent
  358. };
  359. if (o.alias) {
  360. var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
  361. Array.prototype.push.apply(env.classes, aliases);
  362. }
  363. _.hooks.run('wrap', env);
  364. var attributes = Object.keys(env.attributes).map(function(name) {
  365. return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
  366. }).join(' ');
  367. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
  368. };
  369. // if (!_self.document) {
  370. // if (!_self.addEventListener) {
  371. // // in Node.js
  372. // return _self.Prism;
  373. // }
  374. // // In worker
  375. // _self.addEventListener('message', function(evt) {
  376. // var message = JSON.parse(evt.data),
  377. // lang = message.language,
  378. // code = message.code,
  379. // immediateClose = message.immediateClose;
  380. // _self.postMessage(_.highlight(code, _.languages[lang], lang));
  381. // if (immediateClose) {
  382. // _self.close();
  383. // }
  384. // }, false);
  385. // return _self.Prism;
  386. // }
  387. // //Get current script and highlight
  388. // var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
  389. // if (script) {
  390. // _.filename = script.src;
  391. // if (!_.manual && !script.hasAttribute('data-manual')) {
  392. // if(document.readyState !== "loading") {
  393. // if (window.requestAnimationFrame) {
  394. // window.requestAnimationFrame(_.highlightAll);
  395. // } else {
  396. // window.setTimeout(_.highlightAll, 16);
  397. // }
  398. // }
  399. // else {
  400. // document.addEventListener('DOMContentLoaded', _.highlightAll);
  401. // }
  402. // }
  403. // }
  404. return _self.Prism;
  405. })();
  406. if (typeof module !== 'undefined' && module.exports) {
  407. module.exports = Prism;
  408. }
  409. // hack for components to work correctly in node.js
  410. if (typeof global !== 'undefined') {
  411. global.Prism = Prism;
  412. }
  413. ;
  414. Prism.languages.markup = {
  415. 'comment': /<!--[\s\S]*?-->/,
  416. 'prolog': /<\?[\s\S]+?\?>/,
  417. 'doctype': /<!DOCTYPE[\s\S]+?>/i,
  418. 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
  419. 'tag': {
  420. pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
  421. inside: {
  422. 'tag': {
  423. pattern: /^<\/?[^\s>\/]+/i,
  424. inside: {
  425. 'punctuation': /^<\/?/,
  426. 'namespace': /^[^\s>\/:]+:/
  427. }
  428. },
  429. 'attr-value': {
  430. pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,
  431. inside: {
  432. 'punctuation': [
  433. /^=/,
  434. {
  435. pattern: /(^|[^\\])["']/,
  436. lookbehind: true
  437. }
  438. ]
  439. }
  440. },
  441. 'punctuation': /\/?>/,
  442. 'attr-name': {
  443. pattern: /[^\s>\/]+/,
  444. inside: {
  445. 'namespace': /^[^\s>\/:]+:/
  446. }
  447. }
  448. }
  449. },
  450. 'entity': /&#?[\da-z]{1,8};/i
  451. };
  452. Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
  453. Prism.languages.markup['entity'];
  454. // Plugin to make entity title show the real entity, idea by Roman Komarov
  455. Prism.hooks.add('wrap', function(env) {
  456. if (env.type === 'entity') {
  457. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  458. }
  459. });
  460. Prism.languages.xml = Prism.languages.markup;
  461. Prism.languages.html = Prism.languages.markup;
  462. Prism.languages.mathml = Prism.languages.markup;
  463. Prism.languages.svg = Prism.languages.markup;
  464. Prism.languages.css = {
  465. 'comment': /\/\*[\s\S]*?\*\//,
  466. 'atrule': {
  467. pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
  468. inside: {
  469. 'rule': /@[\w-]+/
  470. // See rest below
  471. }
  472. },
  473. 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
  474. 'selector': /[^{}\s][^{};]*?(?=\s*\{)/,
  475. 'string': {
  476. pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  477. greedy: true
  478. },
  479. 'property': /[\w-]+(?=\s*:)/i,
  480. 'important': /\B!important\b/i,
  481. 'function': /[-a-z0-9]+(?=\()/i,
  482. 'punctuation': /[(){};:]/
  483. };
  484. Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
  485. if (Prism.languages.markup) {
  486. Prism.languages.insertBefore('markup', 'tag', {
  487. 'style': {
  488. pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
  489. lookbehind: true,
  490. inside: Prism.languages.css,
  491. alias: 'language-css'
  492. }
  493. });
  494. Prism.languages.insertBefore('inside', 'attr-value', {
  495. 'style-attr': {
  496. pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
  497. inside: {
  498. 'attr-name': {
  499. pattern: /^\s*style/i,
  500. inside: Prism.languages.markup.tag.inside
  501. },
  502. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  503. 'attr-value': {
  504. pattern: /.+/i,
  505. inside: Prism.languages.css
  506. }
  507. },
  508. alias: 'language-css'
  509. }
  510. }, Prism.languages.markup.tag);
  511. };
  512. Prism.languages.clike = {
  513. 'comment': [
  514. {
  515. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  516. lookbehind: true
  517. },
  518. {
  519. pattern: /(^|[^\\:])\/\/.*/,
  520. lookbehind: true
  521. }
  522. ],
  523. 'string': {
  524. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  525. greedy: true
  526. },
  527. 'class-name': {
  528. pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
  529. lookbehind: true,
  530. inside: {
  531. punctuation: /[.\\]/
  532. }
  533. },
  534. 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  535. 'boolean': /\b(?:true|false)\b/,
  536. 'function': /[a-z0-9_]+(?=\()/i,
  537. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
  538. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
  539. 'punctuation': /[{}[\];(),.:]/
  540. };
  541. Prism.languages.javascript = Prism.languages.extend('clike', {
  542. '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/,
  543. 'number': /\b-?(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+(?:[Ee][+-]?\d+)?|NaN|Infinity)\b/,
  544. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  545. 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*\()/i,
  546. 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
  547. });
  548. Prism.languages.insertBefore('javascript', 'keyword', {
  549. 'regex': {
  550. pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,
  551. lookbehind: true,
  552. greedy: true
  553. },
  554. // This must be declared before keyword because we use "function" inside the look-forward
  555. 'function-variable': {
  556. pattern: /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)\s*=>))/i,
  557. alias: 'function'
  558. }
  559. });
  560. Prism.languages.insertBefore('javascript', 'string', {
  561. 'template-string': {
  562. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  563. greedy: true,
  564. inside: {
  565. 'interpolation': {
  566. pattern: /\$\{[^}]+\}/,
  567. inside: {
  568. 'interpolation-punctuation': {
  569. pattern: /^\$\{|\}$/,
  570. alias: 'punctuation'
  571. },
  572. rest: Prism.languages.javascript
  573. }
  574. },
  575. 'string': /[\s\S]+/
  576. }
  577. }
  578. });
  579. if (Prism.languages.markup) {
  580. Prism.languages.insertBefore('markup', 'tag', {
  581. 'script': {
  582. pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
  583. lookbehind: true,
  584. inside: Prism.languages.javascript,
  585. alias: 'language-javascript'
  586. }
  587. });
  588. }
  589. Prism.languages.js = Prism.languages.javascript;
  590. Prism.languages.c = Prism.languages.extend('clike', {
  591. 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
  592. 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
  593. 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i
  594. });
  595. Prism.languages.insertBefore('c', 'string', {
  596. 'macro': {
  597. // allow for multiline macro definitions
  598. // spaces after the # character compile fine with gcc
  599. pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
  600. lookbehind: true,
  601. alias: 'property',
  602. inside: {
  603. // highlight the path of the include statement as a string
  604. 'string': {
  605. pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
  606. lookbehind: true
  607. },
  608. // highlight macro directives as keywords
  609. 'directive': {
  610. pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
  611. lookbehind: true,
  612. alias: 'keyword'
  613. }
  614. }
  615. },
  616. // highlight predefined macros as constants
  617. 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
  618. });
  619. delete Prism.languages.c['class-name'];
  620. delete Prism.languages.c['boolean'];
  621. (function(Prism) {
  622. var insideString = {
  623. variable: [
  624. // Arithmetic Environment
  625. {
  626. pattern: /\$?\(\([\s\S]+?\)\)/,
  627. inside: {
  628. // If there is a $ sign at the beginning highlight $(( and )) as variable
  629. variable: [{
  630. pattern: /(^\$\(\([\s\S]+)\)\)/,
  631. lookbehind: true
  632. },
  633. /^\$\(\(/
  634. ],
  635. number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,
  636. // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
  637. operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
  638. // If there is no $ sign at the beginning highlight (( and )) as punctuation
  639. punctuation: /\(\(?|\)\)?|,|;/
  640. }
  641. },
  642. // Command Substitution
  643. {
  644. pattern: /\$\([^)]+\)|`[^`]+`/,
  645. inside: {
  646. variable: /^\$\(|^`|\)$|`$/
  647. }
  648. },
  649. /\$(?:[\w#?*!@]+|\{[^}]+\})/i
  650. ]
  651. };
  652. Prism.languages.bash = {
  653. 'shebang': {
  654. pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,
  655. alias: 'important'
  656. },
  657. 'comment': {
  658. pattern: /(^|[^"{\\])#.*/,
  659. lookbehind: true
  660. },
  661. 'string': [
  662. //Support for Here-Documents https://en.wikipedia.org/wiki/Here_document
  663. {
  664. pattern: /((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/,
  665. lookbehind: true,
  666. greedy: true,
  667. inside: insideString
  668. },
  669. {
  670. pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
  671. greedy: true,
  672. inside: insideString
  673. }
  674. ],
  675. 'variable': insideString.variable,
  676. // Originally based on http://ss64.com/bash/
  677. 'function': {
  678. pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,
  679. lookbehind: true
  680. },
  681. 'keyword': {
  682. pattern: /(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/,
  683. lookbehind: true
  684. },
  685. 'boolean': {
  686. pattern: /(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/,
  687. lookbehind: true
  688. },
  689. 'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,
  690. 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/
  691. };
  692. var inside = insideString.variable[1].inside;
  693. inside['function'] = Prism.languages.bash['function'];
  694. inside.keyword = Prism.languages.bash.keyword;
  695. inside.boolean = Prism.languages.bash.boolean;
  696. inside.operator = Prism.languages.bash.operator;
  697. inside.punctuation = Prism.languages.bash.punctuation;
  698. })(Prism);
  699. Prism.languages.cpp = Prism.languages.extend('c', {
  700. '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/,
  701. 'boolean': /\b(?:true|false)\b/,
  702. 'operator': /--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/
  703. });
  704. Prism.languages.insertBefore('cpp', 'keyword', {
  705. 'class-name': {
  706. pattern: /(class\s+)\w+/i,
  707. lookbehind: true
  708. }
  709. });
  710. (function(Prism) {
  711. // Ignore comments starting with { to privilege string interpolation highlighting
  712. var comment = /#(?!\{).+/,
  713. interpolation = {
  714. pattern: /#\{[^}]+\}/,
  715. alias: 'variable'
  716. };
  717. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  718. 'comment': comment,
  719. 'string': [
  720. // Strings are multiline
  721. {
  722. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  723. greedy: true
  724. },
  725. {
  726. // Strings are multiline
  727. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  728. greedy: true,
  729. inside: {
  730. 'interpolation': interpolation
  731. }
  732. }
  733. ],
  734. '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/,
  735. 'class-member': {
  736. pattern: /@(?!\d)\w+/,
  737. alias: 'variable'
  738. }
  739. });
  740. Prism.languages.insertBefore('coffeescript', 'comment', {
  741. 'multiline-comment': {
  742. pattern: /###[\s\S]+?###/,
  743. alias: 'comment'
  744. },
  745. // Block regexp can contain comments and interpolation
  746. 'block-regex': {
  747. pattern: /\/{3}[\s\S]*?\/{3}/,
  748. alias: 'regex',
  749. inside: {
  750. 'comment': comment,
  751. 'interpolation': interpolation
  752. }
  753. }
  754. });
  755. Prism.languages.insertBefore('coffeescript', 'string', {
  756. 'inline-javascript': {
  757. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  758. inside: {
  759. 'delimiter': {
  760. pattern: /^`|`$/,
  761. alias: 'punctuation'
  762. },
  763. rest: Prism.languages.javascript
  764. }
  765. },
  766. // Block strings
  767. 'multiline-string': [
  768. {
  769. pattern: /'''[\s\S]*?'''/,
  770. greedy: true,
  771. alias: 'string'
  772. },
  773. {
  774. pattern: /"""[\s\S]*?"""/,
  775. greedy: true,
  776. alias: 'string',
  777. inside: {
  778. interpolation: interpolation
  779. }
  780. }
  781. ]
  782. });
  783. Prism.languages.insertBefore('coffeescript', 'keyword', {
  784. // Object property
  785. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  786. });
  787. delete Prism.languages.coffeescript['template-string'];
  788. }(Prism));
  789. /**
  790. * Original by Samuel Flores
  791. *
  792. * Adds the following new token classes:
  793. * constant, builtin, variable, symbol, regex
  794. */
  795. (function(Prism) {
  796. Prism.languages.ruby = Prism.languages.extend('clike', {
  797. 'comment': [
  798. /#(?!\{[^\r\n]*?\}).*/,
  799. /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m
  800. ],
  801. '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/
  802. });
  803. var interpolation = {
  804. pattern: /#\{[^}]+\}/,
  805. inside: {
  806. 'delimiter': {
  807. pattern: /^#\{|\}$/,
  808. alias: 'tag'
  809. },
  810. rest: Prism.util.clone(Prism.languages.ruby)
  811. }
  812. };
  813. Prism.languages.insertBefore('ruby', 'keyword', {
  814. 'regex': [
  815. {
  816. pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/,
  817. greedy: true,
  818. inside: {
  819. 'interpolation': interpolation
  820. }
  821. },
  822. {
  823. pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
  824. greedy: true,
  825. inside: {
  826. 'interpolation': interpolation
  827. }
  828. },
  829. {
  830. // Here we need to specifically allow interpolation
  831. pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
  832. greedy: true,
  833. inside: {
  834. 'interpolation': interpolation
  835. }
  836. },
  837. {
  838. pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
  839. greedy: true,
  840. inside: {
  841. 'interpolation': interpolation
  842. }
  843. },
  844. {
  845. pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
  846. greedy: true,
  847. inside: {
  848. 'interpolation': interpolation
  849. }
  850. },
  851. {
  852. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
  853. lookbehind: true,
  854. greedy: true
  855. }
  856. ],
  857. 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
  858. 'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/
  859. });
  860. Prism.languages.insertBefore('ruby', 'number', {
  861. 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,
  862. 'constant': /\b[A-Z]\w*(?:[?!]|\b)/
  863. });
  864. Prism.languages.ruby.string = [
  865. {
  866. pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  867. greedy: true,
  868. inside: {
  869. 'interpolation': interpolation
  870. }
  871. },
  872. {
  873. pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
  874. greedy: true,
  875. inside: {
  876. 'interpolation': interpolation
  877. }
  878. },
  879. {
  880. // Here we need to specifically allow interpolation
  881. pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
  882. greedy: true,
  883. inside: {
  884. 'interpolation': interpolation
  885. }
  886. },
  887. {
  888. pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
  889. greedy: true,
  890. inside: {
  891. 'interpolation': interpolation
  892. }
  893. },
  894. {
  895. pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
  896. greedy: true,
  897. inside: {
  898. 'interpolation': interpolation
  899. }
  900. },
  901. {
  902. pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  903. greedy: true,
  904. inside: {
  905. 'interpolation': interpolation
  906. }
  907. }
  908. ];
  909. }(Prism));
  910. Prism.languages.d = Prism.languages.extend('clike', {
  911. 'string': [
  912. // r"", x""
  913. /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/,
  914. // q"[]", q"()", q"<>", q"{}"
  915. /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/,
  916. // q"IDENT
  917. // ...
  918. // IDENT"
  919. /\bq"([_a-zA-Z][_a-zA-Z\d]*)(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\1"/,
  920. // q"//", q"||", etc.
  921. /\bq"(.)[\s\S]*?\1"/,
  922. // Characters
  923. /'(?:\\'|\\?[^']+)'/,
  924. /(["`])(?:\\[\s\S]|(?!\1)[^\\])*\1[cwd]?/
  925. ],
  926. 'number': [
  927. // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
  928. // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
  929. /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i,
  930. {
  931. pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i,
  932. lookbehind: true
  933. }
  934. ],
  935. // In order: $, keywords and special tokens, globally defined symbols
  936. 'keyword': /\$|\b(?:abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|false|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|inout|int|interface|invariant|ireal|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|static|struct|super|switch|synchronized|template|this|throw|true|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__(?:(?:FILE|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__|gshared|traits|vector|parameters)|string|wstring|dstring|size_t|ptrdiff_t)\b/,
  937. 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
  938. });
  939. Prism.languages.d.comment = [
  940. // Shebang
  941. /^\s*#!.+/,
  942. // /+ +/
  943. {
  944. // Allow one level of nesting
  945. pattern: /(^|[^\\])\/\+(?:\/\+[\s\S]*?\+\/|[\s\S])*?\+\//,
  946. lookbehind: true
  947. }
  948. ].concat(Prism.languages.d.comment);
  949. Prism.languages.insertBefore('d', 'comment', {
  950. 'token-string': {
  951. // Allow one level of nesting
  952. pattern: /\bq\{(?:\{[^}]*\}|[^}])*\}/,
  953. alias: 'string'
  954. }
  955. });
  956. Prism.languages.insertBefore('d', 'keyword', {
  957. 'property': /\B@\w*/
  958. });
  959. Prism.languages.insertBefore('d', 'function', {
  960. 'register': {
  961. // Iasm registers
  962. pattern: /\b(?:[ABCD][LHX]|E[ABCD]X|E?(?:BP|SP|DI|SI)|[ECSDGF]S|CR[0234]|DR[012367]|TR[3-7]|X?MM[0-7]|R[ABCD]X|[BS]PL|R[BS]P|[DS]IL|R[DS]I|R(?:[89]|1[0-5])[BWD]?|XMM(?:[89]|1[0-5])|YMM(?:1[0-5]|\d))\b|\bST(?:\([0-7]\)|\b)/,
  963. alias: 'variable'
  964. }
  965. });
  966. // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
  967. // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
  968. var _django_template = {
  969. 'property': {
  970. pattern: /(?:{{|{%)[\s\S]*?(?:%}|}})/g,
  971. greedy: true,
  972. inside: {
  973. 'string': {
  974. pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  975. greedy: true
  976. },
  977. 'keyword': /\b(?:\||load|verbatim|widthratio|ssi|firstof|for|url|ifchanged|csrf_token|lorem|ifnotequal|autoescape|now|templatetag|debug|cycle|ifequal|regroup|comment|filter|endfilter|if|spaceless|with|extends|block|include|else|empty|endif|endfor|as|endblock|endautoescape|endverbatim|trans|endtrans|[Tt]rue|[Ff]alse|[Nn]one|in|is|static|macro|endmacro|call|endcall|set|endset|raw|endraw)\b/,
  978. 'operator' : /[-+=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
  979. 'function': /\b(?:_|abs|add|addslashes|attr|batch|callable|capfirst|capitalize|center|count|cut|d|date|default|default_if_none|defined|dictsort|dictsortreversed|divisibleby|e|equalto|escape|escaped|escapejs|even|filesizeformat|first|float|floatformat|force_escape|forceescape|format|get_digit|groupby|indent|int|iriencode|iterable|join|last|length|length_is|linebreaks|linebreaksbr|linenumbers|list|ljust|lower|make_list|map|mapping|number|odd|phone2numeric|pluralize|pprint|random|reject|rejectattr|removetags|replace|reverse|rjust|round|safe|safeseq|sameas|select|selectattr|sequence|slice|slugify|sort|string|stringformat|striptags|sum|time|timesince|timeuntil|title|trim|truncate|truncatechars|truncatechars_html|truncatewords|truncatewords_html|undefined|unordered_list|upper|urlencode|urlize|urlizetrunc|wordcount|wordwrap|xmlattr|yesno)\b/,
  980. 'important': /\b-?\d+(?:\.\d+)?\b/,
  981. 'variable': /\b\w+?\b/,
  982. 'punctuation' : /[[\];(),.:]/
  983. }
  984. }
  985. };
  986. Prism.languages.django = Prism.languages.extend('markup', {'comment': /(?:<!--|{#)[\s\S]*?(?:#}|-->)/});
  987. // Updated html tag pattern to allow template tags inside html tags
  988. Prism.languages.django.tag.pattern = /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^>=]+))?)*\s*\/?>/i;
  989. Prism.languages.insertBefore('django', 'entity', _django_template);
  990. Prism.languages.insertBefore('inside', 'tag', _django_template, Prism.languages.django.tag);
  991. if (Prism.languages.javascript) {
  992. // Combine js code and template tags painting inside <script> blocks
  993. Prism.languages.insertBefore('inside', 'string', _django_template, Prism.languages.django.script);
  994. Prism.languages.django.script.inside.string.inside = _django_template;
  995. }
  996. if (Prism.languages.css) {
  997. // Combine css code and template tags painting inside <style> blocks
  998. Prism.languages.insertBefore('inside', 'atrule', {'tag': _django_template.property}, Prism.languages.django.style);
  999. Prism.languages.django.style.inside.string.inside = _django_template;
  1000. }
  1001. // Add an Jinja2 alias
  1002. Prism.languages.jinja2 = Prism.languages.django;
  1003. Prism.languages.elixir = {
  1004. // Negative look-ahead is needed for string interpolation
  1005. // Negative look-behind is needed to avoid highlighting markdown headers in
  1006. // multi-line doc strings
  1007. 'comment': {
  1008. pattern: /(^|[^#])#(?![{#]).*/m,
  1009. lookbehind: true
  1010. },
  1011. // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
  1012. 'regex': /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
  1013. 'string': [
  1014. {
  1015. // ~s"""foo""" (multi-line), ~s'''foo''' (multi-line), ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo} (with interpolation care), ~s<foo>
  1016. pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
  1017. greedy: true,
  1018. inside: {
  1019. // See interpolation below
  1020. }
  1021. },
  1022. {
  1023. pattern: /("""|''')[\s\S]*?\1/,
  1024. greedy: true,
  1025. inside: {
  1026. // See interpolation below
  1027. }
  1028. },
  1029. {
  1030. // Multi-line strings are allowed
  1031. pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  1032. greedy: true,
  1033. inside: {
  1034. // See interpolation below
  1035. }
  1036. }
  1037. ],
  1038. 'atom': {
  1039. // Look-behind prevents bad highlighting of the :: operator
  1040. pattern: /(^|[^:]):\w+/,
  1041. lookbehind: true,
  1042. alias: 'symbol'
  1043. },
  1044. // Look-ahead prevents bad highlighting of the :: operator
  1045. 'attr-name': /\w+:(?!:)/,
  1046. 'capture': {
  1047. // Look-behind prevents bad highlighting of the && operator
  1048. pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
  1049. lookbehind: true,
  1050. alias: 'function'
  1051. },
  1052. 'argument': {
  1053. // Look-behind prevents bad highlighting of the && operator
  1054. pattern: /(^|[^&])&\d+/,
  1055. lookbehind: true,
  1056. alias: 'variable'
  1057. },
  1058. 'attribute': {
  1059. pattern: /@[\S]+/,
  1060. alias: 'variable'
  1061. },
  1062. 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
  1063. '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/,
  1064. 'boolean': /\b(?:true|false|nil)\b/,
  1065. 'operator': [
  1066. /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
  1067. {
  1068. // We don't want to match <<
  1069. pattern: /([^<])<(?!<)/,
  1070. lookbehind: true
  1071. },
  1072. {
  1073. // We don't want to match >>
  1074. pattern: /([^>])>(?!>)/,
  1075. lookbehind: true
  1076. }
  1077. ],
  1078. 'punctuation': /<<|>>|[.,%\[\]{}()]/
  1079. };
  1080. Prism.languages.elixir.string.forEach(function(o) {
  1081. o.inside = {
  1082. 'interpolation': {
  1083. pattern: /#\{[^}]+\}/,
  1084. inside: {
  1085. 'delimiter': {
  1086. pattern: /^#\{|\}$/,
  1087. alias: 'punctuation'
  1088. },
  1089. rest: Prism.util.clone(Prism.languages.elixir)
  1090. }
  1091. }
  1092. };
  1093. });
  1094. Prism.languages.erlang = {
  1095. 'comment': /%.+/,
  1096. 'string': {
  1097. pattern: /"(?:\\.|[^\\"\r\n])*"/,
  1098. greedy: true
  1099. },
  1100. 'quoted-function': {
  1101. pattern: /'(?:\\.|[^\\'\r\n])+'(?=\()/,
  1102. alias: 'function'
  1103. },
  1104. 'quoted-atom': {
  1105. pattern: /'(?:\\.|[^\\'\r\n])+'/,
  1106. alias: 'atom'
  1107. },
  1108. 'boolean': /\b(?:true|false)\b/,
  1109. 'keyword': /\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,
  1110. 'number': [
  1111. /\$\\?./,
  1112. /\d+#[a-z0-9]+/i,
  1113. /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/
  1114. ],
  1115. 'function': /\b[a-z][\w@]*(?=\()/,
  1116. 'variable': {
  1117. // Look-behind is used to prevent wrong highlighting of atoms containing "@"
  1118. pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
  1119. lookbehind: true
  1120. },
  1121. 'operator': [
  1122. /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
  1123. {
  1124. // We don't want to match <<
  1125. pattern: /(^|[^<])<(?!<)/,
  1126. lookbehind: true
  1127. },
  1128. {
  1129. // We don't want to match >>
  1130. pattern: /(^|[^>])>(?!>)/,
  1131. lookbehind: true
  1132. }
  1133. ],
  1134. 'atom': /\b[a-z][\w@]*/,
  1135. 'punctuation': /[()[\]{}:;,.#|]|<<|>>/
  1136. };
  1137. Prism.languages.go = Prism.languages.extend('clike', {
  1138. '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/,
  1139. '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/,
  1140. 'boolean': /\b(?:_|iota|nil|true|false)\b/,
  1141. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  1142. 'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
  1143. 'string': {
  1144. pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
  1145. greedy: true
  1146. }
  1147. });
  1148. delete Prism.languages.go['class-name'];
  1149. Prism.languages.java = Prism.languages.extend('clike', {
  1150. 'keyword': /\b(?:abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,
  1151. 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,
  1152. 'operator': {
  1153. pattern: /(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
  1154. lookbehind: true
  1155. }
  1156. });
  1157. Prism.languages.insertBefore('java','function', {
  1158. 'annotation': {
  1159. alias: 'punctuation',
  1160. pattern: /(^|[^.])@\w+/,
  1161. lookbehind: true
  1162. }
  1163. });
  1164. Prism.languages.json = {
  1165. 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
  1166. 'string': {
  1167. pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
  1168. greedy: true
  1169. },
  1170. 'number': /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][+-]?\d+)?)\b/,
  1171. 'punctuation': /[{}[\]);,]/,
  1172. 'operator': /:/g,
  1173. 'boolean': /\b(?:true|false)\b/i,
  1174. 'null': /\bnull\b/i
  1175. };
  1176. Prism.languages.jsonp = Prism.languages.json;
  1177. (function (Prism) {
  1178. Prism.languages.kotlin = Prism.languages.extend('clike', {
  1179. 'keyword': {
  1180. // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
  1181. 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/,
  1182. lookbehind: true
  1183. },
  1184. 'function': [
  1185. /\w+(?=\s*\()/,
  1186. {
  1187. pattern: /(\.)\w+(?=\s*\{)/,
  1188. lookbehind: true
  1189. }
  1190. ],
  1191. 'number': /\b(?:0[bx][\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?[fFL]?)\b/,
  1192. 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
  1193. });
  1194. delete Prism.languages.kotlin["class-name"];
  1195. Prism.languages.insertBefore('kotlin', 'string', {
  1196. 'raw-string': {
  1197. pattern: /("""|''')[\s\S]*?\1/,
  1198. alias: 'string'
  1199. // See interpolation below
  1200. }
  1201. });
  1202. Prism.languages.insertBefore('kotlin', 'keyword', {
  1203. 'annotation': {
  1204. pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
  1205. alias: 'builtin'
  1206. }
  1207. });
  1208. Prism.languages.insertBefore('kotlin', 'function', {
  1209. 'label': {
  1210. pattern: /\w+@|@\w+/,
  1211. alias: 'symbol'
  1212. }
  1213. });
  1214. var interpolation = [
  1215. {
  1216. pattern: /\$\{[^}]+\}/,
  1217. inside: {
  1218. delimiter: {
  1219. pattern: /^\$\{|\}$/,
  1220. alias: 'variable'
  1221. },
  1222. rest: Prism.util.clone(Prism.languages.kotlin)
  1223. }
  1224. },
  1225. {
  1226. pattern: /\$\w+/,
  1227. alias: 'variable'
  1228. }
  1229. ];
  1230. Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
  1231. interpolation: interpolation
  1232. };
  1233. }(Prism));
  1234. Prism.languages.lua = {
  1235. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  1236. // \z may be used to skip the following space
  1237. 'string': {
  1238. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  1239. greedy: true
  1240. },
  1241. 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  1242. '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/,
  1243. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  1244. 'operator': [
  1245. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  1246. {
  1247. // Match ".." but don't break "..."
  1248. pattern: /(^|[^.])\.\.(?!\.)/,
  1249. lookbehind: true
  1250. }
  1251. ],
  1252. 'punctuation': /[\[\](){},;]|\.+|:+/
  1253. };
  1254. Prism.languages.nginx = Prism.languages.extend('clike', {
  1255. 'comment': {
  1256. pattern: /(^|[^"{\\])#.*/,
  1257. lookbehind: true
  1258. },
  1259. 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i
  1260. });
  1261. Prism.languages.insertBefore('nginx', 'keyword', {
  1262. 'variable': /\$[a-z_]+/i
  1263. });
  1264. Prism.languages.nim = {
  1265. 'comment': /#.*/,
  1266. // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
  1267. // Character literals are handled specifically to prevent issues with numeric type suffixes
  1268. 'string': {
  1269. pattern: /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,
  1270. greedy: true
  1271. },
  1272. // The negative look ahead prevents wrong highlighting of the .. operator
  1273. 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
  1274. 'keyword': /\b(?:addr|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|include|interface|iterator|let|macro|method|mixin|nil|object|out|proc|ptr|raise|ref|return|static|template|try|tuple|type|using|var|when|while|with|without|yield)\b/,
  1275. 'function': {
  1276. pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
  1277. inside: {
  1278. 'operator': /\*$/
  1279. }
  1280. },
  1281. // We don't want to highlight operators inside backticks
  1282. 'ignore': {
  1283. pattern: /`[^`\r\n]+`/,
  1284. inside: {
  1285. 'punctuation': /`/
  1286. }
  1287. },
  1288. 'operator': {
  1289. // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
  1290. // but allow the slice operator .. to take precedence over them
  1291. // One can define his own operators in Nim so all combination of operators might be an operator.
  1292. pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr|xor)\b)/m,
  1293. lookbehind: true
  1294. },
  1295. 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
  1296. };
  1297. Prism.languages.perl = {
  1298. 'comment': [
  1299. {
  1300. // POD
  1301. pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
  1302. lookbehind: true
  1303. },
  1304. {
  1305. pattern: /(^|[^\\$])#.*/,
  1306. lookbehind: true
  1307. }
  1308. ],
  1309. // TODO Could be nice to handle Heredoc too.
  1310. 'string': [
  1311. // q/.../
  1312. {
  1313. pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  1314. greedy: true
  1315. },
  1316. // q a...a
  1317. {
  1318. pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  1319. greedy: true
  1320. },
  1321. // q(...)
  1322. {
  1323. pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
  1324. greedy: true
  1325. },
  1326. // q{...}
  1327. {
  1328. pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
  1329. greedy: true
  1330. },
  1331. // q[...]
  1332. {
  1333. pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
  1334. greedy: true
  1335. },
  1336. // q<...>
  1337. {
  1338. pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
  1339. greedy: true
  1340. },
  1341. // "...", `...`
  1342. {
  1343. pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  1344. greedy: true
  1345. },
  1346. // '...'
  1347. // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  1348. {
  1349. pattern: /'(?:[^'\\\r\n]|\\.)*'/,
  1350. greedy: true
  1351. }
  1352. ],
  1353. 'regex': [
  1354. // m/.../
  1355. {
  1356. pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  1357. greedy: true
  1358. },
  1359. // m a...a
  1360. {
  1361. pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  1362. greedy: true
  1363. },
  1364. // m(...)
  1365. {
  1366. pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
  1367. greedy: true
  1368. },
  1369. // m{...}
  1370. {
  1371. pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
  1372. greedy: true
  1373. },
  1374. // m[...]
  1375. {
  1376. pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
  1377. greedy: true
  1378. },
  1379. // m<...>
  1380. {
  1381. pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  1382. greedy: true
  1383. },
  1384. // The lookbehinds prevent -s from breaking
  1385. // FIXME We don't handle change of separator like s(...)[...]
  1386. // s/.../.../
  1387. {
  1388. pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  1389. lookbehind: true,
  1390. greedy: true
  1391. },
  1392. // s a...a...a
  1393. {
  1394. pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  1395. lookbehind: true,
  1396. greedy: true
  1397. },
  1398. // s(...)(...)
  1399. {
  1400. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  1401. lookbehind: true,
  1402. greedy: true
  1403. },
  1404. // s{...}{...}
  1405. {
  1406. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  1407. lookbehind: true,
  1408. greedy: true
  1409. },
  1410. // s[...][...]
  1411. {
  1412. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  1413. lookbehind: true,
  1414. greedy: true
  1415. },
  1416. // s<...><...>
  1417. {
  1418. pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  1419. lookbehind: true,
  1420. greedy: true
  1421. },
  1422. // /.../
  1423. // The look-ahead tries to prevent two divisions on
  1424. // the same line from being highlighted as regex.
  1425. // This does not support multi-line regex.
  1426. {
  1427. pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
  1428. greedy: true
  1429. }
  1430. ],
  1431. // FIXME Not sure about the handling of ::, ', and #
  1432. 'variable': [
  1433. // ${^POSTMATCH}
  1434. /[&*$@%]\{\^[A-Z]+\}/,
  1435. // $^V
  1436. /[&*$@%]\^[A-Z_]/,
  1437. // ${...}
  1438. /[&*$@%]#?(?=\{)/,
  1439. // $foo
  1440. /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
  1441. // $1
  1442. /[&*$@%]\d+/,
  1443. // $_, @_, %!
  1444. // The negative lookahead prevents from breaking the %= operator
  1445. /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
  1446. ],
  1447. 'filehandle': {
  1448. // <>, <FOO>, _
  1449. pattern: /<(?![<=])\S*>|\b_\b/,
  1450. alias: 'symbol'
  1451. },
  1452. 'vstring': {
  1453. // v1.2, 1.2.3
  1454. pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
  1455. alias: 'string'
  1456. },
  1457. 'function': {
  1458. pattern: /sub [a-z0-9_]+/i,
  1459. inside: {
  1460. keyword: /sub/
  1461. }
  1462. },
  1463. '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/,
  1464. 'number': /\b-?(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
  1465. 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
  1466. 'punctuation': /[{}[\];(),:]/
  1467. };
  1468. /**
  1469. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  1470. * Modified by Miles Johnson: http://milesj.me
  1471. *
  1472. * Supports the following:
  1473. * - Extends clike syntax
  1474. * - Support for PHP 5.3+ (namespaces, traits, generators, etc)
  1475. * - Smarter constant and function matching
  1476. *
  1477. * Adds the following new token classes:
  1478. * constant, delimiter, variable, function, package
  1479. */
  1480. Prism.languages.php = Prism.languages.extend('clike', {
  1481. '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,
  1482. 'constant': /\b[A-Z0-9_]{2,}\b/,
  1483. 'comment': {
  1484. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  1485. lookbehind: true
  1486. }
  1487. });
  1488. // Shell-like comments are matched after strings, because they are less
  1489. // common than strings containing hashes...
  1490. Prism.languages.insertBefore('php', 'class-name', {
  1491. 'shell-comment': {
  1492. pattern: /(^|[^\\])#.*/,
  1493. lookbehind: true,
  1494. alias: 'comment'
  1495. }
  1496. });
  1497. Prism.languages.insertBefore('php', 'keyword', {
  1498. 'delimiter': {
  1499. pattern: /\?>|<\?(?:php|=)?/i,
  1500. alias: 'important'
  1501. },
  1502. 'variable': /\$\w+\b/i,
  1503. 'package': {
  1504. pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
  1505. lookbehind: true,
  1506. inside: {
  1507. punctuation: /\\/
  1508. }
  1509. }
  1510. });
  1511. // Must be defined after the function pattern
  1512. Prism.languages.insertBefore('php', 'operator', {
  1513. 'property': {
  1514. pattern: /(->)[\w]+/,
  1515. lookbehind: true
  1516. }
  1517. });
  1518. // Add HTML support if the markup language exists
  1519. if (Prism.languages.markup) {
  1520. // Tokenize all inline PHP blocks that are wrapped in <?php ?>
  1521. // This allows for easy PHP + markup highlighting
  1522. Prism.hooks.add('before-highlight', function(env) {
  1523. if (env.language !== 'php' || !/(?:<\?php|<\?)/ig.test(env.code)) {
  1524. return;
  1525. }
  1526. env.tokenStack = [];
  1527. env.backupCode = env.code;
  1528. env.code = env.code.replace(/(?:<\?php|<\?)[\s\S]*?(?:\?>|$)/ig, function(match) {
  1529. var i = env.tokenStack.length;
  1530. // Check for existing strings
  1531. while (env.backupCode.indexOf('___PHP' + i + '___') !== -1)
  1532. ++i;
  1533. // Create a sparse array
  1534. env.tokenStack[i] = match;
  1535. return '___PHP' + i + '___';
  1536. });
  1537. // Switch the grammar to markup
  1538. env.grammar = Prism.languages.markup;
  1539. });
  1540. // Restore env.code for other plugins (e.g. line-numbers)
  1541. Prism.hooks.add('before-insert', function(env) {
  1542. if (env.language === 'php' && env.backupCode) {
  1543. env.code = env.backupCode;
  1544. delete env.backupCode;
  1545. }
  1546. });
  1547. // Re-insert the tokens after highlighting
  1548. Prism.hooks.add('after-highlight', function(env) {
  1549. if (env.language !== 'php' || !env.tokenStack) {
  1550. return;
  1551. }
  1552. // Switch the grammar back
  1553. env.grammar = Prism.languages.php;
  1554. for (var i = 0, keys = Object.keys(env.tokenStack); i < keys.length; ++i) {
  1555. var k = keys[i];
  1556. var t = env.tokenStack[k];
  1557. // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
  1558. env.highlightedCode = env.highlightedCode.replace('___PHP' + k + '___',
  1559. "<span class=\"token php language-php\">" +
  1560. Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +
  1561. "</span>");
  1562. }
  1563. env.element.innerHTML = env.highlightedCode;
  1564. });
  1565. }
  1566. ;
  1567. Prism.languages.python = {
  1568. 'comment': {
  1569. pattern: /(^|[^\\])#.*/,
  1570. lookbehind: true
  1571. },
  1572. 'triple-quoted-string': {
  1573. pattern: /("""|''')[\s\S]+?\1/,
  1574. greedy: true,
  1575. alias: 'string'
  1576. },
  1577. 'string': {
  1578. pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1579. greedy: true
  1580. },
  1581. 'function': {
  1582. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  1583. lookbehind: true
  1584. },
  1585. 'class-name': {
  1586. pattern: /(\bclass\s+)\w+/i,
  1587. lookbehind: true
  1588. },
  1589. 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
  1590. 'builtin':/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
  1591. 'boolean': /\b(?:True|False|None)\b/,
  1592. 'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
  1593. 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
  1594. 'punctuation': /[{}[\];(),.:]/
  1595. };
  1596. (function(Prism) {
  1597. var javascript = Prism.util.clone(Prism.languages.javascript);
  1598. Prism.languages.jsx = Prism.languages.extend('markup', javascript);
  1599. Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+|(?:\{[^}]*\})))?|\{\.{3}\w+\}))*\s*\/?>/i;
  1600. Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
  1601. Prism.languages.insertBefore('inside', 'attr-name', {
  1602. 'spread': {
  1603. pattern: /\{\.{3}\w+\}/,
  1604. inside: {
  1605. 'punctuation': /[{}]|\.{3}/,
  1606. 'attr-value': /\w+/
  1607. }
  1608. }
  1609. }, Prism.languages.jsx.tag);
  1610. var jsxExpression = Prism.util.clone(Prism.languages.jsx);
  1611. delete jsxExpression.punctuation;
  1612. jsxExpression = Prism.languages.insertBefore('jsx', 'operator', {
  1613. 'punctuation': /=(?={)|[{}[\];(),.:]/
  1614. }, { jsx: jsxExpression });
  1615. Prism.languages.insertBefore('inside', 'attr-value',{
  1616. 'script': {
  1617. // Allow for one level of nesting
  1618. pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i,
  1619. inside: jsxExpression,
  1620. 'alias': 'language-javascript'
  1621. }
  1622. }, Prism.languages.jsx.tag);
  1623. }(Prism));
  1624. (function(Prism) {
  1625. Prism.languages.crystal = Prism.languages.extend('ruby', {
  1626. keyword: [
  1627. /\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/,
  1628. {
  1629. pattern: /(\.\s*)(?:is_a|responds_to)\?/,
  1630. lookbehind: true
  1631. }
  1632. ],
  1633. number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[0-9a-fA-F_]*[0-9a-fA-F]|(?:\d(?:[0-9_]*\d)?)(?:\.[0-9_]*\d)?(?:[eE][+-]?[0-9_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
  1634. });
  1635. var rest = Prism.util.clone(Prism.languages.crystal);
  1636. Prism.languages.insertBefore('crystal', 'string', {
  1637. attribute: {
  1638. pattern: /@\[.+?\]/,
  1639. alias: 'attr-name',
  1640. inside: {
  1641. delimiter: {
  1642. pattern: /^@\[|\]$/,
  1643. alias: 'tag'
  1644. },
  1645. rest: rest
  1646. }
  1647. },
  1648. expansion: [
  1649. {
  1650. pattern: /\{\{.+?\}\}/,
  1651. inside: {
  1652. delimiter: {
  1653. pattern: /^\{\{|\}\}$/,
  1654. alias: 'tag'
  1655. },
  1656. rest: rest
  1657. }
  1658. },
  1659. {
  1660. pattern: /\{%.+?%\}/,
  1661. inside: {
  1662. delimiter: {
  1663. pattern: /^\{%|%\}$/,
  1664. alias: 'tag'
  1665. },
  1666. rest: rest
  1667. }
  1668. }
  1669. ]
  1670. });
  1671. }(Prism));
  1672. /* TODO
  1673. Add support for Markdown notation inside doc comments
  1674. Add support for nested block comments...
  1675. Match closure params even when not followed by dash or brace
  1676. Add better support for macro definition
  1677. */
  1678. Prism.languages.rust = {
  1679. 'comment': [
  1680. {
  1681. pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
  1682. lookbehind: true
  1683. },
  1684. {
  1685. pattern: /(^|[^\\:])\/\/.*/,
  1686. lookbehind: true
  1687. }
  1688. ],
  1689. 'string': [
  1690. {
  1691. pattern: /b?r(#*)"(?:\\.|(?!"\1)[^\\\r\n])*"\1/,
  1692. greedy: true
  1693. },
  1694. {
  1695. pattern: /b?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1696. greedy: true
  1697. }
  1698. ],
  1699. '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/,
  1700. 'attribute': {
  1701. pattern: /#!?\[.+?\]/,
  1702. greedy: true,
  1703. alias: 'attr-name'
  1704. },
  1705. 'function': [
  1706. /\w+(?=\s*\()/,
  1707. // Macros can use parens or brackets
  1708. /\w+!(?=\s*\(|\[)/
  1709. ],
  1710. 'macro-rules': {
  1711. pattern: /\w+!/,
  1712. alias: 'function'
  1713. },
  1714. // Hex, oct, bin, dec numbers with visual separators and type suffix
  1715. '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/,
  1716. // Closure params should not be confused with bitwise OR |
  1717. 'closure-params': {
  1718. pattern: /\|[^|]*\|(?=\s*[{-])/,
  1719. inside: {
  1720. 'punctuation': /[|:,]/,
  1721. 'operator': /[&*]/
  1722. }
  1723. },
  1724. 'punctuation': /[{}[\];(),:]|\.+|->/,
  1725. 'operator': /[-+*\/%!^=]=?|@|&[&=]?|\|[|=]?|<<?=?|>>?=?/
  1726. };
  1727. Prism.languages.scss = Prism.languages.extend('css', {
  1728. 'comment': {
  1729. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  1730. lookbehind: true
  1731. },
  1732. 'atrule': {
  1733. pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
  1734. inside: {
  1735. 'rule': /@[\w-]+/
  1736. // See rest below
  1737. }
  1738. },
  1739. // url, compassified
  1740. 'url': /(?:[-a-z]+-)*url(?=\()/i,
  1741. // CSS selector regex is not appropriate for Sass
  1742. // since there can be lot more things (var, @ directive, nesting..)
  1743. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  1744. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  1745. // 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
  1746. // can "pass" as a selector- e.g: proper#{$erty})
  1747. // this one was hard to do, so please be careful if you edit this one :)
  1748. 'selector': {
  1749. // Initial look-ahead is used to prevent matching of blank selectors
  1750. pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|&|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
  1751. inside: {
  1752. 'parent': {
  1753. pattern: /&/,
  1754. alias: 'important'
  1755. },
  1756. 'placeholder': /%[-\w]+/,
  1757. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  1758. }
  1759. }
  1760. });
  1761. Prism.languages.insertBefore('scss', 'atrule', {
  1762. 'keyword': [
  1763. /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
  1764. {
  1765. pattern: /( +)(?:from|through)(?= )/,
  1766. lookbehind: true
  1767. }
  1768. ]
  1769. });
  1770. Prism.languages.scss.property = {
  1771. pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/i,
  1772. inside: {
  1773. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  1774. }
  1775. };
  1776. Prism.languages.insertBefore('scss', 'important', {
  1777. // var and interpolated vars
  1778. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  1779. });
  1780. Prism.languages.insertBefore('scss', 'function', {
  1781. 'placeholder': {
  1782. pattern: /%[-\w]+/,
  1783. alias: 'selector'
  1784. },
  1785. 'statement': {
  1786. pattern: /\B!(?:default|optional)\b/i,
  1787. alias: 'keyword'
  1788. },
  1789. 'boolean': /\b(?:true|false)\b/,
  1790. 'null': /\bnull\b/,
  1791. 'operator': {
  1792. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
  1793. lookbehind: true
  1794. }
  1795. });
  1796. Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss);
  1797. Prism.languages.sql= {
  1798. 'comment': {
  1799. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
  1800. lookbehind: true
  1801. },
  1802. 'string' : {
  1803. pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\])*\2/,
  1804. greedy: true,
  1805. lookbehind: true
  1806. },
  1807. 'variable': /@[\w.$]+|@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
  1808. '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?
  1809. '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,
  1810. 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
  1811. 'number': /\b-?(?:0x)?\d*\.?[\da-f]+\b/,
  1812. 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  1813. 'punctuation': /[;[\]()`,.]/
  1814. };
  1815. Prism.languages.typescript = Prism.languages.extend('javascript', {
  1816. // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
  1817. 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield|false|true|module|declare|constructor|string|Function|any|number|boolean|Array|symbol|namespace|abstract|require|type)\b/
  1818. });
  1819. Prism.languages.ts = Prism.languages.typescript;
  1820. Prism.languages.yaml = {
  1821. 'scalar': {
  1822. pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
  1823. lookbehind: true,
  1824. alias: 'string'
  1825. },
  1826. 'comment': /#.*/,
  1827. 'key': {
  1828. pattern: /(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/,
  1829. lookbehind: true,
  1830. alias: 'atrule'
  1831. },
  1832. 'directive': {
  1833. pattern: /(^[ \t]*)%.+/m,
  1834. lookbehind: true,
  1835. alias: 'important'
  1836. },
  1837. 'datetime': {
  1838. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?)?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?)(?=[ \t]*(?:$|,|]|}))/m,
  1839. lookbehind: true,
  1840. alias: 'number'
  1841. },
  1842. 'boolean': {
  1843. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im,
  1844. lookbehind: true,
  1845. alias: 'important'
  1846. },
  1847. 'null': {
  1848. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im,
  1849. lookbehind: true,
  1850. alias: 'important'
  1851. },
  1852. 'string': {
  1853. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}))/m,
  1854. lookbehind: true,
  1855. greedy: true
  1856. },
  1857. 'number': {
  1858. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+\-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
  1859. lookbehind: true
  1860. },
  1861. 'tag': /![^\s]+/,
  1862. 'important': /[&*][\w]+/,
  1863. 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
  1864. };
  1865. Prism.languages.dart = Prism.languages.extend('clike', {
  1866. 'string': [
  1867. {
  1868. pattern: /r?("""|''')[\s\S]*?\1/,
  1869. greedy: true
  1870. },
  1871. {
  1872. pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1873. greedy: true
  1874. }
  1875. ],
  1876. 'keyword': [
  1877. /\b(?:async|sync|yield)\*/,
  1878. /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/
  1879. ],
  1880. 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
  1881. });
  1882. Prism.languages.insertBefore('dart','function',{
  1883. 'metadata': {
  1884. pattern: /@\w+/,
  1885. alias: 'symbol'
  1886. }
  1887. });