| @@ -1,5 +1,5 @@ |
| 1 | 1 | /* PrismJS 1.25.0 |
| 2 | | −https://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 */ |
| 2 | +https://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 | 3 | /// <reference lib="WebWorker"/> |
| 4 | 4 | |
| 5 | 5 | var _self = (typeof window !== 'undefined') |
| @@ -21,7 +21,7 @@ var _self = (typeof window !== 'undefined') · 15 unmodified lines |
| 21 | 21 | var Prism = (function (_self) { |
| 22 | 22 | |
| 23 | 23 | // Private helper vars |
| 24 | | − var lang = /\blang(?:uage)?-([\w-]+)\b/i; |
| 24 | + var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i; |
| 25 | 25 | var uniqueId = 0; |
| 26 | 26 | |
| 27 | 27 | // The grammar object for plaintext |
| @@ -186,15 +186,33 @@ var Prism = (function (_self) { · 158 unmodified lines |
| 186 | 186 | * @returns {string} |
| 187 | 187 | */ |
| 188 | 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 | 194 | element = element.parentElement; |
| 191 | 195 | } |
| 192 | | − if (element) { |
| 193 | | − return (element.className.match(lang) || [, 'none'])[1].toLowerCase(); |
| 194 | | − } |
| 195 | 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 | 217 | * Returns the script element that is currently executing. |
| 200 | 218 | * |
| @@ -549,12 +567,12 @@ var Prism = (function (_self) { · 348 unmodified lines |
| 549 | 567 | var grammar = _.languages[language]; |
| 550 | 568 | |
| 551 | 569 | // 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 | 572 | // Set language on the parent, for styling |
| 555 | 573 | var parent = element.parentElement; |
| 556 | 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 | 578 | var code = element.textContent; |
| @@ -1843,7 +1861,7 @@ Prism.languages.js = Prism.languages.javascript; · 1282 unmodified lines |
| 1843 | 1861 | }, |
| 1844 | 1862 | 'variable': insideString.variable, |
| 1845 | 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 | 1865 | lookbehind: true |
| 1848 | 1866 | }, |
| 1849 | 1867 | 'keyword': { |
| @@ -1914,6 +1932,11 @@ Prism.languages.c = Prism.languages.extend('clike', { · 64 unmodified lines |
| 1914 | 1932 | pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/, |
| 1915 | 1933 | 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 | 1940 | 'class-name': { |
| 1918 | 1941 | pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/, |
| 1919 | 1942 | lookbehind: true |
| @@ -1924,6 +1947,14 @@ Prism.languages.c = Prism.languages.extend('clike', { · 4 unmodified lines |
| 1924 | 1947 | 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/ |
| 1925 | 1948 | }); |
| 1926 | 1949 | |
| 1950 | +Prism.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 | + |
| 1927 | 1958 | Prism.languages.insertBefore('c', 'string', { |
| 1928 | 1959 | 'macro': { |
| 1929 | 1960 | // allow for multiline macro definitions |
| @@ -1941,6 +1972,7 @@ Prism.languages.insertBefore('c', 'string', { · 11 unmodified lines |
| 1941 | 1972 | }, |
| 1942 | 1973 | Prism.languages.c['string'] |
| 1943 | 1974 | ], |
| 1975 | + 'char': Prism.languages.c['char'], |
| 1944 | 1976 | 'comment': Prism.languages.c['comment'], |
| 1945 | 1977 | 'macro-name': [ |
| 1946 | 1978 | { |
| @@ -1966,7 +1998,10 @@ Prism.languages.insertBefore('c', 'string', { · 19 unmodified lines |
| 1966 | 1998 | inside: Prism.languages.c |
| 1967 | 1999 | } |
| 1968 | 2000 | } |
| 1969 | | − }, |
| 2001 | + } |
| 2002 | +}); |
| 2003 | + |
| 2004 | +Prism.languages.insertBefore('c', 'function', { |
| 1970 | 2005 | // highlight predefined macros as constants |
| 1971 | 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 | 2244 | (function (Prism) { |
| 2210 | 2245 | Prism.languages.ruby = Prism.languages.extend('clike', { |
| 2211 | | − 'comment': [ |
| 2212 | | − /#.*/, |
| 2213 | | − { |
| 2214 | | − pattern: /^=begin\s[\s\S]*?^=end/m, |
| 2215 | | − greedy: true |
| 2216 | | − } |
| 2217 | | − ], |
| 2246 | + 'comment': { |
| 2247 | + pattern: /#.*|^=begin\s[\s\S]*?^=end/m, |
| 2248 | + greedy: true |
| 2249 | + }, |
| 2218 | 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 | 2252 | lookbehind: true, |
| 2221 | 2253 | inside: { |
| 2222 | 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 | 2269 | var interpolation = { |
| 2229 | | − pattern: /#\{[^}]+\}/, |
| 2270 | + pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/, |
| 2271 | + lookbehind: true, |
| 2230 | 2272 | inside: { |
| 2273 | + 'content': { |
| 2274 | + pattern: /^(#\{)[\s\S]+(?=\}$)/, |
| 2275 | + lookbehind: true, |
| 2276 | + inside: Prism.languages.ruby |
| 2277 | + }, |
| 2231 | 2278 | 'delimiter': { |
| 2232 | 2279 | pattern: /^#\{|\}$/, |
| 2233 | | − alias: 'tag' |
| 2234 | | − }, |
| 2235 | | − rest: Prism.languages.ruby |
| 2280 | + alias: 'punctuation' |
| 2281 | + } |
| 2236 | 2282 | } |
| 2237 | 2283 | }; |
| 2238 | 2284 | |
| 2239 | 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 | 2297 | Prism.languages.insertBefore('ruby', 'keyword', { |
| 2242 | | − 'regex': [ |
| 2298 | + 'regex-literal': [ |
| 2243 | 2299 | { |
| 2244 | | − pattern: RegExp(/%r/.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), |
| 2300 | + pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source), |
| 2252 | 2301 | greedy: true, |
| 2253 | 2302 | inside: { |
| 2254 | | − 'interpolation': interpolation |
| 2303 | + 'interpolation': interpolation, |
| 2304 | + 'regex': /[\s\S]+/ |
| 2255 | 2305 | } |
| 2256 | 2306 | }, |
| 2257 | 2307 | { |
| @@ -2259,134 +2309,176 @@ Prism.languages.cmake = { · 1 unmodified line |
| 2259 | 2309 | lookbehind: true, |
| 2260 | 2310 | greedy: true, |
| 2261 | 2311 | inside: { |
| 2262 | | − 'interpolation': interpolation |
| 2312 | + 'interpolation': interpolation, |
| 2313 | + 'regex': /[\s\S]+/ |
| 2263 | 2314 | } |
| 2264 | 2315 | } |
| 2265 | 2316 | ], |
| 2266 | 2317 | 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/, |
| 2267 | | − 'symbol': { |
| 2268 | | − pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/, |
| 2269 | | − lookbehind: true |
| 2270 | | − }, |
| 2318 | + 'symbol': [ |
| 2319 | + { |
| 2320 | + pattern: RegExp(/(^|[^:]):/.source + symbolName), |
| 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 | 2330 | 'method-definition': { |
| 2272 | | − pattern: /(\bdef\s+)[\w.]+/, |
| 2331 | + pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/, |
| 2273 | 2332 | lookbehind: true, |
| 2274 | 2333 | inside: { |
| 2275 | | − 'function': /\w+$/, |
| 2276 | | − rest: Prism.languages.ruby |
| 2334 | + 'function': /\b\w+$/, |
| 2335 | + 'keyword': /^self\b/, |
| 2336 | + 'class-name': /^\w+/, |
| 2337 | + 'punctuation': /\./ |
| 2277 | 2338 | } |
| 2278 | 2339 | } |
| 2279 | 2340 | }); |
| 2280 | 2341 | |
| 2281 | | − Prism.languages.insertBefore('ruby', 'number', { |
| 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/, |
| 2283 | | − 'constant': /\b[A-Z]\w*(?:[?!]|\b)/ |
| 2284 | | − }); |
| 2285 | | − |
| 2286 | | − Prism.languages.ruby.string = [ |
| 2287 | | − { |
| 2288 | | − pattern: RegExp(/%[qQiIwWxs]?/.source + '(?:' + [ |
| 2289 | | − /([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, |
| 2290 | | − /\((?:[^()\\]|\\[\s\S])*\)/.source, |
| 2291 | | − // Here we need to specifically allow interpolation |
| 2292 | | − /\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/.source, |
| 2293 | | − /\[(?:[^\[\]\\]|\\[\s\S])*\]/.source, |
| 2294 | | − /<(?:[^<>\\]|\\[\s\S])*>/.source |
| 2295 | | − ].join('|') + ')'), |
| 2296 | | − greedy: true, |
| 2297 | | − inside: { |
| 2298 | | − 'interpolation': interpolation |
| 2299 | | − } |
| 2300 | | − }, |
| 2301 | | − { |
| 2302 | | − pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/, |
| 2303 | | − greedy: true, |
| 2304 | | − inside: { |
| 2305 | | − 'interpolation': interpolation |
| 2342 | + Prism.languages.insertBefore('ruby', 'string', { |
| 2343 | + 'string-literal': [ |
| 2344 | + { |
| 2345 | + pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression), |
| 2346 | + greedy: true, |
| 2347 | + inside: { |
| 2348 | + 'interpolation': interpolation, |
| 2349 | + 'string': /[\s\S]+/ |
| 2350 | + } |
| 2351 | + }, |
| 2352 | + { |
| 2353 | + pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/, |
| 2354 | + greedy: true, |
| 2355 | + inside: { |
| 2356 | + 'interpolation': interpolation, |
| 2357 | + 'string': /[\s\S]+/ |
| 2358 | + } |
| 2359 | + }, |
| 2360 | + { |
| 2361 | + pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i, |
| 2362 | + alias: 'heredoc-string', |
| 2363 | + greedy: true, |
| 2364 | + inside: { |
| 2365 | + 'delimiter': { |
| 2366 | + 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 | | − }, |
| 2308 | | − { |
| 2309 | | − pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i, |
| 2310 | | − alias: 'heredoc-string', |
| 2311 | | − greedy: true, |
| 2312 | | − inside: { |
| 2313 | | − 'delimiter': { |
| 2314 | | − pattern: /^<<[-~]?[a-z_]\w*|[a-z_]\w*$/i, |
| 2315 | | − alias: 'symbol', |
| 2316 | | − inside: { |
| 2317 | | − 'punctuation': /^<<[-~]?/ |
| 2391 | + ], |
| 2392 | + 'command-literal': [ |
| 2393 | + { |
| 2394 | + pattern: RegExp(/%x/.source + percentExpression), |
| 2395 | + greedy: true, |
| 2396 | + inside: { |
| 2397 | + 'interpolation': interpolation, |
| 2398 | + 'command': { |
| 2399 | + pattern: /[\s\S]+/, |
| 2400 | + alias: 'string' |
| 2318 | 2401 | } |
| 2319 | | − }, |
| 2320 | | − 'interpolation': interpolation |
| 2321 | | − } |
| 2322 | | − }, |
| 2323 | | − { |
| 2324 | | − pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i, |
| 2325 | | − alias: 'heredoc-string', |
| 2326 | | − greedy: true, |
| 2327 | | − inside: { |
| 2328 | | − 'delimiter': { |
| 2329 | | − pattern: /^<<[-~]?'[a-z_]\w*'|[a-z_]\w*$/i, |
| 2330 | | − alias: 'symbol', |
| 2331 | | − inside: { |
| 2332 | | − 'punctuation': /^<<[-~]?'|'$/, |
| 2402 | + } |
| 2403 | + }, |
| 2404 | + { |
| 2405 | + pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/, |
| 2406 | + greedy: true, |
| 2407 | + inside: { |
| 2408 | + 'interpolation': interpolation, |
| 2409 | + 'command': { |
| 2410 | + pattern: /[\s\S]+/, |
| 2411 | + alias: 'string' |
| 2333 | 2412 | } |
| 2334 | 2413 | } |
| 2335 | 2414 | } |
| 2336 | | − } |
| 2337 | | − ]; |
| 2415 | + ] |
| 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 | 2425 | Prism.languages.rb = Prism.languages.ruby; |
| 2340 | 2426 | }(Prism)); |
| 2341 | 2427 | |
| 2342 | 2428 | (function (Prism) { |
| 2343 | 2429 | Prism.languages.crystal = Prism.languages.extend('ruby', { |
| 2344 | | − 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/, |
| 2430 | + 'keyword': [ |
| 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 | 2433 | pattern: /(\.\s*)(?:is_a|responds_to)\?/, |
| 2348 | 2434 | lookbehind: true |
| 2349 | 2435 | } |
| 2350 | 2436 | ], |
| 2351 | | − |
| 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/ |
| 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/, |
| 2438 | + 'operator': [ |
| 2439 | + /->/, |
| 2440 | + Prism.languages.ruby.operator, |
| 2441 | + ], |
| 2442 | + 'punctuation': /[(){}[\].,;\\]/, |
| 2353 | 2443 | }); |
| 2354 | 2444 | |
| 2355 | | − Prism.languages.insertBefore('crystal', 'string', { |
| 2356 | | − attribute: { |
| 2357 | | − pattern: /@\[.+?\]/, |
| 2358 | | − alias: 'attr-name', |
| 2445 | + Prism.languages.insertBefore('crystal', 'string-literal', { |
| 2446 | + 'attribute': { |
| 2447 | + pattern: /@\[.*?\]/, |
| 2359 | 2448 | inside: { |
| 2360 | | − delimiter: { |
| 2449 | + 'delimiter': { |
| 2361 | 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 | | − |
| 2368 | | − expansion: [ |
| 2369 | | − { |
| 2370 | | − pattern: /\{\{.+?\}\}/, |
| 2371 | | − inside: { |
| 2372 | | − delimiter: { |
| 2373 | | − pattern: /^\{\{|\}\}$/, |
| 2374 | | − alias: 'tag' |
| 2375 | | − }, |
| 2376 | | − rest: Prism.languages.crystal |
| 2377 | | − } |
| 2378 | | − }, |
| 2379 | | − { |
| 2380 | | − pattern: /\{%.+?%\}/, |
| 2381 | | − inside: { |
| 2382 | | − delimiter: { |
| 2383 | | − pattern: /^\{%|%\}$/, |
| 2384 | | − alias: 'tag' |
| 2385 | | − }, |
| 2386 | | − rest: Prism.languages.crystal |
| 2464 | + 'expansion': { |
| 2465 | + pattern: /\{(?:\{.*?\}|%.*?%)\}/, |
| 2466 | + inside: { |
| 2467 | + 'content': { |
| 2468 | + pattern: /^(\{.)[\s\S]+(?=.\}$)/, |
| 2469 | + lookbehind: true, |
| 2470 | + inside: Prism.languages.crystal |
| 2471 | + }, |
| 2472 | + 'delimiter': { |
| 2473 | + pattern: /^\{[\{%]|[\}%]\}$/, |
| 2474 | + alias: 'operator' |
| 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 | 2484 | }(Prism)); |
| @@ -2430,10 +2522,6 @@ Prism.languages.d = Prism.languages.extend('clike', { · 37 unmodified lines |
| 2430 | 2522 | // eslint-disable-next-line regexp/strict |
| 2431 | 2523 | /\bq"(.)[\s\S]*?\2"/.source, |
| 2432 | 2524 | |
| 2433 | | − // Characters |
| 2434 | | − // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot' |
| 2435 | | − /'(?:\\(?:\W|\w+)|[^\\])'/.source, |
| 2436 | | − |
| 2437 | 2525 | // eslint-disable-next-line regexp/strict |
| 2438 | 2526 | /(["`])(?:\\[\s\S]|(?!\3)[^\\])*\3[cwd]?/.source |
| 2439 | 2527 | ].join('|'), 'm'), |
| @@ -2462,6 +2550,12 @@ Prism.languages.d = Prism.languages.extend('clike', { · 22 unmodified lines |
| 2462 | 2550 | 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/ |
| 2463 | 2551 | }); |
| 2464 | 2552 | |
| 2553 | +Prism.languages.insertBefore('d', 'string', { |
| 2554 | + // Characters |
| 2555 | + // 'a', '\\', '\n', '\xFF', '\377', '\uFFFF', '\U0010FFFF', '\quot' |
| 2556 | + 'char': /'(?:\\(?:\W|\w+)|[^\\])'/ |
| 2557 | +}); |
| 2558 | + |
| 2465 | 2559 | Prism.languages.insertBefore('d', 'keyword', { |
| 2466 | 2560 | 'property': /\B@\w*/ |
| 2467 | 2561 | }); |
| @@ -2498,16 +2592,6 @@ Prism.languages.insertBefore('d', 'function', { · 30 unmodified lines |
| 2498 | 2592 | }; |
| 2499 | 2593 | |
| 2500 | 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 | 2595 | 'class-name': [ |
| 2512 | 2596 | className, |
| 2513 | 2597 | { |
| @@ -2522,10 +2606,32 @@ Prism.languages.insertBefore('d', 'function', { · 8 unmodified lines |
| 2522 | 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 | 2632 | 'metadata': { |
| 2527 | 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 | |
| 2940 | 3046 | Prism.languages.go = Prism.languages.extend('clike', { |
| 2941 | 3047 | 'string': { |
| 2942 | | − pattern: /(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/, |
| 3048 | + pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/, |
| 3049 | + lookbehind: true, |
| 2943 | 3050 | greedy: true |
| 2944 | 3051 | }, |
| 2945 | 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 | 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 | 3062 | 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, |
| 2949 | 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 | + |
| 3066 | +Prism.languages.insertBefore('go', 'string', { |
| 3067 | + 'char': { |
| 3068 | + pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/, |
| 3069 | + greedy: true |
| 3070 | + } |
| 3071 | +}); |
| 3072 | + |
| 2951 | 3073 | delete Prism.languages.go['class-name']; |
| 2952 | 3074 | |
| 2953 | 3075 | Prism.languages.groovy = Prism.languages.extend('clike', { |
| @@ -3042,6 +3164,11 @@ Prism.hooks.add('wrap', function (env) { · 88 unmodified lines |
| 3042 | 3164 | }; |
| 3043 | 3165 | |
| 3044 | 3166 | Prism.languages.java = Prism.languages.extend('clike', { |
| 3167 | + 'string': { |
| 3168 | + pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/, |
| 3169 | + lookbehind: true, |
| 3170 | + greedy: true |
| 3171 | + }, |
| 3045 | 3172 | 'class-name': [ |
| 3046 | 3173 | className, |
| 3047 | 3174 | { |
| @@ -3073,6 +3200,10 @@ Prism.hooks.add('wrap', function (env) { · 25 unmodified lines |
| 3073 | 3200 | pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/, |
| 3074 | 3201 | greedy: true, |
| 3075 | 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 | 3275 | greedy: true |
| 3145 | 3276 | }, |
| 3146 | 3277 | 'string': { |
| 3147 | | − // https://docs.julialang.org/en/v1/manual/strings/#man-characters-1 |
| 3148 | 3278 | // https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1 |
| 3149 | 3279 | // https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1 |
| 3150 | 3280 | // 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 | 3287 | lookbehind: true, |
| 3153 | 3288 | greedy: true |
| 3154 | 3289 | }, |
| @@ -3187,19 +3322,60 @@ Prism.languages.julia = { · 32 unmodified lines |
| 3187 | 3322 | |
| 3188 | 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 | 3336 | Prism.languages.insertBefore('kotlin', 'string', { |
| 3191 | | − 'raw-string': { |
| 3192 | | − pattern: /("""|''')[\s\S]*?\1/, |
| 3193 | | − alias: 'string' |
| 3194 | | − // See interpolation below |
| 3337 | + // https://kotlinlang.org/spec/expressions.html#string-interpolation-expressions |
| 3338 | + 'string-literal': [ |
| 3339 | + { |
| 3340 | + 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 | 3372 | Prism.languages.insertBefore('kotlin', 'keyword', { |
| 3198 | 3373 | 'annotation': { |
| 3199 | 3374 | pattern: /\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/, |
| 3200 | 3375 | alias: 'builtin' |
| 3201 | 3376 | } |
| 3202 | 3377 | }); |
| 3378 | + |
| 3203 | 3379 | Prism.languages.insertBefore('kotlin', 'function', { |
| 3204 | 3380 | 'label': { |
| 3205 | 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 | 3386 | Prism.languages.kt = Prism.languages.kotlin; |
| 3232 | 3387 | Prism.languages.kts = Prism.languages.kotlin; |
| 3233 | 3388 | }(Prism)); |
| @@ -3342,7 +3497,8 @@ Prism.languages.matlab = { · 108 unmodified lines |
| 3342 | 3497 | Prism.languages.nginx = { |
| 3343 | 3498 | 'comment': { |
| 3344 | 3499 | pattern: /(^|[\s{};])#.*/, |
| 3345 | | − lookbehind: true |
| 3500 | + lookbehind: true, |
| 3501 | + greedy: true |
| 3346 | 3502 | }, |
| 3347 | 3503 | 'directive': { |
| 3348 | 3504 | pattern: /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/, |
| @@ -3352,6 +3508,7 @@ Prism.languages.matlab = { · 3 unmodified lines |
| 3352 | 3508 | 'string': { |
| 3353 | 3509 | pattern: /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/, |
| 3354 | 3510 | lookbehind: true, |
| 3511 | + greedy: true, |
| 3355 | 3512 | inside: { |
| 3356 | 3513 | 'escape': { |
| 3357 | 3514 | pattern: /\\["'\\nrt]/, |
| @@ -3389,23 +3546,29 @@ Prism.languages.matlab = { · 31 unmodified lines |
| 3389 | 3546 | }(Prism)); |
| 3390 | 3547 | |
| 3391 | 3548 | Prism.languages.nim = { |
| 3392 | | − 'comment': /#.*/, |
| 3393 | | − // Double-quoted strings can be prefixed by an identifier (Generalized raw string literals) |
| 3394 | | − // Character literals are handled specifically to prevent issues with numeric type suffixes |
| 3549 | + 'comment': { |
| 3550 | + pattern: /#.*/, |
| 3551 | + greedy: true |
| 3552 | + }, |
| 3395 | 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 | 3556 | greedy: true |
| 3398 | 3557 | }, |
| 3399 | | − // The negative look ahead prevents wrong highlighting of the .. operator |
| 3400 | | − 'number': /\b(?:0[xXoObB][\da-fA-F_]+|\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:[eE][+-]?\d[\d_]*)?)(?:'?[iuf]\d*)?/, |
| 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/, |
| 3558 | + 'char': { |
| 3559 | + // Character literals are handled specifically to prevent issues with numeric type suffixes |
| 3560 | + pattern: /'(?:\\(?:\d+|x[\da-fA-F]{0,2}|.)|[^'])'/, |
| 3561 | + greedy: true |
| 3562 | + }, |
| 3563 | + |
| 3402 | 3564 | 'function': { |
| 3403 | 3565 | pattern: /(?:(?!\d)(?:\w|\\x[89a-fA-F][0-9a-fA-F])+|`[^`\r\n]+`)\*?(?:\[[^\]]+\])?(?=\s*\()/, |
| 3566 | + greedy: true, |
| 3404 | 3567 | inside: { |
| 3405 | 3568 | 'operator': /\*$/ |
| 3406 | 3569 | } |
| 3407 | 3570 | }, |
| 3408 | | − // We don't want to highlight operators inside backticks |
| 3571 | + // We don't want to highlight operators (and anything really) inside backticks |
| 3409 | 3572 | 'identifier': { |
| 3410 | 3573 | pattern: /`[^`\r\n]+`/, |
| 3411 | 3574 | greedy: true, |
| @@ -3413,6 +3576,10 @@ Prism.languages.nim = { · 1 unmodified line |
| 3413 | 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 | 3583 | 'operator': { |
| 3417 | 3584 | // Look behind and look ahead prevent wrong highlighting of punctuations [. .] {. .} (. .) |
| 3418 | 3585 | // but allow the slice operator .. to take precedence over them |
| @@ -3423,26 +3590,42 @@ Prism.languages.nim = { · 4 unmodified lines |
| 3423 | 3590 | 'punctuation': /[({\[]\.|\.[)}\]]|[`(){}\[\],:]/ |
| 3424 | 3591 | }; |
| 3425 | 3592 | |
| 3593 | +// https://ocaml.org/manual/lex.html |
| 3594 | + |
| 3426 | 3595 | Prism.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 | 3604 | 'string': [ |
| 3429 | 3605 | { |
| 3430 | | − pattern: /"(?:\\.|[^\\\r\n"])*"/, |
| 3606 | + pattern: /"(?:\\(?:[\s\S]|\r\n)|[^\\\r\n"])*"/, |
| 3431 | 3607 | 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 | 3611 | 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 | 3622 | 'directive': { |
| 3440 | 3623 | pattern: /\B#\w+/, |
| 3441 | | − alias: 'important' |
| 3624 | + alias: 'property' |
| 3442 | 3625 | }, |
| 3443 | 3626 | 'label': { |
| 3444 | 3627 | pattern: /\B~\w+/, |
| 3445 | | − alias: 'function' |
| 3628 | + alias: 'property' |
| 3446 | 3629 | }, |
| 3447 | 3630 | 'type-variable': { |
| 3448 | 3631 | pattern: /\B'\w+/, |
| @@ -3450,212 +3633,178 @@ Prism.languages.ocaml = { · 1 unmodified line |
| 3450 | 3633 | }, |
| 3451 | 3634 | 'variant': { |
| 3452 | 3635 | pattern: /`\w+/, |
| 3453 | | − alias: 'variable' |
| 3454 | | − }, |
| 3455 | | − 'module': { |
| 3456 | | − pattern: /\b[A-Z]\w+/, |
| 3457 | | − alias: 'variable' |
| 3636 | + alias: 'symbol' |
| 3458 | 3637 | }, |
| 3459 | 3638 | // For the list of keywords and operators, |
| 3460 | 3639 | // see: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#sec84 |
| 3461 | 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 | 3641 | 'boolean': /\b(?:false|true)\b/, |
| 3642 | + |
| 3643 | + 'operator-like-punctuation': { |
| 3644 | + pattern: /\[[<>|]|[>|]\]|\{<|>\}/, |
| 3645 | + alias: 'punctuation' |
| 3646 | + }, |
| 3463 | 3647 | // Custom operators are allowed |
| 3464 | | − 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/, |
| 3465 | | − 'punctuation': /[(){}\[\].,:;]|\b_\b/ |
| 3648 | + 'operator': /\.[.~]|:[=>]|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/, |
| 3649 | + 'punctuation': /;;|::|[(){}\[\].,:;#]|\b_\b/ |
| 3466 | 3650 | }; |
| 3467 | 3651 | |
| 3468 | | −Prism.languages.perl = { |
| 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 | | − }, |
| 3652 | +(function (Prism) { |
| 3549 | 3653 | |
| 3550 | | − // m{...} |
| 3551 | | − { |
| 3552 | | − pattern: /\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/, |
| 3553 | | − greedy: true |
| 3554 | | − }, |
| 3654 | + var brackets = /(?:\((?:[^()\\]|\\[\s\S])*\)|\{(?:[^{}\\]|\\[\s\S])*\}|\[(?:[^[\]\\]|\\[\s\S])*\]|<(?:[^<>\\]|\\[\s\S])*>)/.source; |
| 3555 | 3655 | |
| 3556 | | − // m[...] |
| 3557 | | − { |
| 3558 | | − pattern: /\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/, |
| 3559 | | − greedy: true |
| 3560 | | − }, |
| 3656 | + Prism.languages.perl = { |
| 3657 | + 'comment': [ |
| 3658 | + { |
| 3659 | + // POD |
| 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<...> |
| 3563 | | − { |
| 3564 | | − pattern: /\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/, |
| 3565 | | − greedy: true |
| 3566 | | − }, |
| 3695 | + // "...", `...` |
| 3696 | + { |
| 3697 | + pattern: /("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/, |
| 3698 | + greedy: true |
| 3699 | + }, |
| 3567 | 3700 | |
| 3568 | | − // The lookbehinds prevent -s from breaking |
| 3569 | | − // FIXME We don't handle change of separator like s(...)[...] |
| 3570 | | − // s/.../.../ |
| 3571 | | − { |
| 3572 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/, |
| 3573 | | − lookbehind: true, |
| 3574 | | − greedy: true |
| 3575 | | − }, |
| 3701 | + // '...' |
| 3702 | + // FIXME Multi-line single-quoted strings are not supported as they would break variables containing ' |
| 3703 | + { |
| 3704 | + pattern: /'(?:[^'\\\r\n]|\\.)*'/, |
| 3705 | + greedy: true |
| 3706 | + } |
| 3707 | + ], |
| 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...a |
| 3578 | | − { |
| 3579 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/, |
| 3580 | | − lookbehind: true, |
| 3581 | | − greedy: true |
| 3582 | | − }, |
| 3733 | + // The lookbehinds prevent -s from breaking |
| 3734 | + { |
| 3735 | + pattern: RegExp( |
| 3736 | + /(^|[^-])\b(?:s|tr|y)(?![a-zA-Z0-9])\s*/.source + |
| 3737 | + '(?:' + |
| 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(...)(...) |
| 3585 | | − { |
| 3586 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/, |
| 3587 | | − lookbehind: true, |
| 3588 | | − greedy: true |
| 3589 | | − }, |
| 3761 | + // /.../ |
| 3762 | + // The look-ahead tries to prevent two divisions on |
| 3763 | + // the same line from being highlighted as regex. |
| 3764 | + // This does not support multi-line regex. |
| 3765 | + { |
| 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{...}{...} |
| 3592 | | − { |
| 3593 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/, |
| 3594 | | − lookbehind: true, |
| 3595 | | − greedy: true |
| 3771 | + // FIXME Not sure about the handling of ::, ', and # |
| 3772 | + 'variable': [ |
| 3773 | + // ${^POSTMATCH} |
| 3774 | + /[&*$@%]\{\^[A-Z]+\}/, |
| 3775 | + // $^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 | | − |
| 3598 | | − // s[...][...] |
| 3599 | | − { |
| 3600 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/, |
| 3601 | | − lookbehind: true, |
| 3602 | | − greedy: true |
| 3792 | + 'v-string': { |
| 3793 | + // v1.2, 1.2.3 |
| 3794 | + pattern: /v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/, |
| 3795 | + alias: 'string' |
| 3603 | 3796 | }, |
| 3604 | | − |
| 3605 | | − // s<...><...> |
| 3606 | | − { |
| 3607 | | − pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/, |
| 3608 | | − lookbehind: true, |
| 3609 | | − greedy: true |
| 3797 | + 'function': { |
| 3798 | + pattern: /(\bsub[ \t]+)\w+/, |
| 3799 | + lookbehind: 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 | | − // /.../ |
| 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 | | −}; |
| 3807 | +}(Prism)); |
| 3659 | 3808 | |
| 3660 | 3809 | /** |
| 3661 | 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 |
| 4003 | 4152 | Prism.languages.python = { |
| 4004 | 4153 | 'comment': { |
| 4005 | 4154 | pattern: /(^|[^\\])#.*/, |
| 4006 | | − lookbehind: true |
| 4155 | + lookbehind: true, |
| 4156 | + greedy: true |
| 4007 | 4157 | }, |
| 4008 | 4158 | 'string-interpolation': { |
| 4009 | 4159 | pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i, |
| @@ -4132,6 +4282,7 @@ Prism.languages.r = { · 122 unmodified lines |
| 4132 | 4282 | 'script': { |
| 4133 | 4283 | // Allow for two levels of nesting |
| 4134 | 4284 | pattern: re(/=<BRACES>/.source), |
| 4285 | + alias: 'language-javascript', |
| 4135 | 4286 | inside: { |
| 4136 | 4287 | 'script-punctuation': { |
| 4137 | 4288 | pattern: /^=(?=\{)/, |
| @@ -4139,7 +4290,6 @@ Prism.languages.r = { · 1 unmodified line |
| 4139 | 4290 | }, |
| 4140 | 4291 | rest: Prism.languages.jsx |
| 4141 | 4292 | }, |
| 4142 | | − 'alias': 'language-javascript' |
| 4143 | 4293 | } |
| 4144 | 4294 | }, Prism.languages.jsx.tag); |
| 4145 | 4295 | |
| @@ -4263,8 +4413,7 @@ Prism.languages.r = { · 117 unmodified lines |
| 4263 | 4413 | }, |
| 4264 | 4414 | 'char': { |
| 4265 | 4415 | pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/, |
| 4266 | | − greedy: true, |
| 4267 | | − alias: 'string' |
| 4416 | + greedy: true |
| 4268 | 4417 | }, |
| 4269 | 4418 | 'attribute': { |
| 4270 | 4419 | pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/, |
| @@ -4307,7 +4456,7 @@ Prism.languages.r = { · 36 unmodified lines |
| 4307 | 4456 | alias: 'function' |
| 4308 | 4457 | }, |
| 4309 | 4458 | 'type-definition': { |
| 4310 | | − pattern: /(\b(?:enum|struct|union)\s+)\w+/, |
| 4459 | + pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/, |
| 4311 | 4460 | lookbehind: true, |
| 4312 | 4461 | alias: 'class-name' |
| 4313 | 4462 | }, |
| @@ -4695,3 +4844,105 @@ Prism.languages.sql = { · 381 unmodified lines |
| 4695 | 4844 | |
| 4696 | 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 | + |