prism.js 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843
  1. /* PrismJS 1.17.1
  2. https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+markup-templating+elixir+erlang+go+groovy+java+php+json+julia+kotlin+crystal+lua+django+matlab+typescript+nginx+nim+perl+sql+scss+python+jsx+rust+yaml */
  3. var _self = (typeof window !== 'undefined')
  4. ? window // if in browser
  5. : (
  6. (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
  7. ? self // if in worker
  8. : {} // if in node js
  9. );
  10. /**
  11. * Prism: Lightweight, robust, elegant syntax highlighting
  12. * MIT license http://www.opensource.org/licenses/mit-license.php/
  13. * @author Lea Verou http://lea.verou.me
  14. */
  15. var Prism = (function (_self){
  16. // Private helper vars
  17. var lang = /\blang(?:uage)?-([\w-]+)\b/i;
  18. var uniqueId = 0;
  19. var _ = {
  20. manual: _self.Prism && _self.Prism.manual,
  21. disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
  22. util: {
  23. encode: function (tokens) {
  24. if (tokens instanceof Token) {
  25. return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
  26. } else if (Array.isArray(tokens)) {
  27. return tokens.map(_.util.encode);
  28. } else {
  29. return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
  30. }
  31. },
  32. type: function (o) {
  33. return Object.prototype.toString.call(o).slice(8, -1);
  34. },
  35. objId: function (obj) {
  36. if (!obj['__id']) {
  37. Object.defineProperty(obj, '__id', { value: ++uniqueId });
  38. }
  39. return obj['__id'];
  40. },
  41. // Deep clone a language definition (e.g. to extend it)
  42. clone: function deepClone(o, visited) {
  43. var clone, id, type = _.util.type(o);
  44. visited = visited || {};
  45. switch (type) {
  46. case 'Object':
  47. id = _.util.objId(o);
  48. if (visited[id]) {
  49. return visited[id];
  50. }
  51. clone = {};
  52. visited[id] = clone;
  53. for (var key in o) {
  54. if (o.hasOwnProperty(key)) {
  55. clone[key] = deepClone(o[key], visited);
  56. }
  57. }
  58. return clone;
  59. case 'Array':
  60. id = _.util.objId(o);
  61. if (visited[id]) {
  62. return visited[id];
  63. }
  64. clone = [];
  65. visited[id] = clone;
  66. o.forEach(function (v, i) {
  67. clone[i] = deepClone(v, visited);
  68. });
  69. return clone;
  70. default:
  71. return o;
  72. }
  73. }
  74. },
  75. languages: {
  76. extend: function (id, redef) {
  77. var lang = _.util.clone(_.languages[id]);
  78. for (var key in redef) {
  79. lang[key] = redef[key];
  80. }
  81. return lang;
  82. },
  83. /**
  84. * Insert a token before another token in a language literal
  85. * As this needs to recreate the object (we cannot actually insert before keys in object literals),
  86. * we cannot just provide an object, we need an object and a key.
  87. * @param inside The key (or language id) of the parent
  88. * @param before The key to insert before.
  89. * @param insert Object with the key/value pairs to insert
  90. * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
  91. */
  92. insertBefore: function (inside, before, insert, root) {
  93. root = root || _.languages;
  94. var grammar = root[inside];
  95. var ret = {};
  96. for (var token in grammar) {
  97. if (grammar.hasOwnProperty(token)) {
  98. if (token == before) {
  99. for (var newToken in insert) {
  100. if (insert.hasOwnProperty(newToken)) {
  101. ret[newToken] = insert[newToken];
  102. }
  103. }
  104. }
  105. // Do not insert token which also occur in insert. See #1525
  106. if (!insert.hasOwnProperty(token)) {
  107. ret[token] = grammar[token];
  108. }
  109. }
  110. }
  111. var old = root[inside];
  112. root[inside] = ret;
  113. // Update references in other language definitions
  114. _.languages.DFS(_.languages, function(key, value) {
  115. if (value === old && key != inside) {
  116. this[key] = ret;
  117. }
  118. });
  119. return ret;
  120. },
  121. // Traverse a language definition with Depth First Search
  122. DFS: function DFS(o, callback, type, visited) {
  123. visited = visited || {};
  124. var objId = _.util.objId;
  125. for (var i in o) {
  126. if (o.hasOwnProperty(i)) {
  127. callback.call(o, i, o[i], type || i);
  128. var property = o[i],
  129. propertyType = _.util.type(property);
  130. if (propertyType === 'Object' && !visited[objId(property)]) {
  131. visited[objId(property)] = true;
  132. DFS(property, callback, null, visited);
  133. }
  134. else if (propertyType === 'Array' && !visited[objId(property)]) {
  135. visited[objId(property)] = true;
  136. DFS(property, callback, i, visited);
  137. }
  138. }
  139. }
  140. }
  141. },
  142. plugins: {},
  143. highlightAll: function(async, callback) {
  144. _.highlightAllUnder(document, async, callback);
  145. },
  146. highlightAllUnder: function(container, async, callback) {
  147. var env = {
  148. callback: callback,
  149. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  150. };
  151. _.hooks.run('before-highlightall', env);
  152. var elements = container.querySelectorAll(env.selector);
  153. for (var i=0, element; element = elements[i++];) {
  154. _.highlightElement(element, async === true, env.callback);
  155. }
  156. },
  157. highlightElement: function(element, async, callback) {
  158. // Find language
  159. var language = 'none', grammar, parent = element;
  160. while (parent && !lang.test(parent.className)) {
  161. parent = parent.parentNode;
  162. }
  163. if (parent) {
  164. language = (parent.className.match(lang) || [,'none'])[1].toLowerCase();
  165. grammar = _.languages[language];
  166. }
  167. // Set language on the element, if not present
  168. element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  169. if (element.parentNode) {
  170. // Set language on the parent, for styling
  171. parent = element.parentNode;
  172. if (/pre/i.test(parent.nodeName)) {
  173. parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  174. }
  175. }
  176. var code = element.textContent;
  177. var env = {
  178. element: element,
  179. language: language,
  180. grammar: grammar,
  181. code: code
  182. };
  183. var insertHighlightedCode = function (highlightedCode) {
  184. env.highlightedCode = highlightedCode;
  185. _.hooks.run('before-insert', env);
  186. env.element.innerHTML = env.highlightedCode;
  187. _.hooks.run('after-highlight', env);
  188. _.hooks.run('complete', env);
  189. callback && callback.call(env.element);
  190. }
  191. _.hooks.run('before-sanity-check', env);
  192. if (!env.code) {
  193. _.hooks.run('complete', env);
  194. return;
  195. }
  196. _.hooks.run('before-highlight', env);
  197. if (!env.grammar) {
  198. insertHighlightedCode(_.util.encode(env.code));
  199. return;
  200. }
  201. if (async && _self.Worker) {
  202. var worker = new Worker(_.filename);
  203. worker.onmessage = function(evt) {
  204. insertHighlightedCode(evt.data);
  205. };
  206. worker.postMessage(JSON.stringify({
  207. language: env.language,
  208. code: env.code,
  209. immediateClose: true
  210. }));
  211. }
  212. else {
  213. insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
  214. }
  215. },
  216. highlight: function (text, grammar, language) {
  217. var env = {
  218. code: text,
  219. grammar: grammar,
  220. language: language
  221. };
  222. _.hooks.run('before-tokenize', env);
  223. env.tokens = _.tokenize(env.code, env.grammar);
  224. _.hooks.run('after-tokenize', env);
  225. return Token.stringify(_.util.encode(env.tokens), env.language);
  226. },
  227. matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
  228. for (var token in grammar) {
  229. if(!grammar.hasOwnProperty(token) || !grammar[token]) {
  230. continue;
  231. }
  232. if (token == target) {
  233. return;
  234. }
  235. var patterns = grammar[token];
  236. patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
  237. for (var j = 0; j < patterns.length; ++j) {
  238. var pattern = patterns[j],
  239. inside = pattern.inside,
  240. lookbehind = !!pattern.lookbehind,
  241. greedy = !!pattern.greedy,
  242. lookbehindLength = 0,
  243. alias = pattern.alias;
  244. if (greedy && !pattern.pattern.global) {
  245. // Without the global flag, lastIndex won't work
  246. var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
  247. pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
  248. }
  249. pattern = pattern.pattern || pattern;
  250. // Don’t cache length as it changes during the loop
  251. for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
  252. var str = strarr[i];
  253. if (strarr.length > text.length) {
  254. // Something went terribly wrong, ABORT, ABORT!
  255. return;
  256. }
  257. if (str instanceof Token) {
  258. continue;
  259. }
  260. if (greedy && i != strarr.length - 1) {
  261. pattern.lastIndex = pos;
  262. var match = pattern.exec(text);
  263. if (!match) {
  264. break;
  265. }
  266. var from = match.index + (lookbehind ? match[1].length : 0),
  267. to = match.index + match[0].length,
  268. k = i,
  269. p = pos;
  270. for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
  271. p += strarr[k].length;
  272. // Move the index i to the element in strarr that is closest to from
  273. if (from >= p) {
  274. ++i;
  275. pos = p;
  276. }
  277. }
  278. // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
  279. if (strarr[i] instanceof Token) {
  280. continue;
  281. }
  282. // Number of tokens to delete and replace with the new match
  283. delNum = k - i;
  284. str = text.slice(pos, p);
  285. match.index -= pos;
  286. } else {
  287. pattern.lastIndex = 0;
  288. var match = pattern.exec(str),
  289. delNum = 1;
  290. }
  291. if (!match) {
  292. if (oneshot) {
  293. break;
  294. }
  295. continue;
  296. }
  297. if(lookbehind) {
  298. lookbehindLength = match[1] ? match[1].length : 0;
  299. }
  300. var from = match.index + lookbehindLength,
  301. match = match[0].slice(lookbehindLength),
  302. to = from + match.length,
  303. before = str.slice(0, from),
  304. after = str.slice(to);
  305. var args = [i, delNum];
  306. if (before) {
  307. ++i;
  308. pos += before.length;
  309. args.push(before);
  310. }
  311. var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
  312. args.push(wrapped);
  313. if (after) {
  314. args.push(after);
  315. }
  316. Array.prototype.splice.apply(strarr, args);
  317. if (delNum != 1)
  318. _.matchGrammar(text, strarr, grammar, i, pos, true, token);
  319. if (oneshot)
  320. break;
  321. }
  322. }
  323. }
  324. },
  325. tokenize: function(text, grammar) {
  326. var strarr = [text];
  327. var rest = grammar.rest;
  328. if (rest) {
  329. for (var token in rest) {
  330. grammar[token] = rest[token];
  331. }
  332. delete grammar.rest;
  333. }
  334. _.matchGrammar(text, strarr, grammar, 0, 0, false);
  335. return strarr;
  336. },
  337. hooks: {
  338. all: {},
  339. add: function (name, callback) {
  340. var hooks = _.hooks.all;
  341. hooks[name] = hooks[name] || [];
  342. hooks[name].push(callback);
  343. },
  344. run: function (name, env) {
  345. var callbacks = _.hooks.all[name];
  346. if (!callbacks || !callbacks.length) {
  347. return;
  348. }
  349. for (var i=0, callback; callback = callbacks[i++];) {
  350. callback(env);
  351. }
  352. }
  353. },
  354. Token: Token
  355. };
  356. _self.Prism = _;
  357. function Token(type, content, alias, matchedStr, greedy) {
  358. this.type = type;
  359. this.content = content;
  360. this.alias = alias;
  361. // Copy of the full string this token was created from
  362. this.length = (matchedStr || "").length|0;
  363. this.greedy = !!greedy;
  364. }
  365. Token.stringify = function(o, language) {
  366. if (typeof o == 'string') {
  367. return o;
  368. }
  369. if (Array.isArray(o)) {
  370. return o.map(function(element) {
  371. return Token.stringify(element, language);
  372. }).join('');
  373. }
  374. var env = {
  375. type: o.type,
  376. content: Token.stringify(o.content, language),
  377. tag: 'span',
  378. classes: ['token', o.type],
  379. attributes: {},
  380. language: language
  381. };
  382. if (o.alias) {
  383. var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
  384. Array.prototype.push.apply(env.classes, aliases);
  385. }
  386. _.hooks.run('wrap', env);
  387. var attributes = Object.keys(env.attributes).map(function(name) {
  388. return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
  389. }).join(' ');
  390. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
  391. };
  392. if (!_self.document) {
  393. if (!_self.addEventListener) {
  394. // in Node.js
  395. return _;
  396. }
  397. if (!_.disableWorkerMessageHandler) {
  398. // In worker
  399. _self.addEventListener('message', function (evt) {
  400. var message = JSON.parse(evt.data),
  401. lang = message.language,
  402. code = message.code,
  403. immediateClose = message.immediateClose;
  404. _self.postMessage(_.highlight(code, _.languages[lang], lang));
  405. if (immediateClose) {
  406. _self.close();
  407. }
  408. }, false);
  409. }
  410. return _;
  411. }
  412. //Get current script and highlight
  413. var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
  414. if (script) {
  415. _.filename = script.src;
  416. if (!_.manual && !script.hasAttribute('data-manual')) {
  417. if(document.readyState !== "loading") {
  418. if (window.requestAnimationFrame) {
  419. window.requestAnimationFrame(_.highlightAll);
  420. } else {
  421. window.setTimeout(_.highlightAll, 16);
  422. }
  423. }
  424. else {
  425. document.addEventListener('DOMContentLoaded', _.highlightAll);
  426. }
  427. }
  428. }
  429. return _;
  430. })(_self);
  431. if (typeof module !== 'undefined' && module.exports) {
  432. module.exports = Prism;
  433. }
  434. // hack for components to work correctly in node.js
  435. if (typeof global !== 'undefined') {
  436. global.Prism = Prism;
  437. }
  438. ;
  439. Prism.languages.markup = {
  440. 'comment': /<!--[\s\S]*?-->/,
  441. 'prolog': /<\?[\s\S]+?\?>/,
  442. 'doctype': /<!DOCTYPE[\s\S]+?>/i,
  443. 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
  444. 'tag': {
  445. pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
  446. greedy: true,
  447. inside: {
  448. 'tag': {
  449. pattern: /^<\/?[^\s>\/]+/i,
  450. inside: {
  451. 'punctuation': /^<\/?/,
  452. 'namespace': /^[^\s>\/:]+:/
  453. }
  454. },
  455. 'attr-value': {
  456. pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
  457. inside: {
  458. 'punctuation': [
  459. /^=/,
  460. {
  461. pattern: /^(\s*)["']|["']$/,
  462. lookbehind: true
  463. }
  464. ]
  465. }
  466. },
  467. 'punctuation': /\/?>/,
  468. 'attr-name': {
  469. pattern: /[^\s>\/]+/,
  470. inside: {
  471. 'namespace': /^[^\s>\/:]+:/
  472. }
  473. }
  474. }
  475. },
  476. 'entity': /&#?[\da-z]{1,8};/i
  477. };
  478. Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
  479. Prism.languages.markup['entity'];
  480. // Plugin to make entity title show the real entity, idea by Roman Komarov
  481. Prism.hooks.add('wrap', function(env) {
  482. if (env.type === 'entity') {
  483. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  484. }
  485. });
  486. Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
  487. /**
  488. * Adds an inlined language to markup.
  489. *
  490. * An example of an inlined language is CSS with `<style>` tags.
  491. *
  492. * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
  493. * case insensitive.
  494. * @param {string} lang The language key.
  495. * @example
  496. * addInlined('style', 'css');
  497. */
  498. value: function addInlined(tagName, lang) {
  499. var includedCdataInside = {};
  500. includedCdataInside['language-' + lang] = {
  501. pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
  502. lookbehind: true,
  503. inside: Prism.languages[lang]
  504. };
  505. includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
  506. var inside = {
  507. 'included-cdata': {
  508. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  509. inside: includedCdataInside
  510. }
  511. };
  512. inside['language-' + lang] = {
  513. pattern: /[\s\S]+/,
  514. inside: Prism.languages[lang]
  515. };
  516. var def = {};
  517. def[tagName] = {
  518. pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
  519. lookbehind: true,
  520. greedy: true,
  521. inside: inside
  522. };
  523. Prism.languages.insertBefore('markup', 'cdata', def);
  524. }
  525. });
  526. Prism.languages.xml = Prism.languages.extend('markup', {});
  527. Prism.languages.html = Prism.languages.markup;
  528. Prism.languages.mathml = Prism.languages.markup;
  529. Prism.languages.svg = Prism.languages.markup;
  530. (function (Prism) {
  531. var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
  532. Prism.languages.css = {
  533. 'comment': /\/\*[\s\S]*?\*\//,
  534. 'atrule': {
  535. pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
  536. inside: {
  537. 'rule': /@[\w-]+/
  538. // See rest below
  539. }
  540. },
  541. 'url': {
  542. pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
  543. inside: {
  544. 'function': /^url/i,
  545. 'punctuation': /^\(|\)$/
  546. }
  547. },
  548. 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
  549. 'string': {
  550. pattern: string,
  551. greedy: true
  552. },
  553. 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
  554. 'important': /!important\b/i,
  555. 'function': /[-a-z0-9]+(?=\()/i,
  556. 'punctuation': /[(){};:,]/
  557. };
  558. Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
  559. var markup = Prism.languages.markup;
  560. if (markup) {
  561. markup.tag.addInlined('style', 'css');
  562. Prism.languages.insertBefore('inside', 'attr-value', {
  563. 'style-attr': {
  564. pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
  565. inside: {
  566. 'attr-name': {
  567. pattern: /^\s*style/i,
  568. inside: markup.tag.inside
  569. },
  570. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  571. 'attr-value': {
  572. pattern: /.+/i,
  573. inside: Prism.languages.css
  574. }
  575. },
  576. alias: 'language-css'
  577. }
  578. }, markup.tag);
  579. }
  580. }(Prism));
  581. Prism.languages.clike = {
  582. 'comment': [
  583. {
  584. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  585. lookbehind: true
  586. },
  587. {
  588. pattern: /(^|[^\\:])\/\/.*/,
  589. lookbehind: true,
  590. greedy: true
  591. }
  592. ],
  593. 'string': {
  594. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  595. greedy: true
  596. },
  597. 'class-name': {
  598. pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
  599. lookbehind: true,
  600. inside: {
  601. punctuation: /[.\\]/
  602. }
  603. },
  604. 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  605. 'boolean': /\b(?:true|false)\b/,
  606. 'function': /\w+(?=\()/,
  607. 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
  608. 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
  609. 'punctuation': /[{}[\];(),.:]/
  610. };
  611. Prism.languages.javascript = Prism.languages.extend('clike', {
  612. 'class-name': [
  613. Prism.languages.clike['class-name'],
  614. {
  615. pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
  616. lookbehind: true
  617. }
  618. ],
  619. 'keyword': [
  620. {
  621. pattern: /((?:^|})\s*)(?:catch|finally)\b/,
  622. lookbehind: true
  623. },
  624. {
  625. pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|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|undefined|var|void|while|with|yield)\b/,
  626. lookbehind: true
  627. },
  628. ],
  629. 'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
  630. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  631. 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
  632. 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
  633. });
  634. Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
  635. Prism.languages.insertBefore('javascript', 'keyword', {
  636. 'regex': {
  637. pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
  638. lookbehind: true,
  639. greedy: true
  640. },
  641. // This must be declared before keyword because we use "function" inside the look-forward
  642. 'function-variable': {
  643. pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
  644. alias: 'function'
  645. },
  646. 'parameter': [
  647. {
  648. pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
  649. lookbehind: true,
  650. inside: Prism.languages.javascript
  651. },
  652. {
  653. pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
  654. inside: Prism.languages.javascript
  655. },
  656. {
  657. pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
  658. lookbehind: true,
  659. inside: Prism.languages.javascript
  660. },
  661. {
  662. pattern: /((?:\b|\s|^)(?!(?: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|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
  663. lookbehind: true,
  664. inside: Prism.languages.javascript
  665. }
  666. ],
  667. 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
  668. });
  669. Prism.languages.insertBefore('javascript', 'string', {
  670. 'template-string': {
  671. pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
  672. greedy: true,
  673. inside: {
  674. 'template-punctuation': {
  675. pattern: /^`|`$/,
  676. alias: 'string'
  677. },
  678. 'interpolation': {
  679. pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
  680. lookbehind: true,
  681. inside: {
  682. 'interpolation-punctuation': {
  683. pattern: /^\${|}$/,
  684. alias: 'punctuation'
  685. },
  686. rest: Prism.languages.javascript
  687. }
  688. },
  689. 'string': /[\s\S]+/
  690. }
  691. }
  692. });
  693. if (Prism.languages.markup) {
  694. Prism.languages.markup.tag.addInlined('script', 'javascript');
  695. }
  696. Prism.languages.js = Prism.languages.javascript;
  697. Prism.languages.c = Prism.languages.extend('clike', {
  698. 'class-name': {
  699. pattern: /(\b(?:enum|struct)\s+)\w+/,
  700. lookbehind: true
  701. },
  702. '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/,
  703. 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
  704. 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
  705. });
  706. Prism.languages.insertBefore('c', 'string', {
  707. 'macro': {
  708. // allow for multiline macro definitions
  709. // spaces after the # character compile fine with gcc
  710. pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
  711. lookbehind: true,
  712. alias: 'property',
  713. inside: {
  714. // highlight the path of the include statement as a string
  715. 'string': {
  716. pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
  717. lookbehind: true
  718. },
  719. // highlight macro directives as keywords
  720. 'directive': {
  721. pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
  722. lookbehind: true,
  723. alias: 'keyword'
  724. }
  725. }
  726. },
  727. // highlight predefined macros as constants
  728. 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
  729. });
  730. delete Prism.languages.c['boolean'];
  731. (function(Prism) {
  732. // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
  733. // + LC_ALL, RANDOM, REPLY, SECONDS.
  734. // + make sure PS1..4 are here as they are not always set,
  735. // - some useless things.
  736. var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
  737. var insideString = {
  738. 'environment': {
  739. pattern: RegExp("\\$" + envVars),
  740. alias: 'constant'
  741. },
  742. 'variable': [
  743. // [0]: Arithmetic Environment
  744. {
  745. pattern: /\$?\(\([\s\S]+?\)\)/,
  746. greedy: true,
  747. inside: {
  748. // If there is a $ sign at the beginning highlight $(( and )) as variable
  749. 'variable': [
  750. {
  751. pattern: /(^\$\(\([\s\S]+)\)\)/,
  752. lookbehind: true
  753. },
  754. /^\$\(\(/
  755. ],
  756. 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
  757. // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
  758. 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
  759. // If there is no $ sign at the beginning highlight (( and )) as punctuation
  760. 'punctuation': /\(\(?|\)\)?|,|;/
  761. }
  762. },
  763. // [1]: Command Substitution
  764. {
  765. pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
  766. greedy: true,
  767. inside: {
  768. 'variable': /^\$\(|^`|\)$|`$/
  769. }
  770. },
  771. // [2]: Brace expansion
  772. {
  773. pattern: /\$\{[^}]+\}/,
  774. greedy: true,
  775. inside: {
  776. 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
  777. 'punctuation': /[\[\]]/,
  778. 'environment': {
  779. pattern: RegExp("(\\{)" + envVars),
  780. lookbehind: true,
  781. alias: 'constant'
  782. }
  783. }
  784. },
  785. /\$(?:\w+|[#?*!@$])/
  786. ],
  787. // Escape sequences from echo and printf's manuals, and escaped quotes.
  788. 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})/
  789. };
  790. Prism.languages.bash = {
  791. 'shebang': {
  792. pattern: /^#!\s*\/.*/,
  793. alias: 'important'
  794. },
  795. 'comment': {
  796. pattern: /(^|[^"{\\$])#.*/,
  797. lookbehind: true
  798. },
  799. 'function-name': [
  800. // a) function foo {
  801. // b) foo() {
  802. // c) function foo() {
  803. // but not “foo {”
  804. {
  805. // a) and c)
  806. pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
  807. lookbehind: true,
  808. alias: 'function'
  809. },
  810. {
  811. // b)
  812. pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
  813. alias: 'function'
  814. }
  815. ],
  816. // Highlight variable names as variables in for and select beginnings.
  817. 'for-or-select': {
  818. pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
  819. alias: 'variable',
  820. lookbehind: true
  821. },
  822. // Highlight variable names as variables in the left-hand part
  823. // of assignments (“=” and “+=”).
  824. 'assign-left': {
  825. pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
  826. inside: {
  827. 'environment': {
  828. pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
  829. lookbehind: true,
  830. alias: 'constant'
  831. }
  832. },
  833. alias: 'variable',
  834. lookbehind: true
  835. },
  836. 'string': [
  837. // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
  838. {
  839. pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\2/,
  840. lookbehind: true,
  841. greedy: true,
  842. inside: insideString
  843. },
  844. // Here-document with quotes around the tag
  845. // → No expansion (so no “inside”).
  846. {
  847. pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)(?:[\s\S])*?(?:\r?\n|\r)\3/,
  848. lookbehind: true,
  849. greedy: true
  850. },
  851. // “Normal” string
  852. {
  853. pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
  854. greedy: true,
  855. inside: insideString
  856. }
  857. ],
  858. 'environment': {
  859. pattern: RegExp("\\$?" + envVars),
  860. alias: 'constant'
  861. },
  862. 'variable': insideString.variable,
  863. 'function': {
  864. pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|aptitude|apt-cache|apt-get|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
  865. lookbehind: true
  866. },
  867. 'keyword': {
  868. pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
  869. lookbehind: true
  870. },
  871. // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
  872. 'builtin': {
  873. pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|break|cd|continue|eval|exec|exit|export|getopts|hash|pwd|readonly|return|shift|test|times|trap|umask|unset|alias|bind|builtin|caller|command|declare|echo|enable|help|let|local|logout|mapfile|printf|read|readarray|source|type|typeset|ulimit|unalias|set|shopt)(?=$|[)\s;|&])/,
  874. lookbehind: true,
  875. // Alias added to make those easier to distinguish from strings.
  876. alias: 'class-name'
  877. },
  878. 'boolean': {
  879. pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
  880. lookbehind: true
  881. },
  882. 'file-descriptor': {
  883. pattern: /\B&\d\b/,
  884. alias: 'important'
  885. },
  886. 'operator': {
  887. // Lots of redirections here, but not just that.
  888. pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
  889. inside: {
  890. 'file-descriptor': {
  891. pattern: /^\d/,
  892. alias: 'important'
  893. }
  894. }
  895. },
  896. 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
  897. 'number': {
  898. pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
  899. lookbehind: true
  900. }
  901. };
  902. /* Patterns in command substitution. */
  903. var toBeCopied = [
  904. 'comment',
  905. 'function-name',
  906. 'for-or-select',
  907. 'assign-left',
  908. 'string',
  909. 'environment',
  910. 'function',
  911. 'keyword',
  912. 'builtin',
  913. 'boolean',
  914. 'file-descriptor',
  915. 'operator',
  916. 'punctuation',
  917. 'number'
  918. ];
  919. var inside = insideString.variable[1].inside;
  920. for(var i = 0; i < toBeCopied.length; i++) {
  921. inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
  922. }
  923. Prism.languages.shell = Prism.languages.bash;
  924. })(Prism);
  925. Prism.languages.cpp = Prism.languages.extend('c', {
  926. 'class-name': {
  927. pattern: /(\b(?:class|enum|struct)\s+)\w+/,
  928. lookbehind: true
  929. },
  930. 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,
  931. 'number': {
  932. pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
  933. greedy: true
  934. },
  935. 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
  936. 'boolean': /\b(?:true|false)\b/
  937. });
  938. Prism.languages.insertBefore('cpp', 'string', {
  939. 'raw-string': {
  940. pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
  941. alias: 'string',
  942. greedy: true
  943. }
  944. });
  945. (function(Prism) {
  946. // Ignore comments starting with { to privilege string interpolation highlighting
  947. var comment = /#(?!\{).+/,
  948. interpolation = {
  949. pattern: /#\{[^}]+\}/,
  950. alias: 'variable'
  951. };
  952. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  953. 'comment': comment,
  954. 'string': [
  955. // Strings are multiline
  956. {
  957. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  958. greedy: true
  959. },
  960. {
  961. // Strings are multiline
  962. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  963. greedy: true,
  964. inside: {
  965. 'interpolation': interpolation
  966. }
  967. }
  968. ],
  969. '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/,
  970. 'class-member': {
  971. pattern: /@(?!\d)\w+/,
  972. alias: 'variable'
  973. }
  974. });
  975. Prism.languages.insertBefore('coffeescript', 'comment', {
  976. 'multiline-comment': {
  977. pattern: /###[\s\S]+?###/,
  978. alias: 'comment'
  979. },
  980. // Block regexp can contain comments and interpolation
  981. 'block-regex': {
  982. pattern: /\/{3}[\s\S]*?\/{3}/,
  983. alias: 'regex',
  984. inside: {
  985. 'comment': comment,
  986. 'interpolation': interpolation
  987. }
  988. }
  989. });
  990. Prism.languages.insertBefore('coffeescript', 'string', {
  991. 'inline-javascript': {
  992. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  993. inside: {
  994. 'delimiter': {
  995. pattern: /^`|`$/,
  996. alias: 'punctuation'
  997. },
  998. rest: Prism.languages.javascript
  999. }
  1000. },
  1001. // Block strings
  1002. 'multiline-string': [
  1003. {
  1004. pattern: /'''[\s\S]*?'''/,
  1005. greedy: true,
  1006. alias: 'string'
  1007. },
  1008. {
  1009. pattern: /"""[\s\S]*?"""/,
  1010. greedy: true,
  1011. alias: 'string',
  1012. inside: {
  1013. interpolation: interpolation
  1014. }
  1015. }
  1016. ]
  1017. });
  1018. Prism.languages.insertBefore('coffeescript', 'keyword', {
  1019. // Object property
  1020. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  1021. });
  1022. delete Prism.languages.coffeescript['template-string'];
  1023. Prism.languages.coffee = Prism.languages.coffeescript;
  1024. }(Prism));
  1025. /**
  1026. * Original by Samuel Flores
  1027. *
  1028. * Adds the following new token classes:
  1029. * constant, builtin, variable, symbol, regex
  1030. */
  1031. (function(Prism) {
  1032. Prism.languages.ruby = Prism.languages.extend('clike', {
  1033. 'comment': [
  1034. /#.*/,
  1035. {
  1036. pattern: /^=begin\s[\s\S]*?^=end/m,
  1037. greedy: true
  1038. }
  1039. ],
  1040. 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/
  1041. });
  1042. var interpolation = {
  1043. pattern: /#\{[^}]+\}/,
  1044. inside: {
  1045. 'delimiter': {
  1046. pattern: /^#\{|\}$/,
  1047. alias: 'tag'
  1048. },
  1049. rest: Prism.languages.ruby
  1050. }
  1051. };
  1052. delete Prism.languages.ruby.function;
  1053. Prism.languages.insertBefore('ruby', 'keyword', {
  1054. 'regex': [
  1055. {
  1056. pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/,
  1057. greedy: true,
  1058. inside: {
  1059. 'interpolation': interpolation
  1060. }
  1061. },
  1062. {
  1063. pattern: /%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,
  1064. greedy: true,
  1065. inside: {
  1066. 'interpolation': interpolation
  1067. }
  1068. },
  1069. {
  1070. // Here we need to specifically allow interpolation
  1071. pattern: /%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,
  1072. greedy: true,
  1073. inside: {
  1074. 'interpolation': interpolation
  1075. }
  1076. },
  1077. {
  1078. pattern: /%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,
  1079. greedy: true,
  1080. inside: {
  1081. 'interpolation': interpolation
  1082. }
  1083. },
  1084. {
  1085. pattern: /%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,
  1086. greedy: true,
  1087. inside: {
  1088. 'interpolation': interpolation
  1089. }
  1090. },
  1091. {
  1092. pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,
  1093. lookbehind: true,
  1094. greedy: true
  1095. }
  1096. ],
  1097. 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
  1098. 'symbol': {
  1099. pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
  1100. lookbehind: true
  1101. },
  1102. 'method-definition': {
  1103. pattern: /(\bdef\s+)[\w.]+/,
  1104. lookbehind: true,
  1105. inside: {
  1106. 'function': /\w+$/,
  1107. rest: Prism.languages.ruby
  1108. }
  1109. }
  1110. });
  1111. Prism.languages.insertBefore('ruby', 'number', {
  1112. '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/,
  1113. 'constant': /\b[A-Z]\w*(?:[?!]|\b)/
  1114. });
  1115. Prism.languages.ruby.string = [
  1116. {
  1117. pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  1118. greedy: true,
  1119. inside: {
  1120. 'interpolation': interpolation
  1121. }
  1122. },
  1123. {
  1124. pattern: /%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,
  1125. greedy: true,
  1126. inside: {
  1127. 'interpolation': interpolation
  1128. }
  1129. },
  1130. {
  1131. // Here we need to specifically allow interpolation
  1132. pattern: /%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,
  1133. greedy: true,
  1134. inside: {
  1135. 'interpolation': interpolation
  1136. }
  1137. },
  1138. {
  1139. pattern: /%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,
  1140. greedy: true,
  1141. inside: {
  1142. 'interpolation': interpolation
  1143. }
  1144. },
  1145. {
  1146. pattern: /%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,
  1147. greedy: true,
  1148. inside: {
  1149. 'interpolation': interpolation
  1150. }
  1151. },
  1152. {
  1153. pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  1154. greedy: true,
  1155. inside: {
  1156. 'interpolation': interpolation
  1157. }
  1158. }
  1159. ];
  1160. Prism.languages.rb = Prism.languages.ruby;
  1161. }(Prism));
  1162. Prism.languages.d = Prism.languages.extend('clike', {
  1163. 'string': [
  1164. // r"", x""
  1165. /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/,
  1166. // q"[]", q"()", q"<>", q"{}"
  1167. /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/,
  1168. // q"IDENT
  1169. // ...
  1170. // IDENT"
  1171. /\bq"([_a-zA-Z][_a-zA-Z\d]*)(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\1"/,
  1172. // q"//", q"||", etc.
  1173. /\bq"(.)[\s\S]*?\1"/,
  1174. // Characters
  1175. /'(?:\\'|\\?[^']+)'/,
  1176. /(["`])(?:\\[\s\S]|(?!\1)[^\\])*\1[cwd]?/
  1177. ],
  1178. 'number': [
  1179. // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
  1180. // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
  1181. /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i,
  1182. {
  1183. pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i,
  1184. lookbehind: true
  1185. }
  1186. ],
  1187. // In order: $, keywords and special tokens, globally defined symbols
  1188. '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/,
  1189. 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
  1190. });
  1191. Prism.languages.d.comment = [
  1192. // Shebang
  1193. /^\s*#!.+/,
  1194. // /+ +/
  1195. {
  1196. // Allow one level of nesting
  1197. pattern: /(^|[^\\])\/\+(?:\/\+[\s\S]*?\+\/|[\s\S])*?\+\//,
  1198. lookbehind: true
  1199. }
  1200. ].concat(Prism.languages.d.comment);
  1201. Prism.languages.insertBefore('d', 'comment', {
  1202. 'token-string': {
  1203. // Allow one level of nesting
  1204. pattern: /\bq\{(?:\{[^}]*\}|[^}])*\}/,
  1205. alias: 'string'
  1206. }
  1207. });
  1208. Prism.languages.insertBefore('d', 'keyword', {
  1209. 'property': /\B@\w*/
  1210. });
  1211. Prism.languages.insertBefore('d', 'function', {
  1212. 'register': {
  1213. // Iasm registers
  1214. 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)/,
  1215. alias: 'variable'
  1216. }
  1217. });
  1218. Prism.languages.dart = Prism.languages.extend('clike', {
  1219. 'string': [
  1220. {
  1221. pattern: /r?("""|''')[\s\S]*?\1/,
  1222. greedy: true
  1223. },
  1224. {
  1225. pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1226. greedy: true
  1227. }
  1228. ],
  1229. 'keyword': [
  1230. /\b(?:async|sync|yield)\*/,
  1231. /\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/
  1232. ],
  1233. 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
  1234. });
  1235. Prism.languages.insertBefore('dart','function',{
  1236. 'metadata': {
  1237. pattern: /@\w+/,
  1238. alias: 'symbol'
  1239. }
  1240. });
  1241. (function (Prism) {
  1242. /**
  1243. * Returns the placeholder for the given language id and index.
  1244. *
  1245. * @param {string} language
  1246. * @param {string|number} index
  1247. * @returns {string}
  1248. */
  1249. function getPlaceholder(language, index) {
  1250. return '___' + language.toUpperCase() + index + '___';
  1251. }
  1252. Object.defineProperties(Prism.languages['markup-templating'] = {}, {
  1253. buildPlaceholders: {
  1254. /**
  1255. * Tokenize all inline templating expressions matching `placeholderPattern`.
  1256. *
  1257. * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
  1258. * `true` will be replaced.
  1259. *
  1260. * @param {object} env The environment of the `before-tokenize` hook.
  1261. * @param {string} language The language id.
  1262. * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
  1263. * @param {(match: string) => boolean} [replaceFilter]
  1264. */
  1265. value: function (env, language, placeholderPattern, replaceFilter) {
  1266. if (env.language !== language) {
  1267. return;
  1268. }
  1269. var tokenStack = env.tokenStack = [];
  1270. env.code = env.code.replace(placeholderPattern, function (match) {
  1271. if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
  1272. return match;
  1273. }
  1274. var i = tokenStack.length;
  1275. var placeholder;
  1276. // Check for existing strings
  1277. while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
  1278. ++i;
  1279. // Create a sparse array
  1280. tokenStack[i] = match;
  1281. return placeholder;
  1282. });
  1283. // Switch the grammar to markup
  1284. env.grammar = Prism.languages.markup;
  1285. }
  1286. },
  1287. tokenizePlaceholders: {
  1288. /**
  1289. * Replace placeholders with proper tokens after tokenizing.
  1290. *
  1291. * @param {object} env The environment of the `after-tokenize` hook.
  1292. * @param {string} language The language id.
  1293. */
  1294. value: function (env, language) {
  1295. if (env.language !== language || !env.tokenStack) {
  1296. return;
  1297. }
  1298. // Switch the grammar back
  1299. env.grammar = Prism.languages[language];
  1300. var j = 0;
  1301. var keys = Object.keys(env.tokenStack);
  1302. function walkTokens(tokens) {
  1303. for (var i = 0; i < tokens.length; i++) {
  1304. // all placeholders are replaced already
  1305. if (j >= keys.length) {
  1306. break;
  1307. }
  1308. var token = tokens[i];
  1309. if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
  1310. var k = keys[j];
  1311. var t = env.tokenStack[k];
  1312. var s = typeof token === 'string' ? token : token.content;
  1313. var placeholder = getPlaceholder(language, k);
  1314. var index = s.indexOf(placeholder);
  1315. if (index > -1) {
  1316. ++j;
  1317. var before = s.substring(0, index);
  1318. var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
  1319. var after = s.substring(index + placeholder.length);
  1320. var replacement = [];
  1321. if (before) {
  1322. replacement.push.apply(replacement, walkTokens([before]));
  1323. }
  1324. replacement.push(middle);
  1325. if (after) {
  1326. replacement.push.apply(replacement, walkTokens([after]));
  1327. }
  1328. if (typeof token === 'string') {
  1329. tokens.splice.apply(tokens, [i, 1].concat(replacement));
  1330. } else {
  1331. token.content = replacement;
  1332. }
  1333. }
  1334. } else if (token.content /* && typeof token.content !== 'string' */) {
  1335. walkTokens(token.content);
  1336. }
  1337. }
  1338. return tokens;
  1339. }
  1340. walkTokens(env.tokens);
  1341. }
  1342. }
  1343. });
  1344. }(Prism));
  1345. Prism.languages.elixir = {
  1346. 'comment': /#.*/m,
  1347. // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
  1348. 'regex': {
  1349. pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
  1350. greedy: true
  1351. },
  1352. 'string': [
  1353. {
  1354. // ~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>
  1355. pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
  1356. greedy: true,
  1357. inside: {
  1358. // See interpolation below
  1359. }
  1360. },
  1361. {
  1362. pattern: /("""|''')[\s\S]*?\1/,
  1363. greedy: true,
  1364. inside: {
  1365. // See interpolation below
  1366. }
  1367. },
  1368. {
  1369. // Multi-line strings are allowed
  1370. pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  1371. greedy: true,
  1372. inside: {
  1373. // See interpolation below
  1374. }
  1375. }
  1376. ],
  1377. 'atom': {
  1378. // Look-behind prevents bad highlighting of the :: operator
  1379. pattern: /(^|[^:]):\w+/,
  1380. lookbehind: true,
  1381. alias: 'symbol'
  1382. },
  1383. // Look-ahead prevents bad highlighting of the :: operator
  1384. 'attr-name': /\w+:(?!:)/,
  1385. 'capture': {
  1386. // Look-behind prevents bad highlighting of the && operator
  1387. pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
  1388. lookbehind: true,
  1389. alias: 'function'
  1390. },
  1391. 'argument': {
  1392. // Look-behind prevents bad highlighting of the && operator
  1393. pattern: /(^|[^&])&\d+/,
  1394. lookbehind: true,
  1395. alias: 'variable'
  1396. },
  1397. 'attribute': {
  1398. pattern: /@\w+/,
  1399. alias: 'variable'
  1400. },
  1401. 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
  1402. '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/,
  1403. 'boolean': /\b(?:true|false|nil)\b/,
  1404. 'operator': [
  1405. /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
  1406. {
  1407. // We don't want to match <<
  1408. pattern: /([^<])<(?!<)/,
  1409. lookbehind: true
  1410. },
  1411. {
  1412. // We don't want to match >>
  1413. pattern: /([^>])>(?!>)/,
  1414. lookbehind: true
  1415. }
  1416. ],
  1417. 'punctuation': /<<|>>|[.,%\[\]{}()]/
  1418. };
  1419. Prism.languages.elixir.string.forEach(function(o) {
  1420. o.inside = {
  1421. 'interpolation': {
  1422. pattern: /#\{[^}]+\}/,
  1423. inside: {
  1424. 'delimiter': {
  1425. pattern: /^#\{|\}$/,
  1426. alias: 'punctuation'
  1427. },
  1428. rest: Prism.languages.elixir
  1429. }
  1430. }
  1431. };
  1432. });
  1433. Prism.languages.erlang = {
  1434. 'comment': /%.+/,
  1435. 'string': {
  1436. pattern: /"(?:\\.|[^\\"\r\n])*"/,
  1437. greedy: true
  1438. },
  1439. 'quoted-function': {
  1440. pattern: /'(?:\\.|[^\\'\r\n])+'(?=\()/,
  1441. alias: 'function'
  1442. },
  1443. 'quoted-atom': {
  1444. pattern: /'(?:\\.|[^\\'\r\n])+'/,
  1445. alias: 'atom'
  1446. },
  1447. 'boolean': /\b(?:true|false)\b/,
  1448. 'keyword': /\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,
  1449. 'number': [
  1450. /\$\\?./,
  1451. /\d+#[a-z0-9]+/i,
  1452. /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
  1453. ],
  1454. 'function': /\b[a-z][\w@]*(?=\()/,
  1455. 'variable': {
  1456. // Look-behind is used to prevent wrong highlighting of atoms containing "@"
  1457. pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
  1458. lookbehind: true
  1459. },
  1460. 'operator': [
  1461. /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
  1462. {
  1463. // We don't want to match <<
  1464. pattern: /(^|[^<])<(?!<)/,
  1465. lookbehind: true
  1466. },
  1467. {
  1468. // We don't want to match >>
  1469. pattern: /(^|[^>])>(?!>)/,
  1470. lookbehind: true
  1471. }
  1472. ],
  1473. 'atom': /\b[a-z][\w@]*/,
  1474. 'punctuation': /[()[\]{}:;,.#|]|<<|>>/
  1475. };
  1476. Prism.languages.go = Prism.languages.extend('clike', {
  1477. '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/,
  1478. 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
  1479. 'boolean': /\b(?:_|iota|nil|true|false)\b/,
  1480. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  1481. 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
  1482. 'string': {
  1483. pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
  1484. greedy: true
  1485. }
  1486. });
  1487. delete Prism.languages.go['class-name'];
  1488. Prism.languages.groovy = Prism.languages.extend('clike', {
  1489. 'keyword': /\b(?:as|def|in|abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|native|new|package|private|protected|public|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|trait|transient|try|void|volatile|while)\b/,
  1490. 'string': [
  1491. {
  1492. pattern: /("""|''')[\s\S]*?\1|(?:\$\/)(?:\$\/\$|[\s\S])*?\/\$/,
  1493. greedy: true
  1494. },
  1495. {
  1496. pattern: /(["'\/])(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1497. greedy: true
  1498. }
  1499. ],
  1500. 'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
  1501. 'operator': {
  1502. pattern: /(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.{1,2}(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
  1503. lookbehind: true
  1504. },
  1505. 'punctuation': /\.+|[{}[\];(),:$]/
  1506. });
  1507. Prism.languages.insertBefore('groovy', 'string', {
  1508. 'shebang': {
  1509. pattern: /#!.+/,
  1510. alias: 'comment'
  1511. }
  1512. });
  1513. Prism.languages.insertBefore('groovy', 'punctuation', {
  1514. 'spock-block': /\b(?:setup|given|when|then|and|cleanup|expect|where):/
  1515. });
  1516. Prism.languages.insertBefore('groovy', 'function', {
  1517. 'annotation': {
  1518. alias: 'punctuation',
  1519. pattern: /(^|[^.])@\w+/,
  1520. lookbehind: true
  1521. }
  1522. });
  1523. // Handle string interpolation
  1524. Prism.hooks.add('wrap', function(env) {
  1525. if (env.language === 'groovy' && env.type === 'string') {
  1526. var delimiter = env.content[0];
  1527. if (delimiter != "'") {
  1528. var pattern = /([^\\])(?:\$(?:\{.*?\}|[\w.]+))/;
  1529. if (delimiter === '$') {
  1530. pattern = /([^\$])(?:\$(?:\{.*?\}|[\w.]+))/;
  1531. }
  1532. // To prevent double HTML-encoding we have to decode env.content first
  1533. env.content = env.content.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
  1534. env.content = Prism.highlight(env.content, {
  1535. 'expression': {
  1536. pattern: pattern,
  1537. lookbehind: true,
  1538. inside: Prism.languages.groovy
  1539. }
  1540. });
  1541. env.classes.push(delimiter === '/' ? 'regex' : 'gstring');
  1542. }
  1543. }
  1544. });
  1545. (function (Prism) {
  1546. var keywords = /\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|var|null|exports|module|open|opens|provides|requires|to|transitive|uses|with)\b/;
  1547. // based on the java naming conventions
  1548. var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
  1549. Prism.languages.java = Prism.languages.extend('clike', {
  1550. 'class-name': [
  1551. className,
  1552. // variables and parameters
  1553. // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
  1554. /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
  1555. ],
  1556. 'keyword': keywords,
  1557. 'function': [
  1558. Prism.languages.clike.function,
  1559. {
  1560. pattern: /(\:\:)[a-z_]\w*/,
  1561. lookbehind: true
  1562. }
  1563. ],
  1564. 'number': /\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
  1565. 'operator': {
  1566. pattern: /(^|[^.])(?:<<=?|>>>?=?|->|([-+&|])\2|[?:~]|[-+*/%&|^!=<>]=?)/m,
  1567. lookbehind: true
  1568. }
  1569. });
  1570. Prism.languages.insertBefore('java', 'class-name', {
  1571. 'annotation': {
  1572. alias: 'punctuation',
  1573. pattern: /(^|[^.])@\w+/,
  1574. lookbehind: true
  1575. },
  1576. 'namespace': {
  1577. pattern: /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)[a-z]\w*(\.[a-z]\w*)+/,
  1578. lookbehind: true,
  1579. inside: {
  1580. 'punctuation': /\./,
  1581. }
  1582. },
  1583. 'generics': {
  1584. pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
  1585. inside: {
  1586. 'class-name': className,
  1587. 'keyword': keywords,
  1588. 'punctuation': /[<>(),.:]/,
  1589. 'operator': /[?&|]/
  1590. }
  1591. }
  1592. });
  1593. }(Prism));
  1594. /**
  1595. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  1596. * Modified by Miles Johnson: http://milesj.me
  1597. *
  1598. * Supports the following:
  1599. * - Extends clike syntax
  1600. * - Support for PHP 5.3+ (namespaces, traits, generators, etc)
  1601. * - Smarter constant and function matching
  1602. *
  1603. * Adds the following new token classes:
  1604. * constant, delimiter, variable, function, package
  1605. */
  1606. (function (Prism) {
  1607. Prism.languages.php = Prism.languages.extend('clike', {
  1608. 'keyword': /\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|parent|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i,
  1609. 'boolean': {
  1610. pattern: /\b(?:false|true)\b/i,
  1611. alias: 'constant'
  1612. },
  1613. 'constant': [
  1614. /\b[A-Z_][A-Z0-9_]*\b/,
  1615. /\b(?:null)\b/i,
  1616. ],
  1617. 'comment': {
  1618. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  1619. lookbehind: true
  1620. }
  1621. });
  1622. Prism.languages.insertBefore('php', 'string', {
  1623. 'shell-comment': {
  1624. pattern: /(^|[^\\])#.*/,
  1625. lookbehind: true,
  1626. alias: 'comment'
  1627. }
  1628. });
  1629. Prism.languages.insertBefore('php', 'comment', {
  1630. 'delimiter': {
  1631. pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
  1632. alias: 'important'
  1633. }
  1634. });
  1635. Prism.languages.insertBefore('php', 'keyword', {
  1636. 'variable': /\$+(?:\w+\b|(?={))/i,
  1637. 'package': {
  1638. pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
  1639. lookbehind: true,
  1640. inside: {
  1641. punctuation: /\\/
  1642. }
  1643. }
  1644. });
  1645. // Must be defined after the function pattern
  1646. Prism.languages.insertBefore('php', 'operator', {
  1647. 'property': {
  1648. pattern: /(->)[\w]+/,
  1649. lookbehind: true
  1650. }
  1651. });
  1652. var string_interpolation = {
  1653. pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[.+?]|->\w+)*)/,
  1654. lookbehind: true,
  1655. inside: {
  1656. rest: Prism.languages.php
  1657. }
  1658. };
  1659. Prism.languages.insertBefore('php', 'string', {
  1660. 'nowdoc-string': {
  1661. pattern: /<<<'([^']+)'(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;/,
  1662. greedy: true,
  1663. alias: 'string',
  1664. inside: {
  1665. 'delimiter': {
  1666. pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
  1667. alias: 'symbol',
  1668. inside: {
  1669. 'punctuation': /^<<<'?|[';]$/
  1670. }
  1671. }
  1672. }
  1673. },
  1674. 'heredoc-string': {
  1675. pattern: /<<<(?:"([^"]+)"(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\1;|([a-z_]\w*)(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?\2;)/i,
  1676. greedy: true,
  1677. alias: 'string',
  1678. inside: {
  1679. 'delimiter': {
  1680. pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
  1681. alias: 'symbol',
  1682. inside: {
  1683. 'punctuation': /^<<<"?|[";]$/
  1684. }
  1685. },
  1686. 'interpolation': string_interpolation // See below
  1687. }
  1688. },
  1689. 'single-quoted-string': {
  1690. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  1691. greedy: true,
  1692. alias: 'string'
  1693. },
  1694. 'double-quoted-string': {
  1695. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  1696. greedy: true,
  1697. alias: 'string',
  1698. inside: {
  1699. 'interpolation': string_interpolation // See below
  1700. }
  1701. }
  1702. });
  1703. // The different types of PHP strings "replace" the C-like standard string
  1704. delete Prism.languages.php['string'];
  1705. Prism.hooks.add('before-tokenize', function(env) {
  1706. if (!/<\?/.test(env.code)) {
  1707. return;
  1708. }
  1709. var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
  1710. Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
  1711. });
  1712. Prism.hooks.add('after-tokenize', function(env) {
  1713. Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
  1714. });
  1715. }(Prism));
  1716. Prism.languages.json = {
  1717. 'property': {
  1718. pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
  1719. greedy: true
  1720. },
  1721. 'string': {
  1722. pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
  1723. greedy: true
  1724. },
  1725. 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
  1726. 'number': /-?\d+\.?\d*(e[+-]?\d+)?/i,
  1727. 'punctuation': /[{}[\],]/,
  1728. 'operator': /:/,
  1729. 'boolean': /\b(?:true|false)\b/,
  1730. 'null': {
  1731. pattern: /\bnull\b/,
  1732. alias: 'keyword'
  1733. }
  1734. };
  1735. Prism.languages.julia= {
  1736. 'comment': {
  1737. pattern: /(^|[^\\])#.*/,
  1738. lookbehind: true
  1739. },
  1740. 'string': /("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2/,
  1741. 'keyword' : /\b(?:abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|in|let|local|macro|module|print|println|quote|return|struct|try|type|typealias|using|while)\b/,
  1742. 'boolean' : /\b(?:true|false)\b/,
  1743. 'number' : /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?/i,
  1744. 'operator': /[-+*^%÷&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
  1745. 'punctuation' : /[{}[\];(),.:]/,
  1746. 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?)\b/
  1747. };
  1748. (function (Prism) {
  1749. Prism.languages.kotlin = Prism.languages.extend('clike', {
  1750. 'keyword': {
  1751. // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
  1752. pattern: /(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,
  1753. lookbehind: true
  1754. },
  1755. 'function': [
  1756. /\w+(?=\s*\()/,
  1757. {
  1758. pattern: /(\.)\w+(?=\s*\{)/,
  1759. lookbehind: true
  1760. }
  1761. ],
  1762. 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
  1763. 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
  1764. });
  1765. delete Prism.languages.kotlin["class-name"];
  1766. Prism.languages.insertBefore('kotlin', 'string', {
  1767. 'raw-string': {
  1768. pattern: /("""|''')[\s\S]*?\1/,
  1769. alias: 'string'
  1770. // See interpolation below
  1771. }
  1772. });
  1773. Prism.languages.insertBefore('kotlin', 'keyword', {
  1774. 'annotation': {
  1775. pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
  1776. alias: 'builtin'
  1777. }
  1778. });
  1779. Prism.languages.insertBefore('kotlin', 'function', {
  1780. 'label': {
  1781. pattern: /\w+@|@\w+/,
  1782. alias: 'symbol'
  1783. }
  1784. });
  1785. var interpolation = [
  1786. {
  1787. pattern: /\$\{[^}]+\}/,
  1788. inside: {
  1789. delimiter: {
  1790. pattern: /^\$\{|\}$/,
  1791. alias: 'variable'
  1792. },
  1793. rest: Prism.languages.kotlin
  1794. }
  1795. },
  1796. {
  1797. pattern: /\$\w+/,
  1798. alias: 'variable'
  1799. }
  1800. ];
  1801. Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
  1802. interpolation: interpolation
  1803. };
  1804. }(Prism));
  1805. (function(Prism) {
  1806. Prism.languages.crystal = Prism.languages.extend('ruby', {
  1807. keyword: [
  1808. /\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/,
  1809. {
  1810. pattern: /(\.\s*)(?:is_a|responds_to)\?/,
  1811. lookbehind: true
  1812. }
  1813. ],
  1814. number: /\b(?:0b[01_]*[01]|0o[0-7_]*[0-7]|0x[\da-fA-F_]*[\da-fA-F]|(?:\d(?:[\d_]*\d)?)(?:\.[\d_]*\d)?(?:[eE][+-]?[\d_]*\d)?)(?:_(?:[uif](?:8|16|32|64))?)?\b/
  1815. });
  1816. Prism.languages.insertBefore('crystal', 'string', {
  1817. attribute: {
  1818. pattern: /@\[.+?\]/,
  1819. alias: 'attr-name',
  1820. inside: {
  1821. delimiter: {
  1822. pattern: /^@\[|\]$/,
  1823. alias: 'tag'
  1824. },
  1825. rest: Prism.languages.crystal
  1826. }
  1827. },
  1828. expansion: [
  1829. {
  1830. pattern: /\{\{.+?\}\}/,
  1831. inside: {
  1832. delimiter: {
  1833. pattern: /^\{\{|\}\}$/,
  1834. alias: 'tag'
  1835. },
  1836. rest: Prism.languages.crystal
  1837. }
  1838. },
  1839. {
  1840. pattern: /\{%.+?%\}/,
  1841. inside: {
  1842. delimiter: {
  1843. pattern: /^\{%|%\}$/,
  1844. alias: 'tag'
  1845. },
  1846. rest: Prism.languages.crystal
  1847. }
  1848. }
  1849. ]
  1850. });
  1851. }(Prism));
  1852. Prism.languages.lua = {
  1853. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  1854. // \z may be used to skip the following space
  1855. 'string': {
  1856. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  1857. greedy: true
  1858. },
  1859. 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  1860. '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/,
  1861. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  1862. 'operator': [
  1863. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  1864. {
  1865. // Match ".." but don't break "..."
  1866. pattern: /(^|[^.])\.\.(?!\.)/,
  1867. lookbehind: true
  1868. }
  1869. ],
  1870. 'punctuation': /[\[\](){},;]|\.+|:+/
  1871. };
  1872. // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
  1873. // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
  1874. (function (Prism) {
  1875. Prism.languages.django = {
  1876. 'comment': /^{#[\s\S]*?#}$/,
  1877. 'tag': {
  1878. pattern: /(^{%[+-]?\s*)\w+/,
  1879. lookbehind: true,
  1880. alias: 'keyword'
  1881. },
  1882. 'delimiter': {
  1883. pattern: /^{[{%][+-]?|[+-]?[}%]}$/,
  1884. alias: 'punctuation'
  1885. },
  1886. 'string': {
  1887. pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1888. greedy: true
  1889. },
  1890. 'filter': {
  1891. pattern: /(\|)\w+/,
  1892. lookbehind: true,
  1893. alias: 'function'
  1894. },
  1895. 'test': {
  1896. pattern: /(\bis\s+(?:not\s+)?)(?!not\b)\w+/,
  1897. lookbehind: true,
  1898. alias: 'function'
  1899. },
  1900. 'function': /\b[a-z_]\w+(?=\s*\()/i,
  1901. 'keyword': /\b(?:and|as|by|else|for|if|import|in|is|loop|not|or|recursive|with|without)\b/,
  1902. 'operator': /[-+*/%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  1903. 'number': /\b\d+(?:\.\d+)?\b/,
  1904. 'boolean': /[Tt]rue|[Ff]alse|[Nn]one/,
  1905. 'variable': /\b\w+?\b/,
  1906. 'punctuation': /[{}[\](),.:;]/
  1907. };
  1908. var pattern = /{{[\s\S]*?}}|{%[\s\S]*?%}|{#[\s\S]*?#}/g;
  1909. var markupTemplating = Prism.languages['markup-templating'];
  1910. Prism.hooks.add('before-tokenize', function (env) {
  1911. markupTemplating.buildPlaceholders(env, 'django', pattern);
  1912. });
  1913. Prism.hooks.add('after-tokenize', function (env) {
  1914. markupTemplating.tokenizePlaceholders(env, 'django');
  1915. });
  1916. // Add an Jinja2 alias
  1917. Prism.languages.jinja2 = Prism.languages.django;
  1918. Prism.hooks.add('before-tokenize', function (env) {
  1919. markupTemplating.buildPlaceholders(env, 'jinja2', pattern);
  1920. });
  1921. Prism.hooks.add('after-tokenize', function (env) {
  1922. markupTemplating.tokenizePlaceholders(env, 'jinja2');
  1923. });
  1924. })(Prism);
  1925. Prism.languages.matlab = {
  1926. 'comment': [
  1927. /%\{[\s\S]*?\}%/,
  1928. /%.+/
  1929. ],
  1930. 'string': {
  1931. pattern: /\B'(?:''|[^'\r\n])*'/,
  1932. greedy: true
  1933. },
  1934. // FIXME We could handle imaginary numbers as a whole
  1935. 'number': /(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b/,
  1936. 'keyword': /\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
  1937. 'function': /(?!\d)\w+(?=\s*\()/,
  1938. 'operator': /\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,
  1939. 'punctuation': /\.{3}|[.,;\[\](){}!]/
  1940. };
  1941. Prism.languages.typescript = Prism.languages.extend('javascript', {
  1942. // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
  1943. 'keyword': /\b(?:abstract|as|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|var|void|while|with|yield)\b/,
  1944. 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
  1945. });
  1946. Prism.languages.ts = Prism.languages.typescript;
  1947. Prism.languages.nginx = Prism.languages.extend('clike', {
  1948. 'comment': {
  1949. pattern: /(^|[^"{\\])#.*/,
  1950. lookbehind: true
  1951. },
  1952. '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|ssl_session_tickets|ssl_stapling|ssl_stapling_verify|ssl_ecdh_curve|ssl_trusted_certificate|more_set_headers|ssl_early_data)\b/i
  1953. });
  1954. Prism.languages.insertBefore('nginx', 'keyword', {
  1955. 'variable': /\$[a-z_]+/i
  1956. });
  1957. Prism.languages.nim = {
  1958. 'comment': /#.*/,
  1959. // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
  1960. // Character literals are handled specifically to prevent issues with numeric type suffixes
  1961. 'string': {
  1962. pattern: /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,
  1963. greedy: true
  1964. },
  1965. // The negative look ahead prevents wrong highlighting of the .. operator
  1966. 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
  1967. '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/,
  1968. 'function': {
  1969. pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
  1970. inside: {
  1971. 'operator': /\*$/
  1972. }
  1973. },
  1974. // We don't want to highlight operators inside backticks
  1975. 'ignore': {
  1976. pattern: /`[^`\r\n]+`/,
  1977. inside: {
  1978. 'punctuation': /`/
  1979. }
  1980. },
  1981. 'operator': {
  1982. // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
  1983. // but allow the slice operator .. to take precedence over them
  1984. // One can define his own operators in Nim so all combination of operators might be an operator.
  1985. pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr|xor)\b)/m,
  1986. lookbehind: true
  1987. },
  1988. 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
  1989. };
  1990. Prism.languages.perl = {
  1991. 'comment': [
  1992. {
  1993. // POD
  1994. pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
  1995. lookbehind: true
  1996. },
  1997. {
  1998. pattern: /(^|[^\\$])#.*/,
  1999. lookbehind: true
  2000. }
  2001. ],
  2002. // TODO Could be nice to handle Heredoc too.
  2003. 'string': [
  2004. // q/.../
  2005. {
  2006. pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2007. greedy: true
  2008. },
  2009. // q a...a
  2010. {
  2011. pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2012. greedy: true
  2013. },
  2014. // q(...)
  2015. {
  2016. pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
  2017. greedy: true
  2018. },
  2019. // q{...}
  2020. {
  2021. pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
  2022. greedy: true
  2023. },
  2024. // q[...]
  2025. {
  2026. pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
  2027. greedy: true
  2028. },
  2029. // q<...>
  2030. {
  2031. pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
  2032. greedy: true
  2033. },
  2034. // "...", `...`
  2035. {
  2036. pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2037. greedy: true
  2038. },
  2039. // '...'
  2040. // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  2041. {
  2042. pattern: /'(?:[^'\\\r\n]|\\.)*'/,
  2043. greedy: true
  2044. }
  2045. ],
  2046. 'regex': [
  2047. // m/.../
  2048. {
  2049. pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  2050. greedy: true
  2051. },
  2052. // m a...a
  2053. {
  2054. pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  2055. greedy: true
  2056. },
  2057. // m(...)
  2058. {
  2059. pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
  2060. greedy: true
  2061. },
  2062. // m{...}
  2063. {
  2064. pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
  2065. greedy: true
  2066. },
  2067. // m[...]
  2068. {
  2069. pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
  2070. greedy: true
  2071. },
  2072. // m<...>
  2073. {
  2074. pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  2075. greedy: true
  2076. },
  2077. // The lookbehinds prevent -s from breaking
  2078. // FIXME We don't handle change of separator like s(...)[...]
  2079. // s/.../.../
  2080. {
  2081. pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  2082. lookbehind: true,
  2083. greedy: true
  2084. },
  2085. // s a...a...a
  2086. {
  2087. pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  2088. lookbehind: true,
  2089. greedy: true
  2090. },
  2091. // s(...)(...)
  2092. {
  2093. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  2094. lookbehind: true,
  2095. greedy: true
  2096. },
  2097. // s{...}{...}
  2098. {
  2099. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  2100. lookbehind: true,
  2101. greedy: true
  2102. },
  2103. // s[...][...]
  2104. {
  2105. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  2106. lookbehind: true,
  2107. greedy: true
  2108. },
  2109. // s<...><...>
  2110. {
  2111. pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  2112. lookbehind: true,
  2113. greedy: true
  2114. },
  2115. // /.../
  2116. // The look-ahead tries to prevent two divisions on
  2117. // the same line from being highlighted as regex.
  2118. // This does not support multi-line regex.
  2119. {
  2120. pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
  2121. greedy: true
  2122. }
  2123. ],
  2124. // FIXME Not sure about the handling of ::, ', and #
  2125. 'variable': [
  2126. // ${^POSTMATCH}
  2127. /[&*$@%]\{\^[A-Z]+\}/,
  2128. // $^V
  2129. /[&*$@%]\^[A-Z_]/,
  2130. // ${...}
  2131. /[&*$@%]#?(?=\{)/,
  2132. // $foo
  2133. /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
  2134. // $1
  2135. /[&*$@%]\d+/,
  2136. // $_, @_, %!
  2137. // The negative lookahead prevents from breaking the %= operator
  2138. /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
  2139. ],
  2140. 'filehandle': {
  2141. // <>, <FOO>, _
  2142. pattern: /<(?![<=])\S*>|\b_\b/,
  2143. alias: 'symbol'
  2144. },
  2145. 'vstring': {
  2146. // v1.2, 1.2.3
  2147. pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
  2148. alias: 'string'
  2149. },
  2150. 'function': {
  2151. pattern: /sub [a-z0-9_]+/i,
  2152. inside: {
  2153. keyword: /sub/
  2154. }
  2155. },
  2156. '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|return|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
  2157. 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
  2158. 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
  2159. 'punctuation': /[{}[\];(),:]/
  2160. };
  2161. Prism.languages.sql = {
  2162. 'comment': {
  2163. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
  2164. lookbehind: true
  2165. },
  2166. 'variable': [
  2167. {
  2168. pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
  2169. greedy: true
  2170. },
  2171. /@[\w.$]+/
  2172. ],
  2173. 'string': {
  2174. pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
  2175. greedy: true,
  2176. lookbehind: true
  2177. },
  2178. 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too?
  2179. 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURNS?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
  2180. 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
  2181. 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
  2182. 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  2183. 'punctuation': /[;[\]()`,.]/
  2184. };
  2185. Prism.languages.scss = Prism.languages.extend('css', {
  2186. 'comment': {
  2187. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  2188. lookbehind: true
  2189. },
  2190. 'atrule': {
  2191. pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
  2192. inside: {
  2193. 'rule': /@[\w-]+/
  2194. // See rest below
  2195. }
  2196. },
  2197. // url, compassified
  2198. 'url': /(?:[-a-z]+-)?url(?=\()/i,
  2199. // CSS selector regex is not appropriate for Sass
  2200. // since there can be lot more things (var, @ directive, nesting..)
  2201. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  2202. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  2203. // 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
  2204. // can "pass" as a selector- e.g: proper#{$erty})
  2205. // this one was hard to do, so please be careful if you edit this one :)
  2206. 'selector': {
  2207. // Initial look-ahead is used to prevent matching of blank selectors
  2208. pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
  2209. inside: {
  2210. 'parent': {
  2211. pattern: /&/,
  2212. alias: 'important'
  2213. },
  2214. 'placeholder': /%[-\w]+/,
  2215. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2216. }
  2217. },
  2218. 'property': {
  2219. pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
  2220. inside: {
  2221. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2222. }
  2223. }
  2224. });
  2225. Prism.languages.insertBefore('scss', 'atrule', {
  2226. 'keyword': [
  2227. /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
  2228. {
  2229. pattern: /( +)(?:from|through)(?= )/,
  2230. lookbehind: true
  2231. }
  2232. ]
  2233. });
  2234. Prism.languages.insertBefore('scss', 'important', {
  2235. // var and interpolated vars
  2236. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2237. });
  2238. Prism.languages.insertBefore('scss', 'function', {
  2239. 'placeholder': {
  2240. pattern: /%[-\w]+/,
  2241. alias: 'selector'
  2242. },
  2243. 'statement': {
  2244. pattern: /\B!(?:default|optional)\b/i,
  2245. alias: 'keyword'
  2246. },
  2247. 'boolean': /\b(?:true|false)\b/,
  2248. 'null': {
  2249. pattern: /\bnull\b/,
  2250. alias: 'keyword'
  2251. },
  2252. 'operator': {
  2253. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
  2254. lookbehind: true
  2255. }
  2256. });
  2257. Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
  2258. Prism.languages.python = {
  2259. 'comment': {
  2260. pattern: /(^|[^\\])#.*/,
  2261. lookbehind: true
  2262. },
  2263. 'string-interpolation': {
  2264. pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]+?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
  2265. greedy: true,
  2266. inside: {
  2267. 'interpolation': {
  2268. // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
  2269. pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
  2270. lookbehind: true,
  2271. inside: {
  2272. 'format-spec': {
  2273. pattern: /(:)[^:(){}]+(?=}$)/,
  2274. lookbehind: true
  2275. },
  2276. 'conversion-option': {
  2277. pattern: /![sra](?=[:}]$)/,
  2278. alias: 'punctuation'
  2279. },
  2280. rest: null
  2281. }
  2282. },
  2283. 'string': /[\s\S]+/
  2284. }
  2285. },
  2286. 'triple-quoted-string': {
  2287. pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]+?\1/i,
  2288. greedy: true,
  2289. alias: 'string'
  2290. },
  2291. 'string': {
  2292. pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
  2293. greedy: true
  2294. },
  2295. 'function': {
  2296. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  2297. lookbehind: true
  2298. },
  2299. 'class-name': {
  2300. pattern: /(\bclass\s+)\w+/i,
  2301. lookbehind: true
  2302. },
  2303. 'decorator': {
  2304. pattern: /(^\s*)@\w+(?:\.\w+)*/i,
  2305. lookbehind: true,
  2306. alias: ['annotation', 'punctuation'],
  2307. inside: {
  2308. 'punctuation': /\./
  2309. }
  2310. },
  2311. 'keyword': /\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
  2312. '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/,
  2313. 'boolean': /\b(?:True|False|None)\b/,
  2314. 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
  2315. 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  2316. 'punctuation': /[{}[\];(),.:]/
  2317. };
  2318. Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
  2319. Prism.languages.py = Prism.languages.python;
  2320. (function(Prism) {
  2321. var javascript = Prism.util.clone(Prism.languages.javascript);
  2322. Prism.languages.jsx = Prism.languages.extend('markup', javascript);
  2323. Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?)?>/i;
  2324. Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
  2325. Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
  2326. Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
  2327. Prism.languages.insertBefore('inside', 'attr-name', {
  2328. 'spread': {
  2329. pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}/,
  2330. inside: {
  2331. 'punctuation': /\.{3}|[{}.]/,
  2332. 'attr-value': /\w+/
  2333. }
  2334. }
  2335. }, Prism.languages.jsx.tag);
  2336. Prism.languages.insertBefore('inside', 'attr-value',{
  2337. 'script': {
  2338. // Allow for two levels of nesting
  2339. pattern: /=(\{(?:\{(?:\{[^}]*\}|[^}])*\}|[^}])+\})/i,
  2340. inside: {
  2341. 'script-punctuation': {
  2342. pattern: /^=(?={)/,
  2343. alias: 'punctuation'
  2344. },
  2345. rest: Prism.languages.jsx
  2346. },
  2347. 'alias': 'language-javascript'
  2348. }
  2349. }, Prism.languages.jsx.tag);
  2350. // The following will handle plain text inside tags
  2351. var stringifyToken = function (token) {
  2352. if (!token) {
  2353. return '';
  2354. }
  2355. if (typeof token === 'string') {
  2356. return token;
  2357. }
  2358. if (typeof token.content === 'string') {
  2359. return token.content;
  2360. }
  2361. return token.content.map(stringifyToken).join('');
  2362. };
  2363. var walkTokens = function (tokens) {
  2364. var openedTags = [];
  2365. for (var i = 0; i < tokens.length; i++) {
  2366. var token = tokens[i];
  2367. var notTagNorBrace = false;
  2368. if (typeof token !== 'string') {
  2369. if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
  2370. // We found a tag, now find its kind
  2371. if (token.content[0].content[0].content === '</') {
  2372. // Closing tag
  2373. if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
  2374. // Pop matching opening tag
  2375. openedTags.pop();
  2376. }
  2377. } else {
  2378. if (token.content[token.content.length - 1].content === '/>') {
  2379. // Autoclosed tag, ignore
  2380. } else {
  2381. // Opening tag
  2382. openedTags.push({
  2383. tagName: stringifyToken(token.content[0].content[1]),
  2384. openedBraces: 0
  2385. });
  2386. }
  2387. }
  2388. } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
  2389. // Here we might have entered a JSX context inside a tag
  2390. openedTags[openedTags.length - 1].openedBraces++;
  2391. } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
  2392. // Here we might have left a JSX context inside a tag
  2393. openedTags[openedTags.length - 1].openedBraces--;
  2394. } else {
  2395. notTagNorBrace = true
  2396. }
  2397. }
  2398. if (notTagNorBrace || typeof token === 'string') {
  2399. if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
  2400. // Here we are inside a tag, and not inside a JSX context.
  2401. // That's plain text: drop any tokens matched.
  2402. var plainText = stringifyToken(token);
  2403. // And merge text with adjacent text
  2404. if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
  2405. plainText += stringifyToken(tokens[i + 1]);
  2406. tokens.splice(i + 1, 1);
  2407. }
  2408. if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
  2409. plainText = stringifyToken(tokens[i - 1]) + plainText;
  2410. tokens.splice(i - 1, 1);
  2411. i--;
  2412. }
  2413. tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
  2414. }
  2415. }
  2416. if (token.content && typeof token.content !== 'string') {
  2417. walkTokens(token.content);
  2418. }
  2419. }
  2420. };
  2421. Prism.hooks.add('after-tokenize', function (env) {
  2422. if (env.language !== 'jsx' && env.language !== 'tsx') {
  2423. return;
  2424. }
  2425. walkTokens(env.tokens);
  2426. });
  2427. }(Prism));
  2428. /* TODO
  2429. Add support for Markdown notation inside doc comments
  2430. Add support for nested block comments...
  2431. Match closure params even when not followed by dash or brace
  2432. Add better support for macro definition
  2433. */
  2434. Prism.languages.rust = {
  2435. 'comment': [
  2436. {
  2437. pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
  2438. lookbehind: true
  2439. },
  2440. {
  2441. pattern: /(^|[^\\:])\/\/.*/,
  2442. lookbehind: true
  2443. }
  2444. ],
  2445. 'string': [
  2446. {
  2447. pattern: /b?r(#*)"(?:\\.|(?!"\1)[^\\\r\n])*"\1/,
  2448. greedy: true
  2449. },
  2450. {
  2451. pattern: /b?"(?:\\.|[^\\\r\n"])*"/,
  2452. greedy: true
  2453. }
  2454. ],
  2455. 'char': {
  2456. pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
  2457. alias: 'string'
  2458. },
  2459. 'lifetime-annotation': {
  2460. pattern: /'[^\s>']+/,
  2461. alias: 'symbol'
  2462. },
  2463. 'keyword': /\b(?:abstract|alignof|as|async|await|be|box|break|const|continue|crate|do|dyn|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|Self|struct|super|true|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
  2464. 'attribute': {
  2465. pattern: /#!?\[.+?\]/,
  2466. greedy: true,
  2467. alias: 'attr-name'
  2468. },
  2469. 'function': [
  2470. /\w+(?=\s*\()/,
  2471. // Macros can use parens or brackets
  2472. /\w+!(?=\s*\(|\[)/
  2473. ],
  2474. 'macro-rules': {
  2475. pattern: /\w+!/,
  2476. alias: 'function'
  2477. },
  2478. // Hex, oct, bin, dec numbers with visual separators and type suffix
  2479. '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/,
  2480. // Closure params should not be confused with bitwise OR |
  2481. 'closure-params': {
  2482. pattern: /\|[^|]*\|(?=\s*[{-])/,
  2483. inside: {
  2484. 'punctuation': /[|:,]/,
  2485. 'operator': /[&*]/
  2486. }
  2487. },
  2488. 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
  2489. 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
  2490. };
  2491. Prism.languages.yaml = {
  2492. 'scalar': {
  2493. pattern: /([\-:]\s*(?:![^\s]+)?[ \t]*[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/,
  2494. lookbehind: true,
  2495. alias: 'string'
  2496. },
  2497. 'comment': /#.*/,
  2498. 'key': {
  2499. pattern: /(\s*(?:^|[:\-,[{\r\n?])[ \t]*(?:![^\s]+)?[ \t]*)[^\r\n{[\]},#\s]+?(?=\s*:\s)/,
  2500. lookbehind: true,
  2501. alias: 'atrule'
  2502. },
  2503. 'directive': {
  2504. pattern: /(^[ \t]*)%.+/m,
  2505. lookbehind: true,
  2506. alias: 'important'
  2507. },
  2508. 'datetime': {
  2509. 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,
  2510. lookbehind: true,
  2511. alias: 'number'
  2512. },
  2513. 'boolean': {
  2514. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:true|false)[ \t]*(?=$|,|]|})/im,
  2515. lookbehind: true,
  2516. alias: 'important'
  2517. },
  2518. 'null': {
  2519. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)(?:null|~)[ \t]*(?=$|,|]|})/im,
  2520. lookbehind: true,
  2521. alias: 'important'
  2522. },
  2523. 'string': {
  2524. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|\s*#))/m,
  2525. lookbehind: true,
  2526. greedy: true
  2527. },
  2528. 'number': {
  2529. pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)[ \t]*(?=$|,|]|})/im,
  2530. lookbehind: true
  2531. },
  2532. 'tag': /![^\s]+/,
  2533. 'important': /[&*][\w]+/,
  2534. 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
  2535. };
  2536. Prism.languages.yml = Prism.languages.yaml;