prism.js 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320
  1. /* PrismJS 1.20.0
  2. https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+cpp+coffeescript+crystal+d+dart+django+elixir+erlang+go+groovy+java+json+julia+kotlin+lua+markup-templating+matlab+nginx+nim+ocaml+perl+php+python+jsx+ruby+rust+scss+shell-session+sql+typescript+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 encode(tokens) {
  24. if (tokens instanceof Token) {
  25. return new Token(tokens.type, encode(tokens.content), tokens.alias);
  26. } else if (Array.isArray(tokens)) {
  27. return tokens.map(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. * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
  76. *
  77. * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
  78. *
  79. * @param {Element} element
  80. * @returns {string}
  81. */
  82. getLanguage: function (element) {
  83. while (element && !lang.test(element.className)) {
  84. element = element.parentElement;
  85. }
  86. if (element) {
  87. return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
  88. }
  89. return 'none';
  90. },
  91. /**
  92. * Returns the script element that is currently executing.
  93. *
  94. * This does __not__ work for line script element.
  95. *
  96. * @returns {HTMLScriptElement | null}
  97. */
  98. currentScript: function () {
  99. if (typeof document === 'undefined') {
  100. return null;
  101. }
  102. if ('currentScript' in document) {
  103. return document.currentScript;
  104. }
  105. // IE11 workaround
  106. // we'll get the src of the current script by parsing IE11's error stack trace
  107. // this will not work for inline scripts
  108. try {
  109. throw new Error();
  110. } catch (err) {
  111. // Get file src url from stack. Specifically works with the format of stack traces in IE.
  112. // A stack will look like this:
  113. //
  114. // Error
  115. // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
  116. // at Global code (http://localhost/components/prism-core.js:606:1)
  117. var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1];
  118. if (src) {
  119. var scripts = document.getElementsByTagName('script');
  120. for (var i in scripts) {
  121. if (scripts[i].src == src) {
  122. return scripts[i];
  123. }
  124. }
  125. }
  126. return null;
  127. }
  128. }
  129. },
  130. languages: {
  131. extend: function (id, redef) {
  132. var lang = _.util.clone(_.languages[id]);
  133. for (var key in redef) {
  134. lang[key] = redef[key];
  135. }
  136. return lang;
  137. },
  138. /**
  139. * Insert a token before another token in a language literal
  140. * As this needs to recreate the object (we cannot actually insert before keys in object literals),
  141. * we cannot just provide an object, we need an object and a key.
  142. * @param inside The key (or language id) of the parent
  143. * @param before The key to insert before.
  144. * @param insert Object with the key/value pairs to insert
  145. * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
  146. */
  147. insertBefore: function (inside, before, insert, root) {
  148. root = root || _.languages;
  149. var grammar = root[inside];
  150. var ret = {};
  151. for (var token in grammar) {
  152. if (grammar.hasOwnProperty(token)) {
  153. if (token == before) {
  154. for (var newToken in insert) {
  155. if (insert.hasOwnProperty(newToken)) {
  156. ret[newToken] = insert[newToken];
  157. }
  158. }
  159. }
  160. // Do not insert token which also occur in insert. See #1525
  161. if (!insert.hasOwnProperty(token)) {
  162. ret[token] = grammar[token];
  163. }
  164. }
  165. }
  166. var old = root[inside];
  167. root[inside] = ret;
  168. // Update references in other language definitions
  169. _.languages.DFS(_.languages, function(key, value) {
  170. if (value === old && key != inside) {
  171. this[key] = ret;
  172. }
  173. });
  174. return ret;
  175. },
  176. // Traverse a language definition with Depth First Search
  177. DFS: function DFS(o, callback, type, visited) {
  178. visited = visited || {};
  179. var objId = _.util.objId;
  180. for (var i in o) {
  181. if (o.hasOwnProperty(i)) {
  182. callback.call(o, i, o[i], type || i);
  183. var property = o[i],
  184. propertyType = _.util.type(property);
  185. if (propertyType === 'Object' && !visited[objId(property)]) {
  186. visited[objId(property)] = true;
  187. DFS(property, callback, null, visited);
  188. }
  189. else if (propertyType === 'Array' && !visited[objId(property)]) {
  190. visited[objId(property)] = true;
  191. DFS(property, callback, i, visited);
  192. }
  193. }
  194. }
  195. }
  196. },
  197. plugins: {},
  198. highlightAll: function(async, callback) {
  199. _.highlightAllUnder(document, async, callback);
  200. },
  201. highlightAllUnder: function(container, async, callback) {
  202. var env = {
  203. callback: callback,
  204. container: container,
  205. selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
  206. };
  207. _.hooks.run('before-highlightall', env);
  208. env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
  209. _.hooks.run('before-all-elements-highlight', env);
  210. for (var i = 0, element; element = env.elements[i++];) {
  211. _.highlightElement(element, async === true, env.callback);
  212. }
  213. },
  214. highlightElement: function(element, async, callback) {
  215. // Find language
  216. var language = _.util.getLanguage(element);
  217. var grammar = _.languages[language];
  218. // Set language on the element, if not present
  219. element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  220. // Set language on the parent, for styling
  221. var parent = element.parentNode;
  222. if (parent && parent.nodeName.toLowerCase() === 'pre') {
  223. parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
  224. }
  225. var code = element.textContent;
  226. var env = {
  227. element: element,
  228. language: language,
  229. grammar: grammar,
  230. code: code
  231. };
  232. function insertHighlightedCode(highlightedCode) {
  233. env.highlightedCode = highlightedCode;
  234. _.hooks.run('before-insert', env);
  235. env.element.innerHTML = env.highlightedCode;
  236. _.hooks.run('after-highlight', env);
  237. _.hooks.run('complete', env);
  238. callback && callback.call(env.element);
  239. }
  240. _.hooks.run('before-sanity-check', env);
  241. if (!env.code) {
  242. _.hooks.run('complete', env);
  243. callback && callback.call(env.element);
  244. return;
  245. }
  246. _.hooks.run('before-highlight', env);
  247. if (!env.grammar) {
  248. insertHighlightedCode(_.util.encode(env.code));
  249. return;
  250. }
  251. if (async && _self.Worker) {
  252. var worker = new Worker(_.filename);
  253. worker.onmessage = function(evt) {
  254. insertHighlightedCode(evt.data);
  255. };
  256. worker.postMessage(JSON.stringify({
  257. language: env.language,
  258. code: env.code,
  259. immediateClose: true
  260. }));
  261. }
  262. else {
  263. insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
  264. }
  265. },
  266. highlight: function (text, grammar, language) {
  267. var env = {
  268. code: text,
  269. grammar: grammar,
  270. language: language
  271. };
  272. _.hooks.run('before-tokenize', env);
  273. env.tokens = _.tokenize(env.code, env.grammar);
  274. _.hooks.run('after-tokenize', env);
  275. return Token.stringify(_.util.encode(env.tokens), env.language);
  276. },
  277. tokenize: function(text, grammar) {
  278. var rest = grammar.rest;
  279. if (rest) {
  280. for (var token in rest) {
  281. grammar[token] = rest[token];
  282. }
  283. delete grammar.rest;
  284. }
  285. var tokenList = new LinkedList();
  286. addAfter(tokenList, tokenList.head, text);
  287. matchGrammar(text, tokenList, grammar, tokenList.head, 0);
  288. return toArray(tokenList);
  289. },
  290. hooks: {
  291. all: {},
  292. add: function (name, callback) {
  293. var hooks = _.hooks.all;
  294. hooks[name] = hooks[name] || [];
  295. hooks[name].push(callback);
  296. },
  297. run: function (name, env) {
  298. var callbacks = _.hooks.all[name];
  299. if (!callbacks || !callbacks.length) {
  300. return;
  301. }
  302. for (var i=0, callback; callback = callbacks[i++];) {
  303. callback(env);
  304. }
  305. }
  306. },
  307. Token: Token
  308. };
  309. _self.Prism = _;
  310. function Token(type, content, alias, matchedStr, greedy) {
  311. this.type = type;
  312. this.content = content;
  313. this.alias = alias;
  314. // Copy of the full string this token was created from
  315. this.length = (matchedStr || '').length|0;
  316. this.greedy = !!greedy;
  317. }
  318. Token.stringify = function stringify(o, language) {
  319. if (typeof o == 'string') {
  320. return o;
  321. }
  322. if (Array.isArray(o)) {
  323. var s = '';
  324. o.forEach(function (e) {
  325. s += stringify(e, language);
  326. });
  327. return s;
  328. }
  329. var env = {
  330. type: o.type,
  331. content: stringify(o.content, language),
  332. tag: 'span',
  333. classes: ['token', o.type],
  334. attributes: {},
  335. language: language
  336. };
  337. var aliases = o.alias;
  338. if (aliases) {
  339. if (Array.isArray(aliases)) {
  340. Array.prototype.push.apply(env.classes, aliases);
  341. } else {
  342. env.classes.push(aliases);
  343. }
  344. }
  345. _.hooks.run('wrap', env);
  346. var attributes = '';
  347. for (var name in env.attributes) {
  348. attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
  349. }
  350. return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
  351. };
  352. /**
  353. * @param {string} text
  354. * @param {LinkedList<string | Token>} tokenList
  355. * @param {any} grammar
  356. * @param {LinkedListNode<string | Token>} startNode
  357. * @param {number} startPos
  358. * @param {boolean} [oneshot=false]
  359. * @param {string} [target]
  360. */
  361. function matchGrammar(text, tokenList, grammar, startNode, startPos, oneshot, target) {
  362. for (var token in grammar) {
  363. if (!grammar.hasOwnProperty(token) || !grammar[token]) {
  364. continue;
  365. }
  366. var patterns = grammar[token];
  367. patterns = Array.isArray(patterns) ? patterns : [patterns];
  368. for (var j = 0; j < patterns.length; ++j) {
  369. if (target && target == token + ',' + j) {
  370. return;
  371. }
  372. var pattern = patterns[j],
  373. inside = pattern.inside,
  374. lookbehind = !!pattern.lookbehind,
  375. greedy = !!pattern.greedy,
  376. lookbehindLength = 0,
  377. alias = pattern.alias;
  378. if (greedy && !pattern.pattern.global) {
  379. // Without the global flag, lastIndex won't work
  380. var flags = pattern.pattern.toString().match(/[imsuy]*$/)[0];
  381. pattern.pattern = RegExp(pattern.pattern.source, flags + 'g');
  382. }
  383. pattern = pattern.pattern || pattern;
  384. for ( // iterate the token list and keep track of the current token/string position
  385. var currentNode = startNode.next, pos = startPos;
  386. currentNode !== tokenList.tail;
  387. pos += currentNode.value.length, currentNode = currentNode.next
  388. ) {
  389. var str = currentNode.value;
  390. if (tokenList.length > text.length) {
  391. // Something went terribly wrong, ABORT, ABORT!
  392. return;
  393. }
  394. if (str instanceof Token) {
  395. continue;
  396. }
  397. var removeCount = 1; // this is the to parameter of removeBetween
  398. if (greedy && currentNode != tokenList.tail.prev) {
  399. pattern.lastIndex = pos;
  400. var match = pattern.exec(text);
  401. if (!match) {
  402. break;
  403. }
  404. var from = match.index + (lookbehind && match[1] ? match[1].length : 0);
  405. var to = match.index + match[0].length;
  406. var p = pos;
  407. // find the node that contains the match
  408. p += currentNode.value.length;
  409. while (from >= p) {
  410. currentNode = currentNode.next;
  411. p += currentNode.value.length;
  412. }
  413. // adjust pos (and p)
  414. p -= currentNode.value.length;
  415. pos = p;
  416. // the current node is a Token, then the match starts inside another Token, which is invalid
  417. if (currentNode.value instanceof Token) {
  418. continue;
  419. }
  420. // find the last node which is affected by this match
  421. for (
  422. var k = currentNode;
  423. k !== tokenList.tail && (p < to || (typeof k.value === 'string' && !k.prev.value.greedy));
  424. k = k.next
  425. ) {
  426. removeCount++;
  427. p += k.value.length;
  428. }
  429. removeCount--;
  430. // replace with the new match
  431. str = text.slice(pos, p);
  432. match.index -= pos;
  433. } else {
  434. pattern.lastIndex = 0;
  435. var match = pattern.exec(str);
  436. }
  437. if (!match) {
  438. if (oneshot) {
  439. break;
  440. }
  441. continue;
  442. }
  443. if (lookbehind) {
  444. lookbehindLength = match[1] ? match[1].length : 0;
  445. }
  446. var from = match.index + lookbehindLength,
  447. match = match[0].slice(lookbehindLength),
  448. to = from + match.length,
  449. before = str.slice(0, from),
  450. after = str.slice(to);
  451. var removeFrom = currentNode.prev;
  452. if (before) {
  453. removeFrom = addAfter(tokenList, removeFrom, before);
  454. pos += before.length;
  455. }
  456. removeRange(tokenList, removeFrom, removeCount);
  457. var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
  458. currentNode = addAfter(tokenList, removeFrom, wrapped);
  459. if (after) {
  460. addAfter(tokenList, currentNode, after);
  461. }
  462. if (removeCount > 1)
  463. matchGrammar(text, tokenList, grammar, currentNode.prev, pos, true, token + ',' + j);
  464. if (oneshot)
  465. break;
  466. }
  467. }
  468. }
  469. }
  470. /**
  471. * @typedef LinkedListNode
  472. * @property {T} value
  473. * @property {LinkedListNode<T> | null} prev The previous node.
  474. * @property {LinkedListNode<T> | null} next The next node.
  475. * @template T
  476. */
  477. /**
  478. * @template T
  479. */
  480. function LinkedList() {
  481. /** @type {LinkedListNode<T>} */
  482. var head = { value: null, prev: null, next: null };
  483. /** @type {LinkedListNode<T>} */
  484. var tail = { value: null, prev: head, next: null };
  485. head.next = tail;
  486. /** @type {LinkedListNode<T>} */
  487. this.head = head;
  488. /** @type {LinkedListNode<T>} */
  489. this.tail = tail;
  490. this.length = 0;
  491. }
  492. /**
  493. * Adds a new node with the given value to the list.
  494. * @param {LinkedList<T>} list
  495. * @param {LinkedListNode<T>} node
  496. * @param {T} value
  497. * @returns {LinkedListNode<T>} The added node.
  498. * @template T
  499. */
  500. function addAfter(list, node, value) {
  501. // assumes that node != list.tail && values.length >= 0
  502. var next = node.next;
  503. var newNode = { value: value, prev: node, next: next };
  504. node.next = newNode;
  505. next.prev = newNode;
  506. list.length++;
  507. return newNode;
  508. }
  509. /**
  510. * Removes `count` nodes after the given node. The given node will not be removed.
  511. * @param {LinkedList<T>} list
  512. * @param {LinkedListNode<T>} node
  513. * @param {number} count
  514. * @template T
  515. */
  516. function removeRange(list, node, count) {
  517. var next = node.next;
  518. for (var i = 0; i < count && next !== list.tail; i++) {
  519. next = next.next;
  520. }
  521. node.next = next;
  522. next.prev = node;
  523. list.length -= i;
  524. }
  525. /**
  526. * @param {LinkedList<T>} list
  527. * @returns {T[]}
  528. * @template T
  529. */
  530. function toArray(list) {
  531. var array = [];
  532. var node = list.head.next;
  533. while (node !== list.tail) {
  534. array.push(node.value);
  535. node = node.next;
  536. }
  537. return array;
  538. }
  539. if (!_self.document) {
  540. if (!_self.addEventListener) {
  541. // in Node.js
  542. return _;
  543. }
  544. if (!_.disableWorkerMessageHandler) {
  545. // In worker
  546. _self.addEventListener('message', function (evt) {
  547. var message = JSON.parse(evt.data),
  548. lang = message.language,
  549. code = message.code,
  550. immediateClose = message.immediateClose;
  551. _self.postMessage(_.highlight(code, _.languages[lang], lang));
  552. if (immediateClose) {
  553. _self.close();
  554. }
  555. }, false);
  556. }
  557. return _;
  558. }
  559. //Get current script and highlight
  560. var script = _.util.currentScript();
  561. if (script) {
  562. _.filename = script.src;
  563. if (script.hasAttribute('data-manual')) {
  564. _.manual = true;
  565. }
  566. }
  567. function highlightAutomaticallyCallback() {
  568. if (!_.manual) {
  569. _.highlightAll();
  570. }
  571. }
  572. if (!_.manual) {
  573. // If the document state is "loading", then we'll use DOMContentLoaded.
  574. // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
  575. // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
  576. // might take longer one animation frame to execute which can create a race condition where only some plugins have
  577. // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
  578. // See https://github.com/PrismJS/prism/issues/2102
  579. var readyState = document.readyState;
  580. if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
  581. document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
  582. } else {
  583. if (window.requestAnimationFrame) {
  584. window.requestAnimationFrame(highlightAutomaticallyCallback);
  585. } else {
  586. window.setTimeout(highlightAutomaticallyCallback, 16);
  587. }
  588. }
  589. }
  590. return _;
  591. })(_self);
  592. if (typeof module !== 'undefined' && module.exports) {
  593. module.exports = Prism;
  594. }
  595. // hack for components to work correctly in node.js
  596. if (typeof global !== 'undefined') {
  597. global.Prism = Prism;
  598. }
  599. ;
  600. Prism.languages.markup = {
  601. 'comment': /<!--[\s\S]*?-->/,
  602. 'prolog': /<\?[\s\S]+?\?>/,
  603. 'doctype': {
  604. // https://www.w3.org/TR/xml/#NT-doctypedecl
  605. pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
  606. greedy: true,
  607. inside: {
  608. 'internal-subset': {
  609. pattern: /(\[)[\s\S]+(?=\]>$)/,
  610. lookbehind: true,
  611. greedy: true,
  612. inside: null // see below
  613. },
  614. 'string': {
  615. pattern: /"[^"]*"|'[^']*'/,
  616. greedy: true
  617. },
  618. 'punctuation': /^<!|>$|[[\]]/,
  619. 'doctype-tag': /^DOCTYPE/,
  620. 'name': /[^\s<>'"]+/
  621. }
  622. },
  623. 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
  624. 'tag': {
  625. pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
  626. greedy: true,
  627. inside: {
  628. 'tag': {
  629. pattern: /^<\/?[^\s>\/]+/,
  630. inside: {
  631. 'punctuation': /^<\/?/,
  632. 'namespace': /^[^\s>\/:]+:/
  633. }
  634. },
  635. 'attr-value': {
  636. pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
  637. inside: {
  638. 'punctuation': [
  639. {
  640. pattern: /^=/,
  641. alias: 'attr-equals'
  642. },
  643. /"|'/
  644. ]
  645. }
  646. },
  647. 'punctuation': /\/?>/,
  648. 'attr-name': {
  649. pattern: /[^\s>\/]+/,
  650. inside: {
  651. 'namespace': /^[^\s>\/:]+:/
  652. }
  653. }
  654. }
  655. },
  656. 'entity': [
  657. {
  658. pattern: /&[\da-z]{1,8};/i,
  659. alias: 'named-entity'
  660. },
  661. /&#x?[\da-f]{1,8};/i
  662. ]
  663. };
  664. Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
  665. Prism.languages.markup['entity'];
  666. Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
  667. // Plugin to make entity title show the real entity, idea by Roman Komarov
  668. Prism.hooks.add('wrap', function (env) {
  669. if (env.type === 'entity') {
  670. env.attributes['title'] = env.content.replace(/&amp;/, '&');
  671. }
  672. });
  673. Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
  674. /**
  675. * Adds an inlined language to markup.
  676. *
  677. * An example of an inlined language is CSS with `<style>` tags.
  678. *
  679. * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
  680. * case insensitive.
  681. * @param {string} lang The language key.
  682. * @example
  683. * addInlined('style', 'css');
  684. */
  685. value: function addInlined(tagName, lang) {
  686. var includedCdataInside = {};
  687. includedCdataInside['language-' + lang] = {
  688. pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
  689. lookbehind: true,
  690. inside: Prism.languages[lang]
  691. };
  692. includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
  693. var inside = {
  694. 'included-cdata': {
  695. pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
  696. inside: includedCdataInside
  697. }
  698. };
  699. inside['language-' + lang] = {
  700. pattern: /[\s\S]+/,
  701. inside: Prism.languages[lang]
  702. };
  703. var def = {};
  704. def[tagName] = {
  705. pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
  706. lookbehind: true,
  707. greedy: true,
  708. inside: inside
  709. };
  710. Prism.languages.insertBefore('markup', 'cdata', def);
  711. }
  712. });
  713. Prism.languages.html = Prism.languages.markup;
  714. Prism.languages.mathml = Prism.languages.markup;
  715. Prism.languages.svg = Prism.languages.markup;
  716. Prism.languages.xml = Prism.languages.extend('markup', {});
  717. Prism.languages.ssml = Prism.languages.xml;
  718. Prism.languages.atom = Prism.languages.xml;
  719. Prism.languages.rss = Prism.languages.xml;
  720. (function (Prism) {
  721. var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
  722. Prism.languages.css = {
  723. 'comment': /\/\*[\s\S]*?\*\//,
  724. 'atrule': {
  725. pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
  726. inside: {
  727. 'rule': /^@[\w-]+/,
  728. 'selector-function-argument': {
  729. pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/,
  730. lookbehind: true,
  731. alias: 'selector'
  732. }
  733. // See rest below
  734. }
  735. },
  736. 'url': {
  737. pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
  738. greedy: true,
  739. inside: {
  740. 'function': /^url/i,
  741. 'punctuation': /^\(|\)$/
  742. }
  743. },
  744. 'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
  745. 'string': {
  746. pattern: string,
  747. greedy: true
  748. },
  749. 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
  750. 'important': /!important\b/i,
  751. 'function': /[-a-z0-9]+(?=\()/i,
  752. 'punctuation': /[(){};:,]/
  753. };
  754. Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
  755. var markup = Prism.languages.markup;
  756. if (markup) {
  757. markup.tag.addInlined('style', 'css');
  758. Prism.languages.insertBefore('inside', 'attr-value', {
  759. 'style-attr': {
  760. pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
  761. inside: {
  762. 'attr-name': {
  763. pattern: /^\s*style/i,
  764. inside: markup.tag.inside
  765. },
  766. 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
  767. 'attr-value': {
  768. pattern: /.+/i,
  769. inside: Prism.languages.css
  770. }
  771. },
  772. alias: 'language-css'
  773. }
  774. }, markup.tag);
  775. }
  776. }(Prism));
  777. Prism.languages.clike = {
  778. 'comment': [
  779. {
  780. pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
  781. lookbehind: true
  782. },
  783. {
  784. pattern: /(^|[^\\:])\/\/.*/,
  785. lookbehind: true,
  786. greedy: true
  787. }
  788. ],
  789. 'string': {
  790. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  791. greedy: true
  792. },
  793. 'class-name': {
  794. pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
  795. lookbehind: true,
  796. inside: {
  797. 'punctuation': /[.\\]/
  798. }
  799. },
  800. 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
  801. 'boolean': /\b(?:true|false)\b/,
  802. 'function': /\w+(?=\()/,
  803. 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
  804. 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
  805. 'punctuation': /[{}[\];(),.:]/
  806. };
  807. Prism.languages.javascript = Prism.languages.extend('clike', {
  808. 'class-name': [
  809. Prism.languages.clike['class-name'],
  810. {
  811. pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
  812. lookbehind: true
  813. }
  814. ],
  815. 'keyword': [
  816. {
  817. pattern: /((?:^|})\s*)(?:catch|finally)\b/,
  818. lookbehind: true
  819. },
  820. {
  821. pattern: /(^|[^.]|\.\.\.\s*)\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/,
  822. lookbehind: true
  823. },
  824. ],
  825. '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)?)+)?/,
  826. // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
  827. 'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
  828. 'operator': /--|\+\+|\*\*=?|=>|&&|\|\||[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?[.?]?|[~:]/
  829. });
  830. Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
  831. Prism.languages.insertBefore('javascript', 'keyword', {
  832. 'regex': {
  833. pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
  834. lookbehind: true,
  835. greedy: true
  836. },
  837. // This must be declared before keyword because we use "function" inside the look-forward
  838. 'function-variable': {
  839. pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
  840. alias: 'function'
  841. },
  842. 'parameter': [
  843. {
  844. pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
  845. lookbehind: true,
  846. inside: Prism.languages.javascript
  847. },
  848. {
  849. pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
  850. inside: Prism.languages.javascript
  851. },
  852. {
  853. pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
  854. lookbehind: true,
  855. inside: Prism.languages.javascript
  856. },
  857. {
  858. 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*\{)/,
  859. lookbehind: true,
  860. inside: Prism.languages.javascript
  861. }
  862. ],
  863. 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
  864. });
  865. Prism.languages.insertBefore('javascript', 'string', {
  866. 'template-string': {
  867. pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
  868. greedy: true,
  869. inside: {
  870. 'template-punctuation': {
  871. pattern: /^`|`$/,
  872. alias: 'string'
  873. },
  874. 'interpolation': {
  875. pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
  876. lookbehind: true,
  877. inside: {
  878. 'interpolation-punctuation': {
  879. pattern: /^\${|}$/,
  880. alias: 'punctuation'
  881. },
  882. rest: Prism.languages.javascript
  883. }
  884. },
  885. 'string': /[\s\S]+/
  886. }
  887. }
  888. });
  889. if (Prism.languages.markup) {
  890. Prism.languages.markup.tag.addInlined('script', 'javascript');
  891. }
  892. Prism.languages.js = Prism.languages.javascript;
  893. (function(Prism) {
  894. // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
  895. // + LC_ALL, RANDOM, REPLY, SECONDS.
  896. // + make sure PS1..4 are here as they are not always set,
  897. // - some useless things.
  898. 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';
  899. var insideString = {
  900. 'environment': {
  901. pattern: RegExp("\\$" + envVars),
  902. alias: 'constant'
  903. },
  904. 'variable': [
  905. // [0]: Arithmetic Environment
  906. {
  907. pattern: /\$?\(\([\s\S]+?\)\)/,
  908. greedy: true,
  909. inside: {
  910. // If there is a $ sign at the beginning highlight $(( and )) as variable
  911. 'variable': [
  912. {
  913. pattern: /(^\$\(\([\s\S]+)\)\)/,
  914. lookbehind: true
  915. },
  916. /^\$\(\(/
  917. ],
  918. 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
  919. // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
  920. 'operator': /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
  921. // If there is no $ sign at the beginning highlight (( and )) as punctuation
  922. 'punctuation': /\(\(?|\)\)?|,|;/
  923. }
  924. },
  925. // [1]: Command Substitution
  926. {
  927. pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
  928. greedy: true,
  929. inside: {
  930. 'variable': /^\$\(|^`|\)$|`$/
  931. }
  932. },
  933. // [2]: Brace expansion
  934. {
  935. pattern: /\$\{[^}]+\}/,
  936. greedy: true,
  937. inside: {
  938. 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
  939. 'punctuation': /[\[\]]/,
  940. 'environment': {
  941. pattern: RegExp("(\\{)" + envVars),
  942. lookbehind: true,
  943. alias: 'constant'
  944. }
  945. }
  946. },
  947. /\$(?:\w+|[#?*!@$])/
  948. ],
  949. // Escape sequences from echo and printf's manuals, and escaped quotes.
  950. '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})/
  951. };
  952. Prism.languages.bash = {
  953. 'shebang': {
  954. pattern: /^#!\s*\/.*/,
  955. alias: 'important'
  956. },
  957. 'comment': {
  958. pattern: /(^|[^"{\\$])#.*/,
  959. lookbehind: true
  960. },
  961. 'function-name': [
  962. // a) function foo {
  963. // b) foo() {
  964. // c) function foo() {
  965. // but not “foo {”
  966. {
  967. // a) and c)
  968. pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
  969. lookbehind: true,
  970. alias: 'function'
  971. },
  972. {
  973. // b)
  974. pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
  975. alias: 'function'
  976. }
  977. ],
  978. // Highlight variable names as variables in for and select beginnings.
  979. 'for-or-select': {
  980. pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
  981. alias: 'variable',
  982. lookbehind: true
  983. },
  984. // Highlight variable names as variables in the left-hand part
  985. // of assignments (“=” and “+=”).
  986. 'assign-left': {
  987. pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
  988. inside: {
  989. 'environment': {
  990. pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
  991. lookbehind: true,
  992. alias: 'constant'
  993. }
  994. },
  995. alias: 'variable',
  996. lookbehind: true
  997. },
  998. 'string': [
  999. // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
  1000. {
  1001. pattern: /((?:^|[^<])<<-?\s*)(\w+?)\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\2/,
  1002. lookbehind: true,
  1003. greedy: true,
  1004. inside: insideString
  1005. },
  1006. // Here-document with quotes around the tag
  1007. // → No expansion (so no “inside”).
  1008. {
  1009. pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\3/,
  1010. lookbehind: true,
  1011. greedy: true
  1012. },
  1013. // “Normal” string
  1014. {
  1015. pattern: /(^|[^\\](?:\\\\)*)(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\2)[^\\])*\2/,
  1016. lookbehind: true,
  1017. greedy: true,
  1018. inside: insideString
  1019. }
  1020. ],
  1021. 'environment': {
  1022. pattern: RegExp("\\$?" + envVars),
  1023. alias: 'constant'
  1024. },
  1025. 'variable': insideString.variable,
  1026. 'function': {
  1027. 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|composer|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;|&])/,
  1028. lookbehind: true
  1029. },
  1030. 'keyword': {
  1031. pattern: /(^|[\s;|&]|[<>]\()(?:if|then|else|elif|fi|for|while|in|case|esac|function|select|do|done|until)(?=$|[)\s;|&])/,
  1032. lookbehind: true
  1033. },
  1034. // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
  1035. 'builtin': {
  1036. 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;|&])/,
  1037. lookbehind: true,
  1038. // Alias added to make those easier to distinguish from strings.
  1039. alias: 'class-name'
  1040. },
  1041. 'boolean': {
  1042. pattern: /(^|[\s;|&]|[<>]\()(?:true|false)(?=$|[)\s;|&])/,
  1043. lookbehind: true
  1044. },
  1045. 'file-descriptor': {
  1046. pattern: /\B&\d\b/,
  1047. alias: 'important'
  1048. },
  1049. 'operator': {
  1050. // Lots of redirections here, but not just that.
  1051. pattern: /\d?<>|>\||\+=|==?|!=?|=~|<<[<-]?|[&\d]?>>|\d?[<>]&?|&[>&]?|\|[&|]?|<=?|>=?/,
  1052. inside: {
  1053. 'file-descriptor': {
  1054. pattern: /^\d/,
  1055. alias: 'important'
  1056. }
  1057. }
  1058. },
  1059. 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
  1060. 'number': {
  1061. pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
  1062. lookbehind: true
  1063. }
  1064. };
  1065. /* Patterns in command substitution. */
  1066. var toBeCopied = [
  1067. 'comment',
  1068. 'function-name',
  1069. 'for-or-select',
  1070. 'assign-left',
  1071. 'string',
  1072. 'environment',
  1073. 'function',
  1074. 'keyword',
  1075. 'builtin',
  1076. 'boolean',
  1077. 'file-descriptor',
  1078. 'operator',
  1079. 'punctuation',
  1080. 'number'
  1081. ];
  1082. var inside = insideString.variable[1].inside;
  1083. for(var i = 0; i < toBeCopied.length; i++) {
  1084. inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
  1085. }
  1086. Prism.languages.shell = Prism.languages.bash;
  1087. })(Prism);
  1088. Prism.languages.c = Prism.languages.extend('clike', {
  1089. 'comment': {
  1090. pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
  1091. greedy: true
  1092. },
  1093. 'class-name': {
  1094. pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+/,
  1095. lookbehind: true
  1096. },
  1097. 'keyword': /\b(?:__attribute__|_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/,
  1098. 'function': /[a-z_]\w*(?=\s*\()/i,
  1099. 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,
  1100. 'number': /(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
  1101. });
  1102. Prism.languages.insertBefore('c', 'string', {
  1103. 'macro': {
  1104. // allow for multiline macro definitions
  1105. // spaces after the # character compile fine with gcc
  1106. pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
  1107. lookbehind: true,
  1108. greedy: true,
  1109. alias: 'property',
  1110. inside: {
  1111. 'string': [
  1112. {
  1113. // highlight the path of the include statement as a string
  1114. pattern: /^(#\s*include\s*)<[^>]+>/,
  1115. lookbehind: true
  1116. },
  1117. Prism.languages.c['string']
  1118. ],
  1119. 'comment': Prism.languages.c['comment'],
  1120. // highlight macro directives as keywords
  1121. 'directive': {
  1122. pattern: /^(#\s*)[a-z]+/,
  1123. lookbehind: true,
  1124. alias: 'keyword'
  1125. }
  1126. }
  1127. },
  1128. // highlight predefined macros as constants
  1129. 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
  1130. });
  1131. delete Prism.languages.c['boolean'];
  1132. (function (Prism) {
  1133. var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|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|requires|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/;
  1134. Prism.languages.cpp = Prism.languages.extend('c', {
  1135. 'class-name': [
  1136. {
  1137. pattern: RegExp(/(\b(?:class|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
  1138. .replace(/<keyword>/g, function () { return keyword.source; })),
  1139. lookbehind: true
  1140. },
  1141. // This is intended to capture the class name of method implementations like:
  1142. // void foo::bar() const {}
  1143. // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
  1144. // it starts with an uppercase letter. This approximation should give decent results.
  1145. /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
  1146. // This will capture the class name before destructors like:
  1147. // Foo::~Foo() {}
  1148. /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
  1149. {
  1150. // This also intends to capture the class name of method implementations but here the class has template
  1151. // parameters, so it can't be a namespace (until C++ adds generic namespaces).
  1152. pattern: /\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/,
  1153. inside: null // see below
  1154. }
  1155. ],
  1156. 'keyword': keyword,
  1157. 'number': {
  1158. pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
  1159. greedy: true
  1160. },
  1161. 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
  1162. 'boolean': /\b(?:true|false)\b/
  1163. });
  1164. Prism.languages.insertBefore('cpp', 'string', {
  1165. 'raw-string': {
  1166. pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
  1167. alias: 'string',
  1168. greedy: true
  1169. }
  1170. });
  1171. Prism.languages.insertBefore('cpp', 'class-name', {
  1172. // the base clause is an optional list of parent classes
  1173. // https://en.cppreference.com/w/cpp/language/class
  1174. 'base-clause': {
  1175. pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)(?:[^;{}"'])+?(?=\s*[;{])/,
  1176. lookbehind: true,
  1177. greedy: true,
  1178. inside: Prism.languages.extend('cpp', {})
  1179. }
  1180. });
  1181. Prism.languages.insertBefore('inside', 'operator', {
  1182. // All untokenized words that are not namespaces should be class names
  1183. 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i
  1184. }, Prism.languages.cpp['base-clause']);
  1185. }(Prism));
  1186. (function(Prism) {
  1187. // Ignore comments starting with { to privilege string interpolation highlighting
  1188. var comment = /#(?!\{).+/,
  1189. interpolation = {
  1190. pattern: /#\{[^}]+\}/,
  1191. alias: 'variable'
  1192. };
  1193. Prism.languages.coffeescript = Prism.languages.extend('javascript', {
  1194. 'comment': comment,
  1195. 'string': [
  1196. // Strings are multiline
  1197. {
  1198. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  1199. greedy: true
  1200. },
  1201. {
  1202. // Strings are multiline
  1203. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  1204. greedy: true,
  1205. inside: {
  1206. 'interpolation': interpolation
  1207. }
  1208. }
  1209. ],
  1210. '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/,
  1211. 'class-member': {
  1212. pattern: /@(?!\d)\w+/,
  1213. alias: 'variable'
  1214. }
  1215. });
  1216. Prism.languages.insertBefore('coffeescript', 'comment', {
  1217. 'multiline-comment': {
  1218. pattern: /###[\s\S]+?###/,
  1219. alias: 'comment'
  1220. },
  1221. // Block regexp can contain comments and interpolation
  1222. 'block-regex': {
  1223. pattern: /\/{3}[\s\S]*?\/{3}/,
  1224. alias: 'regex',
  1225. inside: {
  1226. 'comment': comment,
  1227. 'interpolation': interpolation
  1228. }
  1229. }
  1230. });
  1231. Prism.languages.insertBefore('coffeescript', 'string', {
  1232. 'inline-javascript': {
  1233. pattern: /`(?:\\[\s\S]|[^\\`])*`/,
  1234. inside: {
  1235. 'delimiter': {
  1236. pattern: /^`|`$/,
  1237. alias: 'punctuation'
  1238. },
  1239. rest: Prism.languages.javascript
  1240. }
  1241. },
  1242. // Block strings
  1243. 'multiline-string': [
  1244. {
  1245. pattern: /'''[\s\S]*?'''/,
  1246. greedy: true,
  1247. alias: 'string'
  1248. },
  1249. {
  1250. pattern: /"""[\s\S]*?"""/,
  1251. greedy: true,
  1252. alias: 'string',
  1253. inside: {
  1254. interpolation: interpolation
  1255. }
  1256. }
  1257. ]
  1258. });
  1259. Prism.languages.insertBefore('coffeescript', 'keyword', {
  1260. // Object property
  1261. 'property': /(?!\d)\w+(?=\s*:(?!:))/
  1262. });
  1263. delete Prism.languages.coffeescript['template-string'];
  1264. Prism.languages.coffee = Prism.languages.coffeescript;
  1265. }(Prism));
  1266. /**
  1267. * Original by Samuel Flores
  1268. *
  1269. * Adds the following new token classes:
  1270. * constant, builtin, variable, symbol, regex
  1271. */
  1272. (function (Prism) {
  1273. Prism.languages.ruby = Prism.languages.extend('clike', {
  1274. 'comment': [
  1275. /#.*/,
  1276. {
  1277. pattern: /^=begin\s[\s\S]*?^=end/m,
  1278. greedy: true
  1279. }
  1280. ],
  1281. 'class-name': {
  1282. pattern: /(\b(?:class)\s+|\bcatch\s+\()[\w.\\]+/i,
  1283. lookbehind: true,
  1284. inside: {
  1285. 'punctuation': /[.\\]/
  1286. }
  1287. },
  1288. 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/
  1289. });
  1290. var interpolation = {
  1291. pattern: /#\{[^}]+\}/,
  1292. inside: {
  1293. 'delimiter': {
  1294. pattern: /^#\{|\}$/,
  1295. alias: 'tag'
  1296. },
  1297. rest: Prism.languages.ruby
  1298. }
  1299. };
  1300. delete Prism.languages.ruby.function;
  1301. Prism.languages.insertBefore('ruby', 'keyword', {
  1302. 'regex': [
  1303. {
  1304. pattern: RegExp(/%r/.source + '(?:' + [
  1305. /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/.source,
  1306. /\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/.source,
  1307. // Here we need to specifically allow interpolation
  1308. /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/.source,
  1309. /\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/.source,
  1310. /<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/.source
  1311. ].join('|') + ')'),
  1312. greedy: true,
  1313. inside: {
  1314. 'interpolation': interpolation
  1315. }
  1316. },
  1317. {
  1318. pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[gim]{0,3}(?=\s*(?:$|[\r\n,.;})]))/,
  1319. lookbehind: true,
  1320. greedy: true
  1321. }
  1322. ],
  1323. 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
  1324. 'symbol': {
  1325. pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
  1326. lookbehind: true
  1327. },
  1328. 'method-definition': {
  1329. pattern: /(\bdef\s+)[\w.]+/,
  1330. lookbehind: true,
  1331. inside: {
  1332. 'function': /\w+$/,
  1333. rest: Prism.languages.ruby
  1334. }
  1335. }
  1336. });
  1337. Prism.languages.insertBefore('ruby', 'number', {
  1338. '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/,
  1339. 'constant': /\b[A-Z]\w*(?:[?!]|\b)/
  1340. });
  1341. Prism.languages.ruby.string = [
  1342. {
  1343. pattern: RegExp(/%[qQiIwWxs]?/.source + '(?:' + [
  1344. /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
  1345. /\((?:[^()\\]|\\[\s\S])*\)/.source,
  1346. // Here we need to specifically allow interpolation
  1347. /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,
  1348. /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,
  1349. /<(?:[^<>\\]|\\[\s\S])*>/.source
  1350. ].join('|') + ')'),
  1351. greedy: true,
  1352. inside: {
  1353. 'interpolation': interpolation
  1354. }
  1355. },
  1356. {
  1357. pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  1358. greedy: true,
  1359. inside: {
  1360. 'interpolation': interpolation
  1361. }
  1362. }
  1363. ];
  1364. Prism.languages.rb = Prism.languages.ruby;
  1365. }(Prism));
  1366. (function(Prism) {
  1367. Prism.languages.crystal = Prism.languages.extend('ruby', {
  1368. keyword: [
  1369. /\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/,
  1370. {
  1371. pattern: /(\.\s*)(?:is_a|responds_to)\?/,
  1372. lookbehind: true
  1373. }
  1374. ],
  1375. 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/
  1376. });
  1377. Prism.languages.insertBefore('crystal', 'string', {
  1378. attribute: {
  1379. pattern: /@\[.+?\]/,
  1380. alias: 'attr-name',
  1381. inside: {
  1382. delimiter: {
  1383. pattern: /^@\[|\]$/,
  1384. alias: 'tag'
  1385. },
  1386. rest: Prism.languages.crystal
  1387. }
  1388. },
  1389. expansion: [
  1390. {
  1391. pattern: /\{\{.+?\}\}/,
  1392. inside: {
  1393. delimiter: {
  1394. pattern: /^\{\{|\}\}$/,
  1395. alias: 'tag'
  1396. },
  1397. rest: Prism.languages.crystal
  1398. }
  1399. },
  1400. {
  1401. pattern: /\{%.+?%\}/,
  1402. inside: {
  1403. delimiter: {
  1404. pattern: /^\{%|%\}$/,
  1405. alias: 'tag'
  1406. },
  1407. rest: Prism.languages.crystal
  1408. }
  1409. }
  1410. ]
  1411. });
  1412. }(Prism));
  1413. Prism.languages.d = Prism.languages.extend('clike', {
  1414. 'comment': [
  1415. {
  1416. // Shebang
  1417. pattern: /^\s*#!.+/,
  1418. greedy: true
  1419. },
  1420. {
  1421. pattern: RegExp(/(^|[^\\])/.source + '(?:' + [
  1422. // /+ comment +/
  1423. // Allow one level of nesting
  1424. /\/\+(?:\/\+(?:[^+]|\+(?!\/))*\+\/|(?!\/\+)[\s\S])*?\+\//.source,
  1425. // // comment
  1426. /\/\/.*/.source,
  1427. // /* comment */
  1428. /\/\*[\s\S]*?\*\//.source
  1429. ].join('|') + ')'),
  1430. lookbehind: true,
  1431. greedy: true
  1432. }
  1433. ],
  1434. 'string': [
  1435. {
  1436. pattern: RegExp([
  1437. // r"", x""
  1438. /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/.source,
  1439. // q"[]", q"()", q"<>", q"{}"
  1440. /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/.source,
  1441. // q"IDENT
  1442. // ...
  1443. // IDENT"
  1444. /\bq"((?!\d)\w+)$[\s\S]*?^\1"/.source,
  1445. // q"//", q"||", etc.
  1446. /\bq"(.)[\s\S]*?\2"/.source,
  1447. // Characters
  1448. // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
  1449. /'(?:\\(?:\W|\w+)|[^\\])'/.source,
  1450. /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
  1451. ].join('|'), 'm'),
  1452. greedy: true
  1453. },
  1454. {
  1455. pattern: /\bq\{(?:\{[^{}]*\}|[^{}])*\}/,
  1456. greedy: true,
  1457. alias: 'token-string'
  1458. }
  1459. ],
  1460. 'number': [
  1461. // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator
  1462. // Hexadecimal numbers must be handled separately to avoid problems with exponent "e"
  1463. /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i,
  1464. {
  1465. pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i,
  1466. lookbehind: true
  1467. }
  1468. ],
  1469. // In order: $, keywords and special tokens, globally defined symbols
  1470. '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/,
  1471. 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
  1472. });
  1473. Prism.languages.insertBefore('d', 'keyword', {
  1474. 'property': /\B@\w*/
  1475. });
  1476. Prism.languages.insertBefore('d', 'function', {
  1477. 'register': {
  1478. // Iasm registers
  1479. 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)/,
  1480. alias: 'variable'
  1481. }
  1482. });
  1483. Prism.languages.dart = Prism.languages.extend('clike', {
  1484. 'string': [
  1485. {
  1486. pattern: /r?("""|''')[\s\S]*?\1/,
  1487. greedy: true
  1488. },
  1489. {
  1490. pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1491. greedy: true
  1492. }
  1493. ],
  1494. 'keyword': [
  1495. /\b(?:async|sync|yield)\*/,
  1496. /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extension|external|extends|factory|final|finally|for|Function|get|hide|if|implements|interface|import|in|library|mixin|new|null|on|operator|part|rethrow|return|set|show|static|super|switch|sync|this|throw|try|typedef|var|void|while|with|yield)\b/
  1497. ],
  1498. 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
  1499. });
  1500. Prism.languages.insertBefore('dart','function',{
  1501. 'metadata': {
  1502. pattern: /@\w+/,
  1503. alias: 'symbol'
  1504. }
  1505. });
  1506. (function (Prism) {
  1507. /**
  1508. * Returns the placeholder for the given language id and index.
  1509. *
  1510. * @param {string} language
  1511. * @param {string|number} index
  1512. * @returns {string}
  1513. */
  1514. function getPlaceholder(language, index) {
  1515. return '___' + language.toUpperCase() + index + '___';
  1516. }
  1517. Object.defineProperties(Prism.languages['markup-templating'] = {}, {
  1518. buildPlaceholders: {
  1519. /**
  1520. * Tokenize all inline templating expressions matching `placeholderPattern`.
  1521. *
  1522. * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
  1523. * `true` will be replaced.
  1524. *
  1525. * @param {object} env The environment of the `before-tokenize` hook.
  1526. * @param {string} language The language id.
  1527. * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
  1528. * @param {(match: string) => boolean} [replaceFilter]
  1529. */
  1530. value: function (env, language, placeholderPattern, replaceFilter) {
  1531. if (env.language !== language) {
  1532. return;
  1533. }
  1534. var tokenStack = env.tokenStack = [];
  1535. env.code = env.code.replace(placeholderPattern, function (match) {
  1536. if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
  1537. return match;
  1538. }
  1539. var i = tokenStack.length;
  1540. var placeholder;
  1541. // Check for existing strings
  1542. while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1)
  1543. ++i;
  1544. // Create a sparse array
  1545. tokenStack[i] = match;
  1546. return placeholder;
  1547. });
  1548. // Switch the grammar to markup
  1549. env.grammar = Prism.languages.markup;
  1550. }
  1551. },
  1552. tokenizePlaceholders: {
  1553. /**
  1554. * Replace placeholders with proper tokens after tokenizing.
  1555. *
  1556. * @param {object} env The environment of the `after-tokenize` hook.
  1557. * @param {string} language The language id.
  1558. */
  1559. value: function (env, language) {
  1560. if (env.language !== language || !env.tokenStack) {
  1561. return;
  1562. }
  1563. // Switch the grammar back
  1564. env.grammar = Prism.languages[language];
  1565. var j = 0;
  1566. var keys = Object.keys(env.tokenStack);
  1567. function walkTokens(tokens) {
  1568. for (var i = 0; i < tokens.length; i++) {
  1569. // all placeholders are replaced already
  1570. if (j >= keys.length) {
  1571. break;
  1572. }
  1573. var token = tokens[i];
  1574. if (typeof token === 'string' || (token.content && typeof token.content === 'string')) {
  1575. var k = keys[j];
  1576. var t = env.tokenStack[k];
  1577. var s = typeof token === 'string' ? token : token.content;
  1578. var placeholder = getPlaceholder(language, k);
  1579. var index = s.indexOf(placeholder);
  1580. if (index > -1) {
  1581. ++j;
  1582. var before = s.substring(0, index);
  1583. var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
  1584. var after = s.substring(index + placeholder.length);
  1585. var replacement = [];
  1586. if (before) {
  1587. replacement.push.apply(replacement, walkTokens([before]));
  1588. }
  1589. replacement.push(middle);
  1590. if (after) {
  1591. replacement.push.apply(replacement, walkTokens([after]));
  1592. }
  1593. if (typeof token === 'string') {
  1594. tokens.splice.apply(tokens, [i, 1].concat(replacement));
  1595. } else {
  1596. token.content = replacement;
  1597. }
  1598. }
  1599. } else if (token.content /* && typeof token.content !== 'string' */) {
  1600. walkTokens(token.content);
  1601. }
  1602. }
  1603. return tokens;
  1604. }
  1605. walkTokens(env.tokens);
  1606. }
  1607. }
  1608. });
  1609. }(Prism));
  1610. // Django/Jinja2 syntax definition for Prism.js <http://prismjs.com> syntax highlighter.
  1611. // Mostly it works OK but can paint code incorrectly on complex html/template tag combinations.
  1612. (function (Prism) {
  1613. Prism.languages.django = {
  1614. 'comment': /^{#[\s\S]*?#}$/,
  1615. 'tag': {
  1616. pattern: /(^{%[+-]?\s*)\w+/,
  1617. lookbehind: true,
  1618. alias: 'keyword'
  1619. },
  1620. 'delimiter': {
  1621. pattern: /^{[{%][+-]?|[+-]?[}%]}$/,
  1622. alias: 'punctuation'
  1623. },
  1624. 'string': {
  1625. pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1626. greedy: true
  1627. },
  1628. 'filter': {
  1629. pattern: /(\|)\w+/,
  1630. lookbehind: true,
  1631. alias: 'function'
  1632. },
  1633. 'test': {
  1634. pattern: /(\bis\s+(?:not\s+)?)(?!not\b)\w+/,
  1635. lookbehind: true,
  1636. alias: 'function'
  1637. },
  1638. 'function': /\b[a-z_]\w+(?=\s*\()/i,
  1639. 'keyword': /\b(?:and|as|by|else|for|if|import|in|is|loop|not|or|recursive|with|without)\b/,
  1640. 'operator': /[-+*/%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  1641. 'number': /\b\d+(?:\.\d+)?\b/,
  1642. 'boolean': /[Tt]rue|[Ff]alse|[Nn]one/,
  1643. 'variable': /\b\w+?\b/,
  1644. 'punctuation': /[{}[\](),.:;]/
  1645. };
  1646. var pattern = /{{[\s\S]*?}}|{%[\s\S]*?%}|{#[\s\S]*?#}/g;
  1647. var markupTemplating = Prism.languages['markup-templating'];
  1648. Prism.hooks.add('before-tokenize', function (env) {
  1649. markupTemplating.buildPlaceholders(env, 'django', pattern);
  1650. });
  1651. Prism.hooks.add('after-tokenize', function (env) {
  1652. markupTemplating.tokenizePlaceholders(env, 'django');
  1653. });
  1654. // Add an Jinja2 alias
  1655. Prism.languages.jinja2 = Prism.languages.django;
  1656. Prism.hooks.add('before-tokenize', function (env) {
  1657. markupTemplating.buildPlaceholders(env, 'jinja2', pattern);
  1658. });
  1659. Prism.hooks.add('after-tokenize', function (env) {
  1660. markupTemplating.tokenizePlaceholders(env, 'jinja2');
  1661. });
  1662. })(Prism);
  1663. Prism.languages.elixir = {
  1664. 'comment': /#.*/m,
  1665. // ~r"""foo""" (multi-line), ~r'''foo''' (multi-line), ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r<foo>
  1666. 'regex': {
  1667. pattern: /~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,
  1668. greedy: true
  1669. },
  1670. 'string': [
  1671. {
  1672. // ~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>
  1673. pattern: /~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|#(?!\{)|[^#\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,
  1674. greedy: true,
  1675. inside: {
  1676. // See interpolation below
  1677. }
  1678. },
  1679. {
  1680. pattern: /("""|''')[\s\S]*?\1/,
  1681. greedy: true,
  1682. inside: {
  1683. // See interpolation below
  1684. }
  1685. },
  1686. {
  1687. // Multi-line strings are allowed
  1688. pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  1689. greedy: true,
  1690. inside: {
  1691. // See interpolation below
  1692. }
  1693. }
  1694. ],
  1695. 'atom': {
  1696. // Look-behind prevents bad highlighting of the :: operator
  1697. pattern: /(^|[^:]):\w+/,
  1698. lookbehind: true,
  1699. alias: 'symbol'
  1700. },
  1701. // Look-ahead prevents bad highlighting of the :: operator
  1702. 'attr-name': /\w+\??:(?!:)/,
  1703. 'capture': {
  1704. // Look-behind prevents bad highlighting of the && operator
  1705. pattern: /(^|[^&])&(?:[^&\s\d()][^\s()]*|(?=\())/,
  1706. lookbehind: true,
  1707. alias: 'function'
  1708. },
  1709. 'argument': {
  1710. // Look-behind prevents bad highlighting of the && operator
  1711. pattern: /(^|[^&])&\d+/,
  1712. lookbehind: true,
  1713. alias: 'variable'
  1714. },
  1715. 'attribute': {
  1716. pattern: /@\w+/,
  1717. alias: 'variable'
  1718. },
  1719. 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,
  1720. '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/,
  1721. 'boolean': /\b(?:true|false|nil)\b/,
  1722. 'operator': [
  1723. /\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,
  1724. {
  1725. // We don't want to match <<
  1726. pattern: /([^<])<(?!<)/,
  1727. lookbehind: true
  1728. },
  1729. {
  1730. // We don't want to match >>
  1731. pattern: /([^>])>(?!>)/,
  1732. lookbehind: true
  1733. }
  1734. ],
  1735. 'punctuation': /<<|>>|[.,%\[\]{}()]/
  1736. };
  1737. Prism.languages.elixir.string.forEach(function(o) {
  1738. o.inside = {
  1739. 'interpolation': {
  1740. pattern: /#\{[^}]+\}/,
  1741. inside: {
  1742. 'delimiter': {
  1743. pattern: /^#\{|\}$/,
  1744. alias: 'punctuation'
  1745. },
  1746. rest: Prism.languages.elixir
  1747. }
  1748. }
  1749. };
  1750. });
  1751. Prism.languages.erlang = {
  1752. 'comment': /%.+/,
  1753. 'string': {
  1754. pattern: /"(?:\\.|[^\\"\r\n])*"/,
  1755. greedy: true
  1756. },
  1757. 'quoted-function': {
  1758. pattern: /'(?:\\.|[^\\'\r\n])+'(?=\()/,
  1759. alias: 'function'
  1760. },
  1761. 'quoted-atom': {
  1762. pattern: /'(?:\\.|[^\\'\r\n])+'/,
  1763. alias: 'atom'
  1764. },
  1765. 'boolean': /\b(?:true|false)\b/,
  1766. 'keyword': /\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,
  1767. 'number': [
  1768. /\$\\?./,
  1769. /\d+#[a-z0-9]+/i,
  1770. /(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i
  1771. ],
  1772. 'function': /\b[a-z][\w@]*(?=\()/,
  1773. 'variable': {
  1774. // Look-behind is used to prevent wrong highlighting of atoms containing "@"
  1775. pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,
  1776. lookbehind: true
  1777. },
  1778. 'operator': [
  1779. /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,
  1780. {
  1781. // We don't want to match <<
  1782. pattern: /(^|[^<])<(?!<)/,
  1783. lookbehind: true
  1784. },
  1785. {
  1786. // We don't want to match >>
  1787. pattern: /(^|[^>])>(?!>)/,
  1788. lookbehind: true
  1789. }
  1790. ],
  1791. 'atom': /\b[a-z][\w@]*/,
  1792. 'punctuation': /[()[\]{}:;,.#|]|<<|>>/
  1793. };
  1794. Prism.languages.go = Prism.languages.extend('clike', {
  1795. '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/,
  1796. '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/,
  1797. 'boolean': /\b(?:_|iota|nil|true|false)\b/,
  1798. 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
  1799. 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
  1800. 'string': {
  1801. pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,
  1802. greedy: true
  1803. }
  1804. });
  1805. delete Prism.languages.go['class-name'];
  1806. Prism.languages.groovy = Prism.languages.extend('clike', {
  1807. 'string': [
  1808. {
  1809. // https://groovy-lang.org/syntax.html#_dollar_slashy_string
  1810. pattern: /("""|''')(?:[^\\]|\\[\s\S])*?\1|\$\/(?:[^/$]|\$(?:[/$]|(?![/$]))|\/(?!\$))*\/\$/,
  1811. greedy: true
  1812. },
  1813. {
  1814. // TODO: Slash strings (e.g. /foo/) can contain line breaks but this will cause a lot of trouble with
  1815. // simple division (see JS regex), so find a fix maybe?
  1816. pattern: /(["'/])(?:\\.|(?!\1)[^\\\r\n])*\1/,
  1817. greedy: true
  1818. }
  1819. ],
  1820. '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/,
  1821. 'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?[\d]+)?)[glidf]?\b/i,
  1822. 'operator': {
  1823. pattern: /(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.\.(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
  1824. lookbehind: true
  1825. },
  1826. 'punctuation': /\.+|[{}[\];(),.:$]/
  1827. });
  1828. Prism.languages.insertBefore('groovy', 'string', {
  1829. 'shebang': {
  1830. pattern: /#!.+/,
  1831. alias: 'comment'
  1832. }
  1833. });
  1834. Prism.languages.insertBefore('groovy', 'punctuation', {
  1835. 'spock-block': /\b(?:setup|given|when|then|and|cleanup|expect|where):/
  1836. });
  1837. Prism.languages.insertBefore('groovy', 'function', {
  1838. 'annotation': {
  1839. pattern: /(^|[^.])@\w+/,
  1840. lookbehind: true,
  1841. alias: 'punctuation'
  1842. }
  1843. });
  1844. // Handle string interpolation
  1845. Prism.hooks.add('wrap', function(env) {
  1846. if (env.language === 'groovy' && env.type === 'string') {
  1847. var delimiter = env.content[0];
  1848. if (delimiter != "'") {
  1849. var pattern = /([^\\])(?:\$(?:\{.*?\}|[\w.]+))/;
  1850. if (delimiter === '$') {
  1851. pattern = /([^\$])(?:\$(?:\{.*?\}|[\w.]+))/;
  1852. }
  1853. // To prevent double HTML-encoding we have to decode env.content first
  1854. env.content = env.content.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
  1855. env.content = Prism.highlight(env.content, {
  1856. 'expression': {
  1857. pattern: pattern,
  1858. lookbehind: true,
  1859. inside: Prism.languages.groovy
  1860. }
  1861. });
  1862. env.classes.push(delimiter === '/' ? 'regex' : 'gstring');
  1863. }
  1864. }
  1865. });
  1866. (function (Prism) {
  1867. var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|null|open|opens|package|private|protected|provides|public|record|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
  1868. // based on the java naming conventions
  1869. var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/;
  1870. Prism.languages.java = Prism.languages.extend('clike', {
  1871. 'class-name': [
  1872. className,
  1873. // variables and parameters
  1874. // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
  1875. /\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/
  1876. ],
  1877. 'keyword': keywords,
  1878. 'function': [
  1879. Prism.languages.clike.function,
  1880. {
  1881. pattern: /(\:\:)[a-z_]\w*/,
  1882. lookbehind: true
  1883. }
  1884. ],
  1885. '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,
  1886. 'operator': {
  1887. pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
  1888. lookbehind: true
  1889. }
  1890. });
  1891. Prism.languages.insertBefore('java', 'string', {
  1892. 'triple-quoted-string': {
  1893. // http://openjdk.java.net/jeps/355#Description
  1894. pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
  1895. greedy: true,
  1896. alias: 'string'
  1897. }
  1898. });
  1899. Prism.languages.insertBefore('java', 'class-name', {
  1900. 'annotation': {
  1901. alias: 'punctuation',
  1902. pattern: /(^|[^.])@\w+/,
  1903. lookbehind: true
  1904. },
  1905. 'namespace': {
  1906. pattern: RegExp(
  1907. /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/
  1908. .source.replace(/<keyword>/g, function () { return keywords.source; })),
  1909. lookbehind: true,
  1910. inside: {
  1911. 'punctuation': /\./,
  1912. }
  1913. },
  1914. 'generics': {
  1915. pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,
  1916. inside: {
  1917. 'class-name': className,
  1918. 'keyword': keywords,
  1919. 'punctuation': /[<>(),.:]/,
  1920. 'operator': /[?&|]/
  1921. }
  1922. }
  1923. });
  1924. }(Prism));
  1925. Prism.languages.json = {
  1926. 'property': {
  1927. pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
  1928. greedy: true
  1929. },
  1930. 'string': {
  1931. pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
  1932. greedy: true
  1933. },
  1934. 'comment': /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
  1935. 'number': /-?\d+\.?\d*(?:e[+-]?\d+)?/i,
  1936. 'punctuation': /[{}[\],]/,
  1937. 'operator': /:/,
  1938. 'boolean': /\b(?:true|false)\b/,
  1939. 'null': {
  1940. pattern: /\bnull\b/,
  1941. alias: 'keyword'
  1942. }
  1943. };
  1944. Prism.languages.webmanifest = Prism.languages.json;
  1945. Prism.languages.julia = {
  1946. 'comment': {
  1947. // support one level of nested comments
  1948. // https://github.com/JuliaLang/julia/pull/6128
  1949. pattern: /(^|[^\\])(?:#=(?:[^#=]|=(?!#)|#(?!=)|#=(?:[^#=]|=(?!#)|#(?!=))*=#)*=#|#.*)/,
  1950. lookbehind: true
  1951. },
  1952. 'regex': {
  1953. // https://docs.julialang.org/en/v1/manual/strings/#Regular-Expressions-1
  1954. pattern: /r"(?:\\.|[^"\\\r\n])*"[imsx]{0,4}/,
  1955. greedy: true
  1956. },
  1957. 'string': {
  1958. // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
  1959. // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
  1960. // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
  1961. // https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
  1962. pattern: /"""[\s\S]+?"""|\w*"(?:\\.|[^"\\\r\n])*"|(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'|`(?:[^\\`\r\n]|\\.)*`/,
  1963. lookbehind: true,
  1964. greedy: true
  1965. },
  1966. '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/,
  1967. 'boolean': /\b(?:true|false)\b/,
  1968. 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[box])?(?:[\da-f]+(?:_[\da-f]+)*\.?(?:\d+(?:_\d+)*)?|\.\d+(?:_\d+)*)(?:[efp][+-]?\d+(?:_\d+)*)?j?/i,
  1969. // https://docs.julialang.org/en/v1/manual/mathematical-operations/
  1970. // https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity-1
  1971. 'operator': /&&|\|\||[-+*^%÷⊻&$\\]=?|\/[\/=]?|!=?=?|\|[=>]?|<(?:<=?|[=:|])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥'√∛]/,
  1972. 'punctuation': /::?|[{}[\]();,.?]/,
  1973. // https://docs.julialang.org/en/v1/base/numbers/#Base.im
  1974. 'constant': /\b(?:(?:NaN|Inf)(?:16|32|64)?|im|pi|e|catalan|eulergamma|golden)\b|[πℯγφ]/
  1975. };
  1976. (function (Prism) {
  1977. Prism.languages.kotlin = Prism.languages.extend('clike', {
  1978. 'keyword': {
  1979. // The lookbehind prevents wrong highlighting of e.g. kotlin.properties.get
  1980. 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/,
  1981. lookbehind: true
  1982. },
  1983. 'function': [
  1984. /\w+(?=\s*\()/,
  1985. {
  1986. pattern: /(\.)\w+(?=\s*\{)/,
  1987. lookbehind: true
  1988. }
  1989. ],
  1990. 'number': /\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,
  1991. 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/
  1992. });
  1993. delete Prism.languages.kotlin["class-name"];
  1994. Prism.languages.insertBefore('kotlin', 'string', {
  1995. 'raw-string': {
  1996. pattern: /("""|''')[\s\S]*?\1/,
  1997. alias: 'string'
  1998. // See interpolation below
  1999. }
  2000. });
  2001. Prism.languages.insertBefore('kotlin', 'keyword', {
  2002. 'annotation': {
  2003. pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
  2004. alias: 'builtin'
  2005. }
  2006. });
  2007. Prism.languages.insertBefore('kotlin', 'function', {
  2008. 'label': {
  2009. pattern: /\w+@|@\w+/,
  2010. alias: 'symbol'
  2011. }
  2012. });
  2013. var interpolation = [
  2014. {
  2015. pattern: /\$\{[^}]+\}/,
  2016. inside: {
  2017. 'delimiter': {
  2018. pattern: /^\$\{|\}$/,
  2019. alias: 'variable'
  2020. },
  2021. rest: Prism.languages.kotlin
  2022. }
  2023. },
  2024. {
  2025. pattern: /\$\w+/,
  2026. alias: 'variable'
  2027. }
  2028. ];
  2029. Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
  2030. interpolation: interpolation
  2031. };
  2032. }(Prism));
  2033. Prism.languages.lua = {
  2034. 'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
  2035. // \z may be used to skip the following space
  2036. 'string': {
  2037. pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
  2038. greedy: true
  2039. },
  2040. 'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
  2041. '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/,
  2042. 'function': /(?!\d)\w+(?=\s*(?:[({]))/,
  2043. 'operator': [
  2044. /[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
  2045. {
  2046. // Match ".." but don't break "..."
  2047. pattern: /(^|[^.])\.\.(?!\.)/,
  2048. lookbehind: true
  2049. }
  2050. ],
  2051. 'punctuation': /[\[\](){},;]|\.+|:+/
  2052. };
  2053. Prism.languages.matlab = {
  2054. 'comment': [
  2055. /%\{[\s\S]*?\}%/,
  2056. /%.+/
  2057. ],
  2058. 'string': {
  2059. pattern: /\B'(?:''|[^'\r\n])*'/,
  2060. greedy: true
  2061. },
  2062. // FIXME We could handle imaginary numbers as a whole
  2063. 'number': /(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b/,
  2064. 'keyword': /\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
  2065. 'function': /(?!\d)\w+(?=\s*\()/,
  2066. 'operator': /\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,
  2067. 'punctuation': /\.{3}|[.,;\[\](){}!]/
  2068. };
  2069. Prism.languages.nginx = Prism.languages.extend('clike', {
  2070. 'comment': {
  2071. pattern: /(^|[^"{\\])#.*/,
  2072. lookbehind: true
  2073. },
  2074. '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
  2075. });
  2076. Prism.languages.insertBefore('nginx', 'keyword', {
  2077. 'variable': /\$[a-z_]+/i
  2078. });
  2079. Prism.languages.nim = {
  2080. 'comment': /#.*/,
  2081. // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
  2082. // Character literals are handled specifically to prevent issues with numeric type suffixes
  2083. 'string': {
  2084. pattern: /(?:(?:\b(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,
  2085. greedy: true
  2086. },
  2087. // The negative look ahead prevents wrong highlighting of the .. operator
  2088. 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
  2089. '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/,
  2090. 'function': {
  2091. pattern: /(?:(?!\d)(?:\w|\\x[8-9a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
  2092. inside: {
  2093. 'operator': /\*$/
  2094. }
  2095. },
  2096. // We don't want to highlight operators inside backticks
  2097. 'ignore': {
  2098. pattern: /`[^`\r\n]+`/,
  2099. inside: {
  2100. 'punctuation': /`/
  2101. }
  2102. },
  2103. 'operator': {
  2104. // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
  2105. // but allow the slice operator .. to take precedence over them
  2106. // One can define his own operators in Nim so all combination of operators might be an operator.
  2107. pattern: /(^|[({\[](?=\.\.)|(?![({\[]\.).)(?:(?:[=+\-*\/<>@$~&%|!?^:\\]|\.\.|\.(?![)}\]]))+|\b(?:and|div|of|or|in|is|isnot|mod|not|notin|shl|shr|xor)\b)/m,
  2108. lookbehind: true
  2109. },
  2110. 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
  2111. };
  2112. Prism.languages.ocaml = {
  2113. 'comment': /\(\*[\s\S]*?\*\)/,
  2114. 'string': [
  2115. {
  2116. pattern: /"(?:\\.|[^\\\r\n"])*"/,
  2117. greedy: true
  2118. },
  2119. {
  2120. pattern: /(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,
  2121. greedy: true
  2122. }
  2123. ],
  2124. 'number': /\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,
  2125. 'directive': {
  2126. pattern: /\B#\w+/,
  2127. alias: 'important'
  2128. },
  2129. 'label': {
  2130. pattern: /\B~\w+/,
  2131. alias: 'function'
  2132. },
  2133. 'type_variable': {
  2134. pattern: /\B'\w+/,
  2135. alias: 'function'
  2136. },
  2137. 'variant': {
  2138. pattern: /`\w+/,
  2139. alias: 'variable'
  2140. },
  2141. 'module': {
  2142. pattern: /\b[A-Z]\w+/,
  2143. alias: 'variable'
  2144. },
  2145. // For the list of keywords and operators,
  2146. // see: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sec84
  2147. 'keyword': /\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,
  2148. 'boolean': /\b(?:false|true)\b/,
  2149. // Custom operators are allowed
  2150. 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,
  2151. 'punctuation': /[(){}\[\]|_.,:;]/
  2152. };
  2153. Prism.languages.perl = {
  2154. 'comment': [
  2155. {
  2156. // POD
  2157. pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
  2158. lookbehind: true
  2159. },
  2160. {
  2161. pattern: /(^|[^\\$])#.*/,
  2162. lookbehind: true
  2163. }
  2164. ],
  2165. // TODO Could be nice to handle Heredoc too.
  2166. 'string': [
  2167. // q/.../
  2168. {
  2169. pattern: /\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2170. greedy: true
  2171. },
  2172. // q a...a
  2173. {
  2174. pattern: /\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2175. greedy: true
  2176. },
  2177. // q(...)
  2178. {
  2179. pattern: /\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
  2180. greedy: true
  2181. },
  2182. // q{...}
  2183. {
  2184. pattern: /\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
  2185. greedy: true
  2186. },
  2187. // q[...]
  2188. {
  2189. pattern: /\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
  2190. greedy: true
  2191. },
  2192. // q<...>
  2193. {
  2194. pattern: /\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
  2195. greedy: true
  2196. },
  2197. // "...", `...`
  2198. {
  2199. pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
  2200. greedy: true
  2201. },
  2202. // '...'
  2203. // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  2204. {
  2205. pattern: /'(?:[^'\\\r\n]|\\.)*'/,
  2206. greedy: true
  2207. }
  2208. ],
  2209. 'regex': [
  2210. // m/.../
  2211. {
  2212. pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  2213. greedy: true
  2214. },
  2215. // m a...a
  2216. {
  2217. pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
  2218. greedy: true
  2219. },
  2220. // m(...)
  2221. {
  2222. pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
  2223. greedy: true
  2224. },
  2225. // m{...}
  2226. {
  2227. pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
  2228. greedy: true
  2229. },
  2230. // m[...]
  2231. {
  2232. pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
  2233. greedy: true
  2234. },
  2235. // m<...>
  2236. {
  2237. pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  2238. greedy: true
  2239. },
  2240. // The lookbehinds prevent -s from breaking
  2241. // FIXME We don't handle change of separator like s(...)[...]
  2242. // s/.../.../
  2243. {
  2244. pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  2245. lookbehind: true,
  2246. greedy: true
  2247. },
  2248. // s a...a...a
  2249. {
  2250. pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,
  2251. lookbehind: true,
  2252. greedy: true
  2253. },
  2254. // s(...)(...)
  2255. {
  2256. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  2257. lookbehind: true,
  2258. greedy: true
  2259. },
  2260. // s{...}{...}
  2261. {
  2262. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  2263. lookbehind: true,
  2264. greedy: true
  2265. },
  2266. // s[...][...]
  2267. {
  2268. pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  2269. lookbehind: true,
  2270. greedy: true
  2271. },
  2272. // s<...><...>
  2273. {
  2274. pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  2275. lookbehind: true,
  2276. greedy: true
  2277. },
  2278. // /.../
  2279. // The look-ahead tries to prevent two divisions on
  2280. // the same line from being highlighted as regex.
  2281. // This does not support multi-line regex.
  2282. {
  2283. pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,
  2284. greedy: true
  2285. }
  2286. ],
  2287. // FIXME Not sure about the handling of ::, ', and #
  2288. 'variable': [
  2289. // ${^POSTMATCH}
  2290. /[&*$@%]\{\^[A-Z]+\}/,
  2291. // $^V
  2292. /[&*$@%]\^[A-Z_]/,
  2293. // ${...}
  2294. /[&*$@%]#?(?=\{)/,
  2295. // $foo
  2296. /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
  2297. // $1
  2298. /[&*$@%]\d+/,
  2299. // $_, @_, %!
  2300. // The negative lookahead prevents from breaking the %= operator
  2301. /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
  2302. ],
  2303. 'filehandle': {
  2304. // <>, <FOO>, _
  2305. pattern: /<(?![<=])\S*>|\b_\b/,
  2306. alias: 'symbol'
  2307. },
  2308. 'vstring': {
  2309. // v1.2, 1.2.3
  2310. pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
  2311. alias: 'string'
  2312. },
  2313. 'function': {
  2314. pattern: /sub [a-z0-9_]+/i,
  2315. inside: {
  2316. keyword: /sub/
  2317. }
  2318. },
  2319. '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/,
  2320. 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
  2321. 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
  2322. 'punctuation': /[{}[\];(),:]/
  2323. };
  2324. /**
  2325. * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
  2326. * Modified by Miles Johnson: http://milesj.me
  2327. *
  2328. * Supports the following:
  2329. * - Extends clike syntax
  2330. * - Support for PHP 5.3+ (namespaces, traits, generators, etc)
  2331. * - Smarter constant and function matching
  2332. *
  2333. * Adds the following new token classes:
  2334. * constant, delimiter, variable, function, package
  2335. */
  2336. (function (Prism) {
  2337. Prism.languages.php = Prism.languages.extend('clike', {
  2338. '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,
  2339. 'boolean': {
  2340. pattern: /\b(?:false|true)\b/i,
  2341. alias: 'constant'
  2342. },
  2343. 'constant': [
  2344. /\b[A-Z_][A-Z0-9_]*\b/,
  2345. /\b(?:null)\b/i,
  2346. ],
  2347. 'comment': {
  2348. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  2349. lookbehind: true
  2350. }
  2351. });
  2352. Prism.languages.insertBefore('php', 'string', {
  2353. 'shell-comment': {
  2354. pattern: /(^|[^\\])#.*/,
  2355. lookbehind: true,
  2356. alias: 'comment'
  2357. }
  2358. });
  2359. Prism.languages.insertBefore('php', 'comment', {
  2360. 'delimiter': {
  2361. pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
  2362. alias: 'important'
  2363. }
  2364. });
  2365. Prism.languages.insertBefore('php', 'keyword', {
  2366. 'variable': /\$+(?:\w+\b|(?={))/i,
  2367. 'package': {
  2368. pattern: /(\\|namespace\s+|use\s+)[\w\\]+/,
  2369. lookbehind: true,
  2370. inside: {
  2371. punctuation: /\\/
  2372. }
  2373. }
  2374. });
  2375. // Must be defined after the function pattern
  2376. Prism.languages.insertBefore('php', 'operator', {
  2377. 'property': {
  2378. pattern: /(->)[\w]+/,
  2379. lookbehind: true
  2380. }
  2381. });
  2382. var string_interpolation = {
  2383. pattern: /{\$(?:{(?:{[^{}]+}|[^{}]+)}|[^{}])+}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)*)/,
  2384. lookbehind: true,
  2385. inside: Prism.languages.php
  2386. };
  2387. Prism.languages.insertBefore('php', 'string', {
  2388. 'nowdoc-string': {
  2389. pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
  2390. greedy: true,
  2391. alias: 'string',
  2392. inside: {
  2393. 'delimiter': {
  2394. pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
  2395. alias: 'symbol',
  2396. inside: {
  2397. 'punctuation': /^<<<'?|[';]$/
  2398. }
  2399. }
  2400. }
  2401. },
  2402. 'heredoc-string': {
  2403. pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
  2404. greedy: true,
  2405. alias: 'string',
  2406. inside: {
  2407. 'delimiter': {
  2408. pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
  2409. alias: 'symbol',
  2410. inside: {
  2411. 'punctuation': /^<<<"?|[";]$/
  2412. }
  2413. },
  2414. 'interpolation': string_interpolation // See below
  2415. }
  2416. },
  2417. 'single-quoted-string': {
  2418. pattern: /'(?:\\[\s\S]|[^\\'])*'/,
  2419. greedy: true,
  2420. alias: 'string'
  2421. },
  2422. 'double-quoted-string': {
  2423. pattern: /"(?:\\[\s\S]|[^\\"])*"/,
  2424. greedy: true,
  2425. alias: 'string',
  2426. inside: {
  2427. 'interpolation': string_interpolation // See below
  2428. }
  2429. }
  2430. });
  2431. // The different types of PHP strings "replace" the C-like standard string
  2432. delete Prism.languages.php['string'];
  2433. Prism.hooks.add('before-tokenize', function(env) {
  2434. if (!/<\?/.test(env.code)) {
  2435. return;
  2436. }
  2437. var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#)(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|\/\*[\s\S]*?(?:\*\/|$))*?(?:\?>|$)/ig;
  2438. Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
  2439. });
  2440. Prism.hooks.add('after-tokenize', function(env) {
  2441. Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
  2442. });
  2443. }(Prism));
  2444. Prism.languages.python = {
  2445. 'comment': {
  2446. pattern: /(^|[^\\])#.*/,
  2447. lookbehind: true
  2448. },
  2449. 'string-interpolation': {
  2450. pattern: /(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
  2451. greedy: true,
  2452. inside: {
  2453. 'interpolation': {
  2454. // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
  2455. pattern: /((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,
  2456. lookbehind: true,
  2457. inside: {
  2458. 'format-spec': {
  2459. pattern: /(:)[^:(){}]+(?=}$)/,
  2460. lookbehind: true
  2461. },
  2462. 'conversion-option': {
  2463. pattern: /![sra](?=[:}]$)/,
  2464. alias: 'punctuation'
  2465. },
  2466. rest: null
  2467. }
  2468. },
  2469. 'string': /[\s\S]+/
  2470. }
  2471. },
  2472. 'triple-quoted-string': {
  2473. pattern: /(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,
  2474. greedy: true,
  2475. alias: 'string'
  2476. },
  2477. 'string': {
  2478. pattern: /(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
  2479. greedy: true
  2480. },
  2481. 'function': {
  2482. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  2483. lookbehind: true
  2484. },
  2485. 'class-name': {
  2486. pattern: /(\bclass\s+)\w+/i,
  2487. lookbehind: true
  2488. },
  2489. 'decorator': {
  2490. pattern: /(^\s*)@\w+(?:\.\w+)*/im,
  2491. lookbehind: true,
  2492. alias: ['annotation', 'punctuation'],
  2493. inside: {
  2494. 'punctuation': /\./
  2495. }
  2496. },
  2497. '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/,
  2498. '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/,
  2499. 'boolean': /\b(?:True|False|None)\b/,
  2500. 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
  2501. 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  2502. 'punctuation': /[{}[\];(),.:]/
  2503. };
  2504. Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
  2505. Prism.languages.py = Prism.languages.python;
  2506. (function(Prism) {
  2507. var javascript = Prism.util.clone(Prism.languages.javascript);
  2508. Prism.languages.jsx = Prism.languages.extend('markup', javascript);
  2509. Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:$-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}))*\s*\/?)?>/i;
  2510. Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i;
  2511. Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
  2512. Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
  2513. Prism.languages.insertBefore('inside', 'attr-name', {
  2514. 'spread': {
  2515. pattern: /\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}/,
  2516. inside: {
  2517. 'punctuation': /\.{3}|[{}.]/,
  2518. 'attr-value': /\w+/
  2519. }
  2520. }
  2521. }, Prism.languages.jsx.tag);
  2522. Prism.languages.insertBefore('inside', 'attr-value',{
  2523. 'script': {
  2524. // Allow for two levels of nesting
  2525. pattern: /=(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\})/i,
  2526. inside: {
  2527. 'script-punctuation': {
  2528. pattern: /^=(?={)/,
  2529. alias: 'punctuation'
  2530. },
  2531. rest: Prism.languages.jsx
  2532. },
  2533. 'alias': 'language-javascript'
  2534. }
  2535. }, Prism.languages.jsx.tag);
  2536. // The following will handle plain text inside tags
  2537. var stringifyToken = function (token) {
  2538. if (!token) {
  2539. return '';
  2540. }
  2541. if (typeof token === 'string') {
  2542. return token;
  2543. }
  2544. if (typeof token.content === 'string') {
  2545. return token.content;
  2546. }
  2547. return token.content.map(stringifyToken).join('');
  2548. };
  2549. var walkTokens = function (tokens) {
  2550. var openedTags = [];
  2551. for (var i = 0; i < tokens.length; i++) {
  2552. var token = tokens[i];
  2553. var notTagNorBrace = false;
  2554. if (typeof token !== 'string') {
  2555. if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
  2556. // We found a tag, now find its kind
  2557. if (token.content[0].content[0].content === '</') {
  2558. // Closing tag
  2559. if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
  2560. // Pop matching opening tag
  2561. openedTags.pop();
  2562. }
  2563. } else {
  2564. if (token.content[token.content.length - 1].content === '/>') {
  2565. // Autoclosed tag, ignore
  2566. } else {
  2567. // Opening tag
  2568. openedTags.push({
  2569. tagName: stringifyToken(token.content[0].content[1]),
  2570. openedBraces: 0
  2571. });
  2572. }
  2573. }
  2574. } else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
  2575. // Here we might have entered a JSX context inside a tag
  2576. openedTags[openedTags.length - 1].openedBraces++;
  2577. } else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
  2578. // Here we might have left a JSX context inside a tag
  2579. openedTags[openedTags.length - 1].openedBraces--;
  2580. } else {
  2581. notTagNorBrace = true
  2582. }
  2583. }
  2584. if (notTagNorBrace || typeof token === 'string') {
  2585. if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
  2586. // Here we are inside a tag, and not inside a JSX context.
  2587. // That's plain text: drop any tokens matched.
  2588. var plainText = stringifyToken(token);
  2589. // And merge text with adjacent text
  2590. if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
  2591. plainText += stringifyToken(tokens[i + 1]);
  2592. tokens.splice(i + 1, 1);
  2593. }
  2594. if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
  2595. plainText = stringifyToken(tokens[i - 1]) + plainText;
  2596. tokens.splice(i - 1, 1);
  2597. i--;
  2598. }
  2599. tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
  2600. }
  2601. }
  2602. if (token.content && typeof token.content !== 'string') {
  2603. walkTokens(token.content);
  2604. }
  2605. }
  2606. };
  2607. Prism.hooks.add('after-tokenize', function (env) {
  2608. if (env.language !== 'jsx' && env.language !== 'tsx') {
  2609. return;
  2610. }
  2611. walkTokens(env.tokens);
  2612. });
  2613. }(Prism));
  2614. (function (Prism) {
  2615. var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
  2616. for (var i = 0; i < 2; i++) {
  2617. // support 4 levels of nested comments
  2618. multilineComment = multilineComment.replace(/<self>/g, function () { return multilineComment; });
  2619. }
  2620. multilineComment = multilineComment.replace(/<self>/g, function () { return /[^\s\S]/.source; });
  2621. Prism.languages.rust = {
  2622. 'comment': [
  2623. {
  2624. pattern: RegExp(/(^|[^\\])/.source + multilineComment),
  2625. lookbehind: true,
  2626. greedy: true
  2627. },
  2628. {
  2629. pattern: /(^|[^\\:])\/\/.*/,
  2630. lookbehind: true,
  2631. greedy: true
  2632. }
  2633. ],
  2634. 'string': {
  2635. pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
  2636. greedy: true
  2637. },
  2638. 'char': {
  2639. pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u{(?:[\da-fA-F]_*){1,6}|.)|[^\\\r\n\t'])'/,
  2640. greedy: true,
  2641. alias: 'string'
  2642. },
  2643. 'attribute': {
  2644. pattern: /#!?\[[^[\]]*\]/,
  2645. greedy: true,
  2646. alias: 'attr-name',
  2647. inside: {
  2648. 'string': null // see below
  2649. }
  2650. },
  2651. // Closure params should not be confused with bitwise OR |
  2652. 'closure-params': {
  2653. pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
  2654. lookbehind: true,
  2655. greedy: true,
  2656. inside: {
  2657. 'closure-punctuation': {
  2658. pattern: /^\||\|$/,
  2659. alias: 'punctuation'
  2660. },
  2661. rest: null // see below
  2662. }
  2663. },
  2664. 'lifetime-annotation': {
  2665. pattern: /'\w+/,
  2666. alias: 'symbol'
  2667. },
  2668. 'fragment-specifier': {
  2669. pattern: /(\$\w+:)[a-z]+/,
  2670. lookbehind: true,
  2671. alias: 'punctuation'
  2672. },
  2673. 'variable': /\$\w+/,
  2674. 'function-definition': {
  2675. pattern: /(\bfn\s*)\w+/,
  2676. lookbehind: true,
  2677. alias: 'function'
  2678. },
  2679. 'keyword': [
  2680. // https://github.com/rust-lang/reference/blob/master/src/keywords.md
  2681. /\b(?:abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|Self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
  2682. // primitives
  2683. // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
  2684. /\b(?:[ui](?:8|16|32|64|128|size)|f(?:32|64)|bool|char)\b/
  2685. ],
  2686. // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
  2687. // and Rust's naming conventions recommend snake_case anyway.
  2688. // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
  2689. 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*)?\()/,
  2690. 'macro': {
  2691. pattern: /\w+!/,
  2692. alias: 'property'
  2693. },
  2694. // Hex, oct, bin, dec numbers with visual separators and type suffix
  2695. '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|size)?|f32|f64))?\b/,
  2696. 'boolean': /\b(?:false|true)\b/,
  2697. 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
  2698. 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
  2699. };
  2700. Prism.languages.rust['closure-params'].inside.rest = Prism.languages.rust;
  2701. Prism.languages.rust['attribute'].inside['string'] = Prism.languages.rust['string'];
  2702. }(Prism));
  2703. Prism.languages.scss = Prism.languages.extend('css', {
  2704. 'comment': {
  2705. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|\/\/.*)/,
  2706. lookbehind: true
  2707. },
  2708. 'atrule': {
  2709. pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+[{;])/,
  2710. inside: {
  2711. 'rule': /@[\w-]+/
  2712. // See rest below
  2713. }
  2714. },
  2715. // url, compassified
  2716. 'url': /(?:[-a-z]+-)?url(?=\()/i,
  2717. // CSS selector regex is not appropriate for Sass
  2718. // since there can be lot more things (var, @ directive, nesting..)
  2719. // a selector must start at the end of a property or after a brace (end of other rules or nesting)
  2720. // it can contain some characters that aren't used for defining rules or end of selector, & (parent selector), or interpolated variable
  2721. // 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
  2722. // can "pass" as a selector- e.g: proper#{$erty})
  2723. // this one was hard to do, so please be careful if you edit this one :)
  2724. 'selector': {
  2725. // Initial look-ahead is used to prevent matching of blank selectors
  2726. pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()]|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}]+[:{][^}]+))/m,
  2727. inside: {
  2728. 'parent': {
  2729. pattern: /&/,
  2730. alias: 'important'
  2731. },
  2732. 'placeholder': /%[-\w]+/,
  2733. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2734. }
  2735. },
  2736. 'property': {
  2737. pattern: /(?:[\w-]|\$[-\w]+|#\{\$[-\w]+\})+(?=\s*:)/,
  2738. inside: {
  2739. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2740. }
  2741. }
  2742. });
  2743. Prism.languages.insertBefore('scss', 'atrule', {
  2744. 'keyword': [
  2745. /@(?:if|else(?: if)?|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)/i,
  2746. {
  2747. pattern: /( +)(?:from|through)(?= )/,
  2748. lookbehind: true
  2749. }
  2750. ]
  2751. });
  2752. Prism.languages.insertBefore('scss', 'important', {
  2753. // var and interpolated vars
  2754. 'variable': /\$[-\w]+|#\{\$[-\w]+\}/
  2755. });
  2756. Prism.languages.insertBefore('scss', 'function', {
  2757. 'placeholder': {
  2758. pattern: /%[-\w]+/,
  2759. alias: 'selector'
  2760. },
  2761. 'statement': {
  2762. pattern: /\B!(?:default|optional)\b/i,
  2763. alias: 'keyword'
  2764. },
  2765. 'boolean': /\b(?:true|false)\b/,
  2766. 'null': {
  2767. pattern: /\bnull\b/,
  2768. alias: 'keyword'
  2769. },
  2770. 'operator': {
  2771. pattern: /(\s)(?:[-+*\/%]|[=!]=|<=?|>=?|and|or|not)(?=\s)/,
  2772. lookbehind: true
  2773. }
  2774. });
  2775. Prism.languages.scss['atrule'].inside.rest = Prism.languages.scss;
  2776. (function (Prism) {
  2777. // CAREFUL!
  2778. // The following patterns are concatenated, so the group referenced by a back reference is non-obvious!
  2779. var strings = [
  2780. // normal string
  2781. // 1 capturing group
  2782. /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/.source,
  2783. // here doc
  2784. // 1 capturing group
  2785. /<<-?\s*(\w+?)[ \t]*(?!.)[\s\S]*?[\r\n]\2/.source,
  2786. // here doc quoted
  2787. // 2 capturing group
  2788. /<<-?\s*(["'])(\w+)\3[ \t]*(?!.)[\s\S]*?[\r\n]\4/.source
  2789. ].join('|');
  2790. Prism.languages['shell-session'] = {
  2791. 'info': {
  2792. // foo@bar:~/files$ exit
  2793. // foo@bar$ exit
  2794. pattern: /^[^\r\n$#*!]+(?=[$#])/m,
  2795. alias: 'punctuation',
  2796. inside: {
  2797. 'path': {
  2798. pattern: /(:)[\s\S]+/,
  2799. lookbehind: true
  2800. },
  2801. 'user': /^[^\s@:$#*!/\\]+@[^\s@:$#*!/\\]+(?=:|$)/,
  2802. 'punctuation': /:/
  2803. }
  2804. },
  2805. 'command': {
  2806. pattern: RegExp(/[$#](?:[^\\\r\n'"<]|\\.|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; })),
  2807. greedy: true,
  2808. inside: {
  2809. 'bash': {
  2810. pattern: /(^[$#]\s*)[\s\S]+/,
  2811. lookbehind: true,
  2812. alias: 'language-bash',
  2813. inside: Prism.languages.bash
  2814. },
  2815. 'shell-symbol': {
  2816. pattern: /^[$#]/,
  2817. alias: 'important'
  2818. }
  2819. }
  2820. },
  2821. 'output': /.(?:.*(?:[\r\n]|.$))*/
  2822. };
  2823. }(Prism));
  2824. Prism.languages.sql = {
  2825. 'comment': {
  2826. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
  2827. lookbehind: true
  2828. },
  2829. 'variable': [
  2830. {
  2831. pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
  2832. greedy: true
  2833. },
  2834. /@[\w.$]+/
  2835. ],
  2836. 'string': {
  2837. pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
  2838. greedy: true,
  2839. lookbehind: true
  2840. },
  2841. '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?
  2842. '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,
  2843. 'boolean': /\b(?:TRUE|FALSE|NULL)\b/i,
  2844. 'number': /\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,
  2845. 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
  2846. 'punctuation': /[;[\]()`,.]/
  2847. };
  2848. Prism.languages.liquid = {
  2849. keyword:/\b(?:comment|endcomment|if|elsif|else|endif|unless|endunless|for|endfor|case|endcase|when|in|break|assign|continue|limit|offset|range|reversed|raw|endraw|capture|endcapture|tablerow|endtablerow)\b/,
  2850. number:/\b0b[01]+\b|\b0x(?:\.[\da-fp-]+|[\da-f]+(?:\.[\da-fp-]+)?)\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?[df]?/i,
  2851. operator:{
  2852. pattern:/(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<<?=?|>>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,
  2853. lookbehind:!0
  2854. },
  2855. function:{
  2856. pattern:/(^|[\s;|&])(?:append|prepend|capitalize|cycle|cols|increment|decrement|abs|at_least|at_most|ceil|compact|concat|date|default|divided_by|downcase|escape|escape_once|first|floor|join|last|lstrip|map|minus|modulo|newline_to_br|plus|remove|remove_first|replace|replace_first|reverse|round|rstrip|size|slice|sort|sort_natural|split|strip|strip_html|strip_newlines|times|truncate|truncatewords|uniq|upcase|url_decode|url_encode|include|paginate)(?=$|[\s;|&])/,
  2857. lookbehind:!0
  2858. }
  2859. };
  2860. (function (Prism) {
  2861. Prism.languages.typescript = Prism.languages.extend('javascript', {
  2862. 'class-name': {
  2863. pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
  2864. lookbehind: true,
  2865. greedy: true,
  2866. inside: null // see below
  2867. },
  2868. // From JavaScript Prism keyword list and TypeScript language spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#221-reserved-words
  2869. 'keyword': /\b(?:abstract|as|asserts|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|undefined|var|void|while|with|yield)\b/,
  2870. 'builtin': /\b(?:string|Function|any|number|boolean|Array|symbol|console|Promise|unknown|never)\b/,
  2871. });
  2872. // doesn't work with TS because TS is too complex
  2873. delete Prism.languages.typescript['parameter'];
  2874. // a version of typescript specifically for highlighting types
  2875. var typeInside = Prism.languages.extend('typescript', {});
  2876. delete typeInside['class-name'];
  2877. Prism.languages.typescript['class-name'].inside = typeInside;
  2878. Prism.languages.insertBefore('typescript', 'function', {
  2879. 'generic-function': {
  2880. // e.g. foo<T extends "bar" | "baz">( ...
  2881. pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
  2882. greedy: true,
  2883. inside: {
  2884. 'function': /^#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*/,
  2885. 'generic': {
  2886. pattern: /<[\s\S]+/, // everything after the first <
  2887. alias: 'class-name',
  2888. inside: typeInside
  2889. }
  2890. }
  2891. }
  2892. });
  2893. Prism.languages.ts = Prism.languages.typescript;
  2894. }(Prism));
  2895. (function (Prism) {
  2896. // https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
  2897. // https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
  2898. var anchorOrAlias = /[*&][^\s[\]{},]+/;
  2899. // https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
  2900. var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
  2901. // https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
  2902. var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|'
  2903. + anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)';
  2904. /**
  2905. *
  2906. * @param {string} value
  2907. * @param {string} [flags]
  2908. * @returns {RegExp}
  2909. */
  2910. function createValuePattern(value, flags) {
  2911. flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
  2912. var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|]|}|\s*#))/.source
  2913. .replace(/<<prop>>/g, function () { return properties; }).replace(/<<value>>/g, function () { return value; });
  2914. return RegExp(pattern, flags)
  2915. }
  2916. Prism.languages.yaml = {
  2917. 'scalar': {
  2918. pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)[^\r\n]+(?:\2[^\r\n]+)*)/.source
  2919. .replace(/<<prop>>/g, function () { return properties; })),
  2920. lookbehind: true,
  2921. alias: 'string'
  2922. },
  2923. 'comment': /#.*/,
  2924. 'key': {
  2925. pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)[^\r\n{[\]},#\s]+?(?=\s*:\s)/.source
  2926. .replace(/<<prop>>/g, function () { return properties; })),
  2927. lookbehind: true,
  2928. alias: 'atrule'
  2929. },
  2930. 'directive': {
  2931. pattern: /(^[ \t]*)%.+/m,
  2932. lookbehind: true,
  2933. alias: 'important'
  2934. },
  2935. 'datetime': {
  2936. pattern: createValuePattern(/\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*)?)?/.source),
  2937. lookbehind: true,
  2938. alias: 'number'
  2939. },
  2940. 'boolean': {
  2941. pattern: createValuePattern(/true|false/.source, 'i'),
  2942. lookbehind: true,
  2943. alias: 'important'
  2944. },
  2945. 'null': {
  2946. pattern: createValuePattern(/null|~/.source, 'i'),
  2947. lookbehind: true,
  2948. alias: 'important'
  2949. },
  2950. 'string': {
  2951. // \2 because of the lookbehind group
  2952. pattern: createValuePattern(/("|')(?:(?!\2)[^\\\r\n]|\\.)*\2/.source),
  2953. lookbehind: true,
  2954. greedy: true
  2955. },
  2956. 'number': {
  2957. pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+\.?\d*|\.?\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
  2958. lookbehind: true
  2959. },
  2960. 'tag': tag,
  2961. 'important': anchorOrAlias,
  2962. 'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
  2963. };
  2964. Prism.languages.yml = Prism.languages.yaml;
  2965. }(Prism));