History

Add Zig documentation (0.9.0)

Simon Legner committed 4 years ago

Commit 4ed22db1 parent b1963549 files · +705 −376Browse files

Showing the changes to assets/javascripts (3 of 9 files). Show all

Unified · Split

3 files
  1. assets/javascripts/news.json +5 −1
  2. assets/javascripts/templates/pages/about_tmpl.coffee +4 −0
  3. assets/javascripts/vendor/prism.js +628 −377
assets/javascripts/news.json+5−1
@@ -1,7 +1,11 @@
1[1[
2 [
3 "2021-12-27",
4 "New documentation: <a href=\"/zig/\">Zig</a>"
5 ],
2 [6 [
3 "2021-12-26",7 "2021-12-26",
4 "New documentation: <a href=\"/gnu_make/\">Gnu Make</a>"8 "New documentation: <a href=\"/gnu_make/\">GNU Make</a>"
5 ],9 ],
6 [10 [
7 "2021-12-07",11 "2021-12-07",
assets/javascripts/templates/pages/about_tmpl.coffee+4−0
@@ -918,5 +918,9 @@ credits = [ · 917 unmodified lines
918 'BSD',918 'BSD',
919 'https://raw.githubusercontent.com/yiisoft/yii/master/LICENSE'919 'https://raw.githubusercontent.com/yiisoft/yii/master/LICENSE'
920 ], [920 ], [
921 'Zig',
922 '2015–2021, Zig contributors',
923 'MIT',
924 'https://raw.githubusercontent.com/ziglang/zig/master/LICENSE'
921 ]925 ]
922]926]
assets/javascripts/vendor/prism.js+628−377
@@ -1,5 +1,5 @@
1/* PrismJS 1.25.01/* PrismJS 1.25.0
2https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+cpp+cmake+coffeescript+crystal+d+dart+diff+django+elixir+erlang+go+groovy+java+json+julia+kotlin+latex+lua+markup-templating+matlab+nginx+nim+ocaml+perl+php+python+r+jsx+ruby+rust+scss+shell-session+sql+typescript+yaml */2https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+bash+c+cpp+cmake+coffeescript+crystal+d+dart+diff+django+elixir+erlang+go+groovy+java+json+julia+kotlin+latex+lua+markup-templating+matlab+nginx+nim+ocaml+perl+php+python+r+jsx+ruby+rust+scss+shell-session+sql+typescript+yaml+zig */
3/// <reference lib="WebWorker"/>3/// <reference lib="WebWorker"/>
4 4
5var _self = (typeof window !== 'undefined')5var _self = (typeof window !== 'undefined')
@@ -21,7 +21,7 @@ var _self = (typeof window !== 'undefined') · 15 unmodified lines
21var Prism = (function (_self) {21var Prism = (function (_self) {
22 22
23 // Private helper vars23 // Private helper vars
24 var lang = /\blang(?:uage)?-([\w-]+)\b/i;24 var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
25 var uniqueId = 0;25 var uniqueId = 0;
26 26
27 // The grammar object for plaintext27 // The grammar object for plaintext
@@ -186,15 +186,33 @@ var Prism = (function (_self) { · 158 unmodified lines
186 * @returns {string}186 * @returns {string}
187 */187 */
188 getLanguage: function (element) {188 getLanguage: function (element) {
189 while (element && !lang.test(element.className)) {189 while (element) {
190 var m = lang.exec(element.className);
191 if (m) {
192 return m[1].toLowerCase();
193 }
190 element = element.parentElement;194 element = element.parentElement;
191 }195 }
192 if (element) {
193 return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
194 }
195 return 'none';196 return 'none';
196 },197 },
197 198
199 /**
200 * Sets the Prism `language-xxxx` class of the given element.
201 *
202 * @param {Element} element
203 * @param {string} language
204 * @returns {void}
205 */
206 setLanguage: function (element, language) {
207 // remove all `language-xxxx` classes
208 // (this might leave behind a leading space)
209 element.className = element.className.replace(RegExp(lang, 'gi'), '');
210
211 // add the new `language-xxxx` class
212 // (using `classList` will automatically clean up spaces for us)
213 element.classList.add('language-' + language);
214 },
215
198 /**216 /**
199 * Returns the script element that is currently executing.217 * Returns the script element that is currently executing.
200 *218 *
@@ -549,12 +567,12 @@ var Prism = (function (_self) { · 348 unmodified lines
549 var grammar = _.languages[language];567 var grammar = _.languages[language];
550 568
551 // Set language on the element, if not present569 // Set language on the element, if not present
552 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;570 _.util.setLanguage(element, language);
553 571
554 // Set language on the parent, for styling572 // Set language on the parent, for styling
555 var parent = element.parentElement;573 var parent = element.parentElement;
556 if (parent && parent.nodeName.toLowerCase() === 'pre') {574 if (parent && parent.nodeName.toLowerCase() === 'pre') {
557 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;575 _.util.setLanguage(parent, language);
558 }576 }
559 577
560 var code = element.textContent;578 var code = element.textContent;
@@ -1843,7 +1861,7 @@ Prism.languages.js = Prism.languages.javascript; · 1282 unmodified lines
1843 },1861 },
1844 'variable': insideString.variable,1862 'variable': insideString.variable,
1845 'function': {1863 'function': {
1846 pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|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;|&])/,1864 pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|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|docker|docker-compose|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|podman|podman-compose|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|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
1847 lookbehind: true1865 lookbehind: true
1848 },1866 },
1849 'keyword': {1867 'keyword': {
@@ -1914,6 +1932,11 @@ Prism.languages.c = Prism.languages.extend('clike', { · 64 unmodified lines
1914 pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,1932 pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
1915 greedy: true1933 greedy: true
1916 },1934 },
1935 'string': {
1936 // https://en.cppreference.com/w/c/language/string_literal
1937 pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
1938 greedy: true
1939 },
1917 'class-name': {1940 'class-name': {
1918 pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,1941 pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
1919 lookbehind: true1942 lookbehind: true
@@ -1924,6 +1947,14 @@ Prism.languages.c = Prism.languages.extend('clike', { · 4 unmodified lines
1924 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/1947 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
1925});1948});
1926 1949
1950Prism.languages.insertBefore('c', 'string', {
1951 'char': {
1952 // https://en.cppreference.com/w/c/language/character_constant
1953 pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
1954 greedy: true
1955 }
1956});
1957
1927Prism.languages.insertBefore('c', 'string', {1958Prism.languages.insertBefore('c', 'string', {
1928 'macro': {1959 'macro': {
1929 // allow for multiline macro definitions1960 // allow for multiline macro definitions
@@ -1941,6 +1972,7 @@ Prism.languages.insertBefore('c', 'string', { · 11 unmodified lines
1941 },1972 },
1942 Prism.languages.c['string']1973 Prism.languages.c['string']
1943 ],1974 ],
1975 'char': Prism.languages.c['char'],
1944 'comment': Prism.languages.c['comment'],1976 'comment': Prism.languages.c['comment'],
1945 'macro-name': [1977 'macro-name': [
1946 {1978 {
@@ -1966,7 +1998,10 @@ Prism.languages.insertBefore('c', 'string', { · 19 unmodified lines
1966 inside: Prism.languages.c1998 inside: Prism.languages.c
1967 }1999 }
1968 }2000 }
1969 },2001 }
2002});
2003
2004Prism.languages.insertBefore('c', 'function', {
1970 // highlight predefined macros as constants2005 // highlight predefined macros as constants
1971 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/2006 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
1972});2007});
@@ -2208,50 +2243,65 @@ Prism.languages.cmake = { · 235 unmodified lines
2208 */2243 */
2209(function (Prism) {2244(function (Prism) {
2210 Prism.languages.ruby = Prism.languages.extend('clike', {2245 Prism.languages.ruby = Prism.languages.extend('clike', {
2211 'comment': [2246 'comment': {
2212 /#.*/,2247 pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
2213 {2248 greedy: true
2214 pattern: /^=begin\s[\s\S]*?^=end/m,2249 },
2215 greedy: true
2216 }
2217 ],
2218 'class-name': {2250 'class-name': {
2219 pattern: /(\b(?:class)\s+|\bcatch\s+\()[\w.\\]+/i,2251 pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
2220 lookbehind: true,2252 lookbehind: true,
2221 inside: {2253 inside: {
2222 'punctuation': /[.\\]/2254 'punctuation': /[.\\]/
2223 }2255 }
2224 },2256 },
2225 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/2257 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
2258 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
2259 'punctuation': /[(){}[\].,;]/,
2260 });
2261
2262 Prism.languages.insertBefore('ruby', 'operator', {
2263 'double-colon': {
2264 pattern: /::/,
2265 alias: 'punctuation'
2266 },
2226 });2267 });
2227 2268
2228 var interpolation = {2269 var interpolation = {
2229 pattern: /#\{[^}]+\}/,2270 pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
2271 lookbehind: true,
2230 inside: {2272 inside: {
2273 'content': {
2274 pattern: /^(#\{)[\s\S]+(?=\}$)/,
2275 lookbehind: true,
2276 inside: Prism.languages.ruby
2277 },
2231 'delimiter': {2278 'delimiter': {
2232 pattern: /^#\{|\}$/,2279 pattern: /^#\{|\}$/,
2233 alias: 'tag'2280 alias: 'punctuation'
2234 },2281 }
2235 rest: Prism.languages.ruby
2236 }2282 }
2237 };2283 };
2238 2284
2239 delete Prism.languages.ruby.function;2285 delete Prism.languages.ruby.function;
2240 2286
2287 var percentExpression = '(?:' + [
2288 /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2289 /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
2290 /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
2291 /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
2292 /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
2293 ].join('|') + ')';
2294
2295 var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
2296
2241 Prism.languages.insertBefore('ruby', 'keyword', {2297 Prism.languages.insertBefore('ruby', 'keyword', {
2242 'regex': [2298 'regex-literal': [
2243 {2299 {
2244 pattern: RegExp(/%r/.source + '(?:' + [2300 pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
2245 /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
2246 /\((?:[^()\\]|\\[\s\S])*\)/.source,
2247 // Here we need to specifically allow interpolation
2248 /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,
2249 /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,
2250 /<(?:[^<>\\]|\\[\s\S])*>/.source
2251 ].join('|') + ')' + /[egimnosux]{0,6}/.source),
2252 greedy: true,2301 greedy: true,
2253 inside: {2302 inside: {
2254 'interpolation': interpolation2303 'interpolation': interpolation,
2304 'regex': /[\s\S]+/
2255 }2305 }
2256 },2306 },
2257 {2307 {
@@ -2259,134 +2309,176 @@ Prism.languages.cmake = { · 1 unmodified line
2259 lookbehind: true,2309 lookbehind: true,
2260 greedy: true,2310 greedy: true,
2261 inside: {2311 inside: {
2262 'interpolation': interpolation2312 'interpolation': interpolation,
2313 'regex': /[\s\S]+/
2263 }2314 }
2264 }2315 }
2265 ],2316 ],
2266 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,2317 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
2267 'symbol': {2318 'symbol': [
2268 pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,2319 {
2269 lookbehind: true2320 pattern: RegExp(/(^|[^:]):/.source + symbolName),
2270 },2321 lookbehind: true,
2322 greedy: true
2323 },
2324 {
2325 pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
2326 lookbehind: true,
2327 greedy: true
2328 },
2329 ],
2271 'method-definition': {2330 'method-definition': {
2272 pattern: /(\bdef\s+)[\w.]+/,2331 pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
2273 lookbehind: true,2332 lookbehind: true,
2274 inside: {2333 inside: {
2275 'function': /\w+$/,2334 'function': /\b\w+$/,
2276 rest: Prism.languages.ruby2335 'keyword': /^self\b/,
2336 'class-name': /^\w+/,
2337 'punctuation': /\./
2277 }2338 }
2278 }2339 }
2279 });2340 });
2280 2341
2281 Prism.languages.insertBefore('ruby', 'number', {2342 Prism.languages.insertBefore('ruby', 'string', {
2282 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,2343 'string-literal': [
2283 'constant': /\b[A-Z]\w*(?:[?!]|\b)/2344 {
2284 });2345 pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
2285 2346 greedy: true,
2286 Prism.languages.ruby.string = [2347 inside: {
2287 {2348 'interpolation': interpolation,
2288 pattern: RegExp(/%[qQiIwWxs]?/.source + '(?:' + [2349 'string': /[\s\S]+/
2289 /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,2350 }
2290 /\((?:[^()\\]|\\[\s\S])*\)/.source,2351 },
2291 // Here we need to specifically allow interpolation2352 {
2292 /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source,2353 pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
2293 /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source,2354 greedy: true,
2294 /<(?:[^<>\\]|\\[\s\S])*>/.source2355 inside: {
2295 ].join('|') + ')'),2356 'interpolation': interpolation,
2296 greedy: true,2357 'string': /[\s\S]+/
2297 inside: {2358 }
2298 'interpolation': interpolation2359 },
2299 }2360 {
2300 },2361 pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2301 {2362 alias: 'heredoc-string',
2302 pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,2363 greedy: true,
2303 greedy: true,2364 inside: {
2304 inside: {2365 'delimiter': {
2305 'interpolation': interpolation2366 pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
2367 inside: {
2368 'symbol': /\b\w+/,
2369 'punctuation': /^<<[-~]?/
2370 }
2371 },
2372 'interpolation': interpolation,
2373 'string': /[\s\S]+/
2374 }
2375 },
2376 {
2377 pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
2378 alias: 'heredoc-string',
2379 greedy: true,
2380 inside: {
2381 'delimiter': {
2382 pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
2383 inside: {
2384 'symbol': /\b\w+/,
2385 'punctuation': /^<<[-~]?'|'$/,
2386 }
2387 },
2388 'string': /[\s\S]+/
2389 }
2306 }2390 }
2307 },2391 ],
2308 {2392 'command-literal': [
2309 pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,2393 {
2310 alias: 'heredoc-string',2394 pattern: RegExp(/%x/.source + percentExpression),
2311 greedy: true,2395 greedy: true,
2312 inside: {2396 inside: {
2313 'delimiter': {2397 'interpolation': interpolation,
2314 pattern: /^<<[-~]?[a-z_]\w*|[a-z_]\w*$/i,2398 'command': {
2315 alias: 'symbol',2399 pattern: /[\s\S]+/,
2316 inside: {2400 alias: 'string'
2317 'punctuation': /^<<[-~]?/
2318 }2401 }
2319 },2402 }
2320 'interpolation': interpolation2403 },
2321 }2404 {
2322 },2405 pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
2323 {2406 greedy: true,
2324 pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,2407 inside: {
2325 alias: 'heredoc-string',2408 'interpolation': interpolation,
2326 greedy: true,2409 'command': {
2327 inside: {2410 pattern: /[\s\S]+/,
2328 'delimiter': {2411 alias: 'string'
2329 pattern: /^<<[-~]?'[a-z_]\w*'|[a-z_]\w*$/i,
2330 alias: 'symbol',
2331 inside: {
2332 'punctuation': /^<<[-~]?'|'$/,
2333 }2412 }
2334 }2413 }
2335 }2414 }
2336 }2415 ]
2337 ];2416 });
2417
2418 delete Prism.languages.ruby.string;
2419
2420 Prism.languages.insertBefore('ruby', 'number', {
2421 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
2422 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
2423 });
2338 2424
2339 Prism.languages.rb = Prism.languages.ruby;2425 Prism.languages.rb = Prism.languages.ruby;
2340}(Prism));2426}(Prism));
2341 2427
2342(function (Prism) {2428(function (Prism) {
2343 Prism.languages.crystal = Prism.languages.extend('ruby', {2429 Prism.languages.crystal = Prism.languages.extend('ruby', {
2344 keyword: [2430 'keyword': [
2345 /\b(?:__DIR__|__END_LINE__|__FILE__|__LINE__|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|require|rescue|return|select|self|sizeof|struct|super|then|type|typeof|uninitialized|union|unless|until|when|while|with|yield)\b/,2431 /\b(?:__DIR__|__END_LINE__|__FILE__|__LINE__|abstract|alias|annotation|as|asm|begin|break|case|class|def|do|else|elsif|end|ensure|enum|extend|for|fun|if|ifdef|include|instance_sizeof|lib|macro|module|next|of|out|pointerof|private|protected|ptr|require|rescue|return|select|self|sizeof|struct|super|then|type|typeof|undef|uninitialized|union|unless|until|when|while|with|yield)\b/,
2346 {2432 {
2347 pattern: /(\.\s*)(?:is_a|responds_to)\?/,2433 pattern: /(\.\s*)(?:is_a|responds_to)\?/,
2348 lookbehind: true2434 lookbehind: true
2349 }2435 }
2350 ],2436 ],
2351 2437 '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/,
2352 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/2438 'operator': [
2439 /->/,
2440 Prism.languages.ruby.operator,
2441 ],
2442 'punctuation': /[(){}[\].,;\\]/,
2353 });2443 });
2354 2444
2355 Prism.languages.insertBefore('crystal', 'string', {2445 Prism.languages.insertBefore('crystal', 'string-literal', {
2356 attribute: {2446 'attribute': {
2357 pattern: /@\[.+?\]/,2447 pattern: /@\[.*?\]/,
2358 alias: 'attr-name',
2359 inside: {2448 inside: {
2360 delimiter: {2449 'delimiter': {
2361 pattern: /^@\[|\]$/,2450 pattern: /^@\[|\]$/,
2362 alias: 'tag'2451 alias: 'punctuation'
2452 },
2453 'attribute': {
2454 pattern: /^(\s*)\w+/,
2455 lookbehind: true,
2456 alias: 'class-name'
2457 },
2458 'args': {
2459 pattern: /\S(?:[\s\S]*\S)?/,
2460 inside: Prism.languages.crystal
2363 },2461 },
2364 rest: Prism.languages.crystal
2365 }2462 }
2366 },2463 },
2367 2464 'expansion': {
2368 expansion: [2465 pattern: /\{(?:\{.*?\}|%.*?%)\}/,
2369 {2466 inside: {
2370 pattern: /\{\{.+?\}\}/,2467 'content': {
2371 inside: {2468 pattern: /^(\{.)[\s\S]+(?=.\}$)/,
2372 delimiter: {2469 lookbehind: true,
2373 pattern: /^\{\{|\}\}$/,2470 inside: Prism.languages.crystal
2374 alias: 'tag'2471 },
2375 },2472 'delimiter': {
2376 rest: Prism.languages.crystal2473 pattern: /^\{[\{%]|[\}%]\}$/,
2377 }2474 alias: 'operator'
2378 },
2379 {
2380 pattern: /\{%.+?%\}/,
2381 inside: {
2382 delimiter: {
2383 pattern: /^\{%|%\}$/,
2384 alias: 'tag'
2385 },
2386 rest: Prism.languages.crystal
2387 }2475 }
2388 }2476 }
2389 ]2477 },
2478 'char': {
2479 pattern: /'(?:[^\\\r\n]{1,2}|\\(?:.|u(?:[A-Fa-f0-9]{1,4}|\{[A-Fa-f0-9]{1,6}\})))'/,
2480 greedy: true
2481 }
2390 });2482 });
2391 2483
2392}(Prism));2484}(Prism));
@@ -2430,10 +2522,6 @@ Prism.languages.d = Prism.languages.extend('clike', { · 37 unmodified lines
2430 // eslint-disable-next-line regexp/strict2522 // eslint-disable-next-line regexp/strict
2431 /\bq"(.)[\s\S]*?\2"/.source,2523 /\bq"(.)[\s\S]*?\2"/.source,
2432 2524
2433 // Characters
2434 // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
2435 /'(?:\\(?:\W|\w+)|[^\\])'/.source,
2436
2437 // eslint-disable-next-line regexp/strict2525 // eslint-disable-next-line regexp/strict
2438 /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source2526 /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source
2439 ].join('|'), 'm'),2527 ].join('|'), 'm'),
@@ -2462,6 +2550,12 @@ Prism.languages.d = Prism.languages.extend('clike', { · 22 unmodified lines
2462 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/2550 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/
2463});2551});
2464 2552
2553Prism.languages.insertBefore('d', 'string', {
2554 // Characters
2555 // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot'
2556 'char': /'(?:\\(?:\W|\w+)|[^\\])'/
2557});
2558
2465Prism.languages.insertBefore('d', 'keyword', {2559Prism.languages.insertBefore('d', 'keyword', {
2466 'property': /\B@\w*/2560 'property': /\B@\w*/
2467});2561});
@@ -2498,16 +2592,6 @@ Prism.languages.insertBefore('d', 'function', { · 30 unmodified lines
2498 };2592 };
2499 2593
2500 Prism.languages.dart = Prism.languages.extend('clike', {2594 Prism.languages.dart = Prism.languages.extend('clike', {
2501 'string': [
2502 {
2503 pattern: /r?("""|''')[\s\S]*?\1/,
2504 greedy: true
2505 },
2506 {
2507 pattern: /r?(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
2508 greedy: true
2509 }
2510 ],
2511 'class-name': [2595 'class-name': [
2512 className,2596 className,
2513 {2597 {
@@ -2522,10 +2606,32 @@ Prism.languages.insertBefore('d', 'function', { · 8 unmodified lines
2522 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/2606 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/
2523 });2607 });
2524 2608
2525 Prism.languages.insertBefore('dart', 'function', {2609 Prism.languages.insertBefore('dart', 'string', {
2610 'string-literal': {
2611 pattern: /r?(?:("""|''')[\s\S]*?\1|(["'])(?:\\.|(?!\2)[^\\\r\n])*\2(?!\2))/,
2612 greedy: true,
2613 inside: {
2614 'interpolation': {
2615 pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\w+|\{(?:[^{}]|\{[^{}]*\})*\})/,
2616 lookbehind: true,
2617 inside: {
2618 'punctuation': /^\$\{?|\}$/,
2619 'expression': {
2620 pattern: /[\s\S]+/,
2621 inside: Prism.languages.dart
2622 }
2623 }
2624 },
2625 'string': /[\s\S]+/
2626 }
2627 },
2628 'string': undefined
2629 });
2630
2631 Prism.languages.insertBefore('dart', 'class-name', {
2526 'metadata': {2632 'metadata': {
2527 pattern: /@\w+/,2633 pattern: /@\w+/,
2528 alias: 'symbol'2634 alias: 'function'
2529 }2635 }
2530 });2636 });
2531 2637
@@ -2939,15 +3045,31 @@ Prism.languages.erlang = { · 407 unmodified lines
2939 3045
2940Prism.languages.go = Prism.languages.extend('clike', {3046Prism.languages.go = Prism.languages.extend('clike', {
2941 'string': {3047 'string': {
2942 pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/,3048 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
3049 lookbehind: true,
2943 greedy: true3050 greedy: true
2944 },3051 },
2945 '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/,3052 '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/,
2946 'boolean': /\b(?:_|false|iota|nil|true)\b/,3053 'boolean': /\b(?:_|false|iota|nil|true)\b/,
2947 'number': /(?:\b0x[a-f\d]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[-+]?\d+)?)i?/i,3054 'number': [
3055 // binary and octal integers
3056 /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
3057 // hexadecimal integers and floats
3058 /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
3059 // decimal integers and floats
3060 /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
3061 ],
2948 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,3062 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
2949 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/3063 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
2950});3064});
3065
3066Prism.languages.insertBefore('go', 'string', {
3067 'char': {
3068 pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
3069 greedy: true
3070 }
3071});
3072
2951delete Prism.languages.go['class-name'];3073delete Prism.languages.go['class-name'];
2952 3074
2953Prism.languages.groovy = Prism.languages.extend('clike', {3075Prism.languages.groovy = Prism.languages.extend('clike', {
@@ -3042,6 +3164,11 @@ Prism.hooks.add('wrap', function (env) { · 88 unmodified lines
3042 };3164 };
3043 3165
3044 Prism.languages.java = Prism.languages.extend('clike', {3166 Prism.languages.java = Prism.languages.extend('clike', {
3167 'string': {
3168 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
3169 lookbehind: true,
3170 greedy: true
3171 },
3045 'class-name': [3172 'class-name': [
3046 className,3173 className,
3047 {3174 {
@@ -3073,6 +3200,10 @@ Prism.hooks.add('wrap', function (env) { · 25 unmodified lines
3073 pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,3200 pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
3074 greedy: true,3201 greedy: true,
3075 alias: 'string'3202 alias: 'string'
3203 },
3204 'char': {
3205 pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
3206 greedy: true
3076 }3207 }
3077 });3208 });
3078 3209
@@ -3144,11 +3275,15 @@ Prism.languages.julia = { · 65 unmodified lines
3144 greedy: true3275 greedy: true
3145 },3276 },
3146 'string': {3277 'string': {
3147 // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
3148 // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-13278 // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
3149 // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-13279 // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
3150 // https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-13280 // https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
3151 pattern: /"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'|`(?:[^\\`\r\n]|\\.)*`/,3281 pattern: /"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|`(?:[^\\`\r\n]|\\.)*`/,
3282 greedy: true
3283 },
3284 'char': {
3285 // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
3286 pattern: /(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'/,
3152 lookbehind: true,3287 lookbehind: true,
3153 greedy: true3288 greedy: true
3154 },3289 },
@@ -3187,19 +3322,60 @@ Prism.languages.julia = { · 32 unmodified lines
3187 3322
3188 delete Prism.languages.kotlin['class-name'];3323 delete Prism.languages.kotlin['class-name'];
3189 3324
3325 var interpolationInside = {
3326 'interpolation-punctuation': {
3327 pattern: /^\$\{?|\}$/,
3328 alias: 'punctuation'
3329 },
3330 'expression': {
3331 pattern: /[\s\S]+/,
3332 inside: Prism.languages.kotlin
3333 }
3334 };
3335
3190 Prism.languages.insertBefore('kotlin', 'string', {3336 Prism.languages.insertBefore('kotlin', 'string', {
3191 'raw-string': {3337 // https://kotlinlang.org/spec/expressions.html#string-interpolation-expressions
3192 pattern: /("""|''')[\s\S]*?\1/,3338 'string-literal': [
3193 alias: 'string'3339 {
3194 // See interpolation below3340 pattern: /"""(?:[^$]|\$(?:(?!\{)|\{[^{}]*\}))*?"""/,
3341 alias: 'multiline',
3342 inside: {
3343 'interpolation': {
3344 pattern: /\$(?:[a-z_]\w*|\{[^{}]*\})/i,
3345 inside: interpolationInside
3346 },
3347 'string': /[\s\S]+/
3348 }
3349 },
3350 {
3351 pattern: /"(?:[^"\\\r\n$]|\\.|\$(?:(?!\{)|\{[^{}]*\}))*"/,
3352 alias: 'singleline',
3353 inside: {
3354 'interpolation': {
3355 pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:[a-z_]\w*|\{[^{}]*\})/i,
3356 lookbehind: true,
3357 inside: interpolationInside
3358 },
3359 'string': /[\s\S]+/
3360 }
3361 }
3362 ],
3363 'char': {
3364 // https://kotlinlang.org/spec/expressions.html#character-literals
3365 pattern: /'(?:[^'\\\r\n]|\\(?:.|u[a-fA-F0-9]{0,4}))'/,
3366 greedy: true
3195 }3367 }
3196 });3368 });
3369
3370 delete Prism.languages.kotlin['string'];
3371
3197 Prism.languages.insertBefore('kotlin', 'keyword', {3372 Prism.languages.insertBefore('kotlin', 'keyword', {
3198 'annotation': {3373 'annotation': {
3199 pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,3374 pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,
3200 alias: 'builtin'3375 alias: 'builtin'
3201 }3376 }
3202 });3377 });
3378
3203 Prism.languages.insertBefore('kotlin', 'function', {3379 Prism.languages.insertBefore('kotlin', 'function', {
3204 'label': {3380 'label': {
3205 pattern: /\b\w+@|@\w+\b/,3381 pattern: /\b\w+@|@\w+\b/,
@@ -3207,27 +3383,6 @@ Prism.languages.julia = { · 1 unmodified line
3207 }3383 }
3208 });3384 });
3209 3385
3210 var interpolation = [
3211 {
3212 pattern: /\$\{[^}]+\}/,
3213 inside: {
3214 'delimiter': {
3215 pattern: /^\$\{|\}$/,
3216 alias: 'variable'
3217 },
3218 rest: Prism.languages.kotlin
3219 }
3220 },
3221 {
3222 pattern: /\$\w+/,
3223 alias: 'variable'
3224 }
3225 ];
3226
3227 Prism.languages.kotlin['string'].inside = Prism.languages.kotlin['raw-string'].inside = {
3228 interpolation: interpolation
3229 };
3230
3231 Prism.languages.kt = Prism.languages.kotlin;3386 Prism.languages.kt = Prism.languages.kotlin;
3232 Prism.languages.kts = Prism.languages.kotlin;3387 Prism.languages.kts = Prism.languages.kotlin;
3233}(Prism));3388}(Prism));
@@ -3342,7 +3497,8 @@ Prism.languages.matlab = { · 108 unmodified lines
3342 Prism.languages.nginx = {3497 Prism.languages.nginx = {
3343 'comment': {3498 'comment': {
3344 pattern: /(^|[\s{};])#.*/,3499 pattern: /(^|[\s{};])#.*/,
3345 lookbehind: true3500 lookbehind: true,
3501 greedy: true
3346 },3502 },
3347 'directive': {3503 'directive': {
3348 pattern: /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/,3504 pattern: /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/,
@@ -3352,6 +3508,7 @@ Prism.languages.matlab = { · 3 unmodified lines
3352 'string': {3508 'string': {
3353 pattern: /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,3509 pattern: /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,
3354 lookbehind: true,3510 lookbehind: true,
3511 greedy: true,
3355 inside: {3512 inside: {
3356 'escape': {3513 'escape': {
3357 pattern: /\\["'\\nrt]/,3514 pattern: /\\["'\\nrt]/,
@@ -3389,23 +3546,29 @@ Prism.languages.matlab = { · 31 unmodified lines
3389}(Prism));3546}(Prism));
3390 3547
3391Prism.languages.nim = {3548Prism.languages.nim = {
3392 'comment': /#.*/,3549 'comment': {
3393 // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)3550 pattern: /#.*/,
3394 // Character literals are handled specifically to prevent issues with numeric type suffixes3551 greedy: true
3552 },
3395 'string': {3553 'string': {
3396 pattern: /(?:(?:\b(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")|'(?:\\(?:\d+|x[\da-fA-F]{2}|.)|[^'])')/,3554 // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals)
3555 pattern: /(?:\b(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+)?(?:"""[\s\S]*?"""(?!")|"(?:\\[\s\S]|""|[^"\\])*")/,
3397 greedy: true3556 greedy: true
3398 },3557 },
3399 // The negative look ahead prevents wrong highlighting of the .. operator3558 'char': {
3400 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,3559 // Character literals are handled specifically to prevent issues with numeric type suffixes
3401 '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/,3560 pattern: /'(?:\\(?:\d+|x[\da-fA-F]{0,2}|.)|[^'])'/,
3561 greedy: true
3562 },
3563
3402 'function': {3564 'function': {
3403 pattern: /(?:(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,3565 pattern: /(?:(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/,
3566 greedy: true,
3404 inside: {3567 inside: {
3405 'operator': /\*$/3568 'operator': /\*$/
3406 }3569 }
3407 },3570 },
3408 // We don't want to highlight operators inside backticks3571 // We don't want to highlight operators (and anything really) inside backticks
3409 'identifier': {3572 'identifier': {
3410 pattern: /`[^`\r\n]+`/,3573 pattern: /`[^`\r\n]+`/,
3411 greedy: true,3574 greedy: true,
@@ -3413,6 +3576,10 @@ Prism.languages.nim = { · 1 unmodified line
3413 'punctuation': /`/3576 'punctuation': /`/
3414 }3577 }
3415 },3578 },
3579
3580 // The negative look ahead prevents wrong highlighting of the .. operator
3581 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/,
3582 '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/,
3416 'operator': {3583 'operator': {
3417 // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)3584 // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .)
3418 // but allow the slice operator .. to take precedence over them3585 // but allow the slice operator .. to take precedence over them
@@ -3423,26 +3590,42 @@ Prism.languages.nim = { · 4 unmodified lines
3423 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/3590 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/
3424};3591};
3425 3592
3593// https://ocaml.org/manual/lex.html
3594
3426Prism.languages.ocaml = {3595Prism.languages.ocaml = {
3427 'comment': /\(\*[\s\S]*?\*\)/,3596 'comment': {
3597 pattern: /\(\*[\s\S]*?\*\)/,
3598 greedy: true
3599 },
3600 'char': {
3601 pattern: /'(?:[^\\\r\n']|\\(?:.|[ox]?[0-9a-f]{1,3}))'/i,
3602 greedy: true
3603 },
3428 'string': [3604 'string': [
3429 {3605 {
3430 pattern: /"(?:\\.|[^\\\r\n"])*"/,3606 pattern: /"(?:\\(?:[\s\S]|\r\n)|[^\\\r\n"])*"/,
3431 greedy: true3607 greedy: true
3432 },3608 },
3433 {3609 {
3434 pattern: /(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,3610 pattern: /\{([a-z_]*)\|[\s\S]*?\|\1\}/,
3435 greedy: true3611 greedy: true
3436 }3612 }
3437 ],3613 ],
3438 'number': /\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?[\d_]+)?)/i,3614 'number': [
3615 // binary and octal
3616 /\b(?:0b[01][01_]*|0o[0-7][0-7_]*)\b/i,
3617 // hexadecimal
3618 /\b0x[a-f0-9][a-f0-9_]*(?:\.[a-f0-9_]*)?(?:p[+-]?\d[\d_]*)?(?!\w)/i,
3619 // decimal
3620 /\b\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?\d[\d_]*)?(?!\w)/i,
3621 ],
3439 'directive': {3622 'directive': {
3440 pattern: /\B#\w+/,3623 pattern: /\B#\w+/,
3441 alias: 'important'3624 alias: 'property'
3442 },3625 },
3443 'label': {3626 'label': {
3444 pattern: /\B~\w+/,3627 pattern: /\B~\w+/,
3445 alias: 'function'3628 alias: 'property'
3446 },3629 },
3447 'type-variable': {3630 'type-variable': {
3448 pattern: /\B'\w+/,3631 pattern: /\B'\w+/,
@@ -3450,212 +3633,178 @@ Prism.languages.ocaml = { · 1 unmodified line
3450 },3633 },
3451 'variant': {3634 'variant': {
3452 pattern: /`\w+/,3635 pattern: /`\w+/,
3453 alias: 'variable'3636 alias: 'symbol'
3454 },
3455 'module': {
3456 pattern: /\b[A-Z]\w+/,
3457 alias: 'variable'
3458 },3637 },
3459 // For the list of keywords and operators,3638 // For the list of keywords and operators,
3460 // see: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sec843639 // see: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sec84
3461 '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/,3640 '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/,
3462 'boolean': /\b(?:false|true)\b/,3641 'boolean': /\b(?:false|true)\b/,
3642
3643 'operator-like-punctuation': {
3644 pattern: /\[[<>|]|[>|]\]|\{<|>\}/,
3645 alias: 'punctuation'
3646 },
3463 // Custom operators are allowed3647 // Custom operators are allowed
3464 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,3648 'operator': /\.[.~]|:[=>]|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,
3465 'punctuation': /[(){}\[\].,:;]|\b_\b/3649 'punctuation': /;;|::|[(){}\[\].,:;#]|\b_\b/
3466};3650};
3467 3651
3468Prism.languages.perl = {3652(function (Prism) {
3469 'comment': [
3470 {
3471 // POD
3472 pattern: /(^\s*)=\w[\s\S]*?=cut.*/m,
3473 lookbehind: true
3474 },
3475 {
3476 pattern: /(^|[^\\$])#.*/,
3477 lookbehind: true
3478 }
3479 ],
3480 // TODO Could be nice to handle Heredoc too.
3481 'string': [
3482 // q/.../
3483 {
3484 pattern: /\b(?:q|qq|qw|qx)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
3485 greedy: true
3486 },
3487
3488 // q a...a
3489 {
3490 pattern: /\b(?:q|qq|qw|qx)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,
3491 greedy: true
3492 },
3493
3494 // q(...)
3495 {
3496 pattern: /\b(?:q|qq|qw|qx)\s*\((?:[^()\\]|\\[\s\S])*\)/,
3497 greedy: true
3498 },
3499
3500 // q{...}
3501 {
3502 pattern: /\b(?:q|qq|qw|qx)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
3503 greedy: true
3504 },
3505
3506 // q[...]
3507 {
3508 pattern: /\b(?:q|qq|qw|qx)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
3509 greedy: true
3510 },
3511
3512 // q<...>
3513 {
3514 pattern: /\b(?:q|qq|qw|qx)\s*<(?:[^<>\\]|\\[\s\S])*>/,
3515 greedy: true
3516 },
3517
3518 // "...", `...`
3519 {
3520 pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
3521 greedy: true
3522 },
3523
3524 // '...'
3525 // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
3526 {
3527 pattern: /'(?:[^'\\\r\n]|\\.)*'/,
3528 greedy: true
3529 }
3530 ],
3531 'regex': [
3532 // m/.../
3533 {
3534 pattern: /\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
3535 greedy: true
3536 },
3537
3538 // m a...a
3539 {
3540 pattern: /\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,
3541 greedy: true
3542 },
3543
3544 // m(...)
3545 {
3546 pattern: /\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
3547 greedy: true
3548 },
3549 3653
3550 // m{...}3654 var brackets = /(?:\((?:[^()\\]|\\[\s\S])*\)|\{(?:[^{}\\]|\\[\s\S])*\}|\[(?:[^[\]\\]|\\[\s\S])*\]|<(?:[^<>\\]|\\[\s\S])*>)/.source;
3551 {
3552 pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
3553 greedy: true
3554 },
3555 3655
3556 // m[...]3656 Prism.languages.perl = {
3557 {3657 'comment': [
3558 pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,3658 {
3559 greedy: true3659 // POD
3560 },3660 pattern: /(^\s*)=\w[\s\S]*?=cut.*/m,
3661 lookbehind: true,
3662 greedy: true
3663 },
3664 {
3665 pattern: /(^|[^\\$])#.*/,
3666 lookbehind: true,
3667 greedy: true
3668 }
3669 ],
3670 // TODO Could be nice to handle Heredoc too.
3671 'string': [
3672 {
3673 pattern: RegExp(
3674 /\b(?:q|qq|qw|qx)(?![a-zA-Z0-9])\s*/.source +
3675 '(?:' +
3676 [
3677 // q/.../
3678 /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
3679
3680 // q a...a
3681 // eslint-disable-next-line regexp/strict
3682 /([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
3683
3684 // q(...)
3685 // q{...}
3686 // q[...]
3687 // q<...>
3688 brackets,
3689 ].join('|') +
3690 ')'
3691 ),
3692 greedy: true
3693 },
3561 3694
3562 // m<...>3695 // "...", `...`
3563 {3696 {
3564 pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,3697 pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,
3565 greedy: true3698 greedy: true
3566 },3699 },
3567 3700
3568 // The lookbehinds prevent -s from breaking3701 // '...'
3569 // FIXME We don't handle change of separator like s(...)[...]3702 // FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
3570 // s/.../.../3703 {
3571 {3704 pattern: /'(?:[^'\\\r\n]|\\.)*'/,
3572 pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,3705 greedy: true
3573 lookbehind: true,3706 }
3574 greedy: true3707 ],
3575 },3708 'regex': [
3709 {
3710 pattern: RegExp(
3711 /\b(?:m|qr)(?![a-zA-Z0-9])\s*/.source +
3712 '(?:' +
3713 [
3714 // m/.../
3715 /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
3716
3717 // m a...a
3718 // eslint-disable-next-line regexp/strict
3719 /([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
3720
3721 // m(...)
3722 // m{...}
3723 // m[...]
3724 // m<...>
3725 brackets,
3726 ].join('|') +
3727 ')' +
3728 /[msixpodualngc]*/.source
3729 ),
3730 greedy: true
3731 },
3576 3732
3577 // s a...a...a3733 // The lookbehinds prevent -s from breaking
3578 {3734 {
3579 pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,3735 pattern: RegExp(
3580 lookbehind: true,3736 /(^|[^-])\b(?:s|tr|y)(?![a-zA-Z0-9])\s*/.source +
3581 greedy: true3737 '(?:' +
3582 },3738 [
3739 // s/.../.../
3740 // eslint-disable-next-line regexp/strict
3741 /([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2/.source,
3742
3743 // s a...a...a
3744 // eslint-disable-next-line regexp/strict
3745 /([a-zA-Z0-9])(?:(?!\3)[^\\]|\\[\s\S])*\3(?:(?!\3)[^\\]|\\[\s\S])*\3/.source,
3746
3747 // s(...)(...)
3748 // s{...}{...}
3749 // s[...][...]
3750 // s<...><...>
3751 // s(...)[...]
3752 brackets + /\s*/.source + brackets,
3753 ].join('|') +
3754 ')' +
3755 /[msixpodualngcer]*/.source
3756 ),
3757 lookbehind: true,
3758 greedy: true
3759 },
3583 3760
3584 // s(...)(...)3761 // /.../
3585 {3762 // The look-ahead tries to prevent two divisions on
3586 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,3763 // the same line from being highlighted as regex.
3587 lookbehind: true,3764 // This does not support multi-line regex.
3588 greedy: true3765 {
3589 },3766 pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|x|xor)\b))/,
3767 greedy: true
3768 }
3769 ],
3590 3770
3591 // s{...}{...}3771 // FIXME Not sure about the handling of ::, ', and #
3592 {3772 'variable': [
3593 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,3773 // ${^POSTMATCH}
3594 lookbehind: true,3774 /[&*$@%]\{\^[A-Z]+\}/,
3595 greedy: true3775 // $^V
3776 /[&*$@%]\^[A-Z_]/,
3777 // ${...}
3778 /[&*$@%]#?(?=\{)/,
3779 // $foo
3780 /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+(?![\w$]))+(?:::)*/,
3781 // $1
3782 /[&*$@%]\d+/,
3783 // $_, @_, %!
3784 // The negative lookahead prevents from breaking the %= operator
3785 /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
3786 ],
3787 'filehandle': {
3788 // <>, <FOO>, _
3789 pattern: /<(?![<=])\S*?>|\b_\b/,
3790 alias: 'symbol'
3596 },3791 },
3597 3792 'v-string': {
3598 // s[...][...]3793 // v1.2, 1.2.3
3599 {3794 pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
3600 pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,3795 alias: 'string'
3601 lookbehind: true,
3602 greedy: true
3603 },3796 },
3604 3797 'function': {
3605 // s<...><...>3798 pattern: /(\bsub[ \t]+)\w+/,
3606 {3799 lookbehind: true
3607 pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
3608 lookbehind: true,
3609 greedy: true
3610 },3800 },
3801 '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/,
3802 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
3803 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)\b/,
3804 'punctuation': /[{}[\];(),:]/
3805 };
3611 3806
3612 // /.../3807}(Prism));
3613 // The look-ahead tries to prevent two divisions on
3614 // the same line from being highlighted as regex.
3615 // This does not support multi-line regex.
3616 {
3617 pattern: /\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|x|xor)\b))/,
3618 greedy: true
3619 }
3620 ],
3621
3622 // FIXME Not sure about the handling of ::, ', and #
3623 'variable': [
3624 // ${^POSTMATCH}
3625 /[&*$@%]\{\^[A-Z]+\}/,
3626 // $^V
3627 /[&*$@%]\^[A-Z_]/,
3628 // ${...}
3629 /[&*$@%]#?(?=\{)/,
3630 // $foo
3631 /[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+(?![\w$]))+(?:::)*/,
3632 // $1
3633 /[&*$@%]\d+/,
3634 // $_, @_, %!
3635 // The negative lookahead prevents from breaking the %= operator
3636 /(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
3637 ],
3638 'filehandle': {
3639 // <>, <FOO>, _
3640 pattern: /<(?![<=])\S*>|\b_\b/,
3641 alias: 'symbol'
3642 },
3643 'vstring': {
3644 // v1.2, 1.2.3
3645 pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,
3646 alias: 'string'
3647 },
3648 'function': {
3649 pattern: /sub \w+/i,
3650 inside: {
3651 keyword: /sub/
3652 }
3653 },
3654 '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/,
3655 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,
3656 'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)\b/,
3657 'punctuation': /[{}[\];(),:]/
3658};
3659 3808
3660/**3809/**
3661 * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/3810 * Original by Aaron Harun: http://aahacreative.com/2012/07/31/php-syntax-highlighting-prism/
@@ -4003,7 +4152,8 @@ Prism.languages.perl = { · 341 unmodified lines
4003Prism.languages.python = {4152Prism.languages.python = {
4004 'comment': {4153 'comment': {
4005 pattern: /(^|[^\\])#.*/,4154 pattern: /(^|[^\\])#.*/,
4006 lookbehind: true4155 lookbehind: true,
4156 greedy: true
4007 },4157 },
4008 'string-interpolation': {4158 'string-interpolation': {
4009 pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,4159 pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
@@ -4132,6 +4282,7 @@ Prism.languages.r = { · 122 unmodified lines
4132 'script': {4282 'script': {
4133 // Allow for two levels of nesting4283 // Allow for two levels of nesting
4134 pattern: re(/=<BRACES>/.source),4284 pattern: re(/=<BRACES>/.source),
4285 alias: 'language-javascript',
4135 inside: {4286 inside: {
4136 'script-punctuation': {4287 'script-punctuation': {
4137 pattern: /^=(?=\{)/,4288 pattern: /^=(?=\{)/,
@@ -4139,7 +4290,6 @@ Prism.languages.r = { · 1 unmodified line
4139 },4290 },
4140 rest: Prism.languages.jsx4291 rest: Prism.languages.jsx
4141 },4292 },
4142 'alias': 'language-javascript'
4143 }4293 }
4144 }, Prism.languages.jsx.tag);4294 }, Prism.languages.jsx.tag);
4145 4295
@@ -4263,8 +4413,7 @@ Prism.languages.r = { · 117 unmodified lines
4263 },4413 },
4264 'char': {4414 'char': {
4265 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,4415 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
4266 greedy: true,4416 greedy: true
4267 alias: 'string'
4268 },4417 },
4269 'attribute': {4418 'attribute': {
4270 pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,4419 pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
@@ -4307,7 +4456,7 @@ Prism.languages.r = { · 36 unmodified lines
4307 alias: 'function'4456 alias: 'function'
4308 },4457 },
4309 'type-definition': {4458 'type-definition': {
4310 pattern: /(\b(?:enum|struct|union)\s+)\w+/,4459 pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
4311 lookbehind: true,4460 lookbehind: true,
4312 alias: 'class-name'4461 alias: 'class-name'
4313 },4462 },
@@ -4695,3 +4844,105 @@ Prism.languages.sql = { · 381 unmodified lines
4695 4844
4696}(Prism));4845}(Prism));
4697 4846
4847(function (Prism) {
4848
4849 function literal(str) {
4850 return function () { return str; };
4851 }
4852
4853 var keyword = /\b(?:align|allowzero|and|anyframe|anytype|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|nakedcc|noalias|nosuspend|null|or|orelse|packed|promise|pub|resume|return|stdcallcc|struct|suspend|switch|test|threadlocal|try|undefined|union|unreachable|usingnamespace|var|volatile|while)\b/;
4854
4855 var IDENTIFIER = '\\b(?!' + keyword.source + ')(?!\\d)\\w+\\b';
4856 var ALIGN = /align\s*\((?:[^()]|\([^()]*\))*\)/.source;
4857 var PREFIX_TYPE_OP = /(?:\?|\bpromise->|(?:\[[^[\]]*\]|\*(?!\*)|\*\*)(?:\s*<ALIGN>|\s*const\b|\s*volatile\b|\s*allowzero\b)*)/.source.replace(/<ALIGN>/g, literal(ALIGN));
4858 var SUFFIX_EXPR = /(?:\bpromise\b|(?:\berror\.)?<ID>(?:\.<ID>)*(?!\s+<ID>))/.source.replace(/<ID>/g, literal(IDENTIFIER));
4859 var TYPE = '(?!\\s)(?:!?\\s*(?:' + PREFIX_TYPE_OP + '\\s*)*' + SUFFIX_EXPR + ')+';
4860
4861 /*
4862 * A simplified grammar for Zig compile time type literals:
4863 *
4864 * TypeExpr = ( "!"? PREFIX_TYPE_OP* SUFFIX_EXPR )+
4865 *
4866 * SUFFIX_EXPR = ( \b "promise" \b | ( \b "error" "." )? IDENTIFIER ( "." IDENTIFIER )* (?! \s+ IDENTIFIER ) )
4867 *
4868 * PREFIX_TYPE_OP = "?"
4869 * | \b "promise" "->"
4870 * | ( "[" [^\[\]]* "]" | "*" | "**" ) ( ALIGN | "const" \b | "volatile" \b | "allowzero" \b )*
4871 *
4872 * ALIGN = "align" "(" ( [^()] | "(" [^()]* ")" )* ")"
4873 *
4874 * IDENTIFIER = \b (?! KEYWORD ) [a-zA-Z_] \w* \b
4875 *
4876 */
4877
4878 Prism.languages.zig = {
4879 'comment': [
4880 {
4881 pattern: /\/\/[/!].*/,
4882 alias: 'doc-comment'
4883 },
4884 /\/{2}.*/
4885 ],
4886 'string': [
4887 {
4888 // "string" and c"string"
4889 pattern: /(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/,
4890 lookbehind: true,
4891 greedy: true
4892 },
4893 {
4894 // multiline strings and c-strings
4895 pattern: /([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/,
4896 lookbehind: true,
4897 greedy: true
4898 }
4899 ],
4900 'char': {
4901 // characters 'a', '\n', '\xFF', '\u{10FFFF}'
4902 pattern: /(^|[^\\])'(?:[^'\\\r\n]|[\uD800-\uDFFF]{2}|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,
4903 lookbehind: true,
4904 greedy: true
4905 },
4906 'builtin': /\B@(?!\d)\w+(?=\s*\()/,
4907 'label': {
4908 pattern: /(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/,
4909 lookbehind: true
4910 },
4911 'class-name': [
4912 // const Foo = struct {};
4913 /\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/,
4914 {
4915 // const x: i32 = 9;
4916 // var x: Bar;
4917 // fn foo(x: bool, y: f32) void {}
4918 pattern: RegExp(/(:\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?[=;,)])|<TYPE>(?=\s*(?:<ALIGN>\s*)?\{)/.source.replace(/<TYPE>/g, literal(TYPE)).replace(/<ALIGN>/g, literal(ALIGN))),
4919 lookbehind: true,
4920 inside: null // see below
4921 },
4922 {
4923 // extern fn foo(x: f64) f64; (optional alignment)
4924 pattern: RegExp(/(\)\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?;)/.source.replace(/<TYPE>/g, literal(TYPE)).replace(/<ALIGN>/g, literal(ALIGN))),
4925 lookbehind: true,
4926 inside: null // see below
4927 }
4928 ],
4929 'builtin-type': {
4930 pattern: /\b(?:anyerror|bool|c_u?(?:int|long|longlong|short)|c_longdouble|c_void|comptime_(?:float|int)|f(?:16|32|64|128)|[iu](?:8|16|32|64|128|size)|noreturn|type|void)\b/,
4931 alias: 'keyword'
4932 },
4933 'keyword': keyword,
4934 'function': /\b(?!\d)\w+(?=\s*\()/,
4935 'number': /\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+(?:\.[a-fA-F\d]*)?(?:[pP][+-]?[a-fA-F\d]+)?|\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)\b/,
4936 'boolean': /\b(?:false|true)\b/,
4937 'operator': /\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/,
4938 'punctuation': /[.:,;(){}[\]]/
4939 };
4940
4941 Prism.languages.zig['class-name'].forEach(function (obj) {
4942 if (obj.inside === null) {
4943 obj.inside = Prism.languages.zig;
4944 }
4945 });
4946
4947}(Prism));
4948