Skip to content

Commit

Permalink
Update Prism to 1.29.0
Browse files Browse the repository at this point in the history
There are now 297 (from 290) syntaxes supported.

*   Add `bbj`, `bqn`, `cilkc`, `cilkcpp`, `gradle`, `metafont`, `wgsl`,

See: <https://github.com/PrismJS/prism/blob/master/CHANGELOG.md#1290-2022-08-23>
  • Loading branch information
wooorm committed Aug 23, 2022
1 parent 40494b8 commit 82394d3
Show file tree
Hide file tree
Showing 21 changed files with 466 additions and 19 deletions.
9 changes: 4 additions & 5 deletions lang/asciidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function asciidoc(Prism) {
}
var asciidoc = (Prism.languages.asciidoc = {
'comment-block': {
pattern: /^(\/{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1/m,
pattern: /^(\/{4,})$[\s\S]*?^\1/m,
alias: 'comment'
},
table: {
Expand All @@ -50,22 +50,21 @@ export default function asciidoc(Prism) {
}
},
'passthrough-block': {
pattern: /^(\+{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
pattern: /^(\+{4,})$[\s\S]*?^\1$/m,
inside: {
punctuation: /^\++|\++$/ // See rest below
}
},
// Literal blocks and listing blocks
'literal-block': {
pattern: /^(-{4,}|\.{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
pattern: /^(-{4,}|\.{4,})$[\s\S]*?^\1$/m,
inside: {
punctuation: /^(?:-+|\.+)|(?:-+|\.+)$/ // See rest below
}
},
// Sidebar blocks, quote blocks, example blocks and open blocks
'other-block': {
pattern:
/^(--|\*{4,}|_{4,}|={4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
pattern: /^(--|\*{4,}|_{4,}|={4,})$[\s\S]*?^\1$/m,
inside: {
punctuation: /^(?:-+|\*+|_+|=+)|(?:-+|\*+|_+|=+)$/ // See rest below
}
Expand Down
14 changes: 11 additions & 3 deletions lang/bash.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
bash.displayName = 'bash'
bash.aliases = ['shell']
bash.aliases = ['sh', 'shell']

/** @type {import('../core.js').Syntax} */
export default function bash(Prism) {
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function bash(Prism) {
// Highlight variable names as variables in the left-hand part
// of assignments (“=” and “+=”).
'assign-left': {
pattern: /(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
inside: {
environment: {
pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
Expand All @@ -119,6 +119,12 @@ export default function bash(Prism) {
alias: 'variable',
lookbehind: true
},
// Highlight parameter names as variables
parameter: {
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
alias: 'variable',
lookbehind: true
},
string: [
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
{
Expand Down Expand Up @@ -166,7 +172,7 @@ export default function bash(Prism) {
variable: insideString.variable,
function: {
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|node|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;|&])/,
/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|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|java|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|node|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|sysctl|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;|&])/,
lookbehind: true
},
keyword: {
Expand Down Expand Up @@ -215,6 +221,7 @@ export default function bash(Prism) {
'function-name',
'for-or-select',
'assign-left',
'parameter',
'string',
'environment',
'function',
Expand All @@ -232,6 +239,7 @@ export default function bash(Prism) {
inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]]
}

Prism.languages.sh = Prism.languages.bash
Prism.languages.shell = Prism.languages.bash
})(Prism)
}
27 changes: 27 additions & 0 deletions lang/bbj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-nocheck
bbj.displayName = 'bbj'
bbj.aliases = []

/** @type {import('../core.js').Syntax} */
export default function bbj(Prism) {
;(function (Prism) {
Prism.languages.bbj = {
comment: {
pattern: /(^|[^\\:])rem\s+.*/i,
lookbehind: true,
greedy: true
},
string: {
pattern: /(['"])(?:(?!\1|\\).|\\.)*\1/,
greedy: true
},
number: /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
keyword:
/\b(?:abstract|all|argc|begin|bye|callback|case|chn|class|classend|ctl|day|declare|delete|dim|dom|dread|dsz|else|end|endif|err|exitto|extends|fi|field|for|from|gosub|goto|if|implements|interface|interfaceend|iol|iolist|let|list|load|method|methodend|methodret|on|opts|pfx|print|private|process_events|protected|psz|public|read|read_resource|release|remove_callback|repeat|restore|return|rev|seterr|setesc|sqlchn|sqlunt|ssn|start|static|swend|switch|sys|then|tim|unt|until|use|void|wend|where|while)\b/i,
function: /\b\w+(?=\()/,
boolean: /\b(?:BBjAPI\.TRUE|BBjAPI\.FALSE)\b/i,
operator: /<[=>]?|>=?|[+\-*\/^=&]|\b(?:and|not|or|xor)\b/i,
punctuation: /[.,;:()]/
}
})(Prism)
}
71 changes: 71 additions & 0 deletions lang/bqn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// @ts-nocheck
bqn.displayName = 'bqn'
bqn.aliases = []

/** @type {import('../core.js').Syntax} */
export default function bqn(Prism) {
Prism.languages.bqn = {
shebang: {
pattern: /^#![ \t]*\/.*/,
alias: 'important',
greedy: true
},
comment: {
pattern: /#.*/,
greedy: true
},
'string-literal': {
pattern: /"(?:[^"]|"")*"/,
greedy: true,
alias: 'string'
},
'character-literal': {
pattern: /'(?:[\s\S]|[\uD800-\uDBFF][\uDC00-\uDFFF])'/,
greedy: true,
alias: 'char'
},
function: /•[\w¯.∞π]+[\w¯.∞π]*/,
'dot-notation-on-brackets': {
pattern: /\{(?=.*\}\.)|\}\./,
alias: 'namespace'
},
'special-name': {
pattern: /(?:𝕨|𝕩|𝕗|𝕘|𝕤|𝕣|𝕎|𝕏|𝔽|𝔾|𝕊|_𝕣_|_𝕣)/,
alias: 'keyword'
},
'dot-notation-on-name': {
pattern: /[A-Za-z_][\w¯∞π]*\./,
alias: 'namespace'
},
'word-number-scientific': {
pattern: /\d+(?:\.\d+)?[eE]¯?\d+/,
alias: 'number'
},
'word-name': {
pattern: /[A-Za-z_][\w¯∞π]*/,
alias: 'symbol'
},
'word-number': {
pattern:
/[¯∞π]?(?:\d*\.?\b\d+(?:e[+¯]?\d+|E[+¯]?\d+)?|¯|∞|π)(?:j¯?(?:(?:\d+(?:\.\d+)?|\.\d+)(?:e[+¯]?\d+|E[+¯]?\d+)?|¯|∞|π))?/,
alias: 'number'
},
'null-literal': {
pattern: /@/,
alias: 'char'
},
'primitive-functions': {
pattern: /[-+×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!]/,
alias: 'operator'
},
'primitive-1-operators': {
pattern: /[`˜˘¨⁼⌜´˝˙]/,
alias: 'operator'
},
'primitive-2-operators': {
pattern: /[∘⊸⟜○⌾⎉⚇⍟⊘◶⎊]/,
alias: 'operator'
},
punctuation: /[←⇐↩(){}⟨⟩[\]‿·⋄,.;:?]/
}
}
16 changes: 16 additions & 0 deletions lang/cilkc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @ts-nocheck
import refractorC from './c.js'
cilkc.displayName = 'cilkc'
cilkc.aliases = ['cilk-c']

/** @type {import('../core.js').Syntax} */
export default function cilkc(Prism) {
Prism.register(refractorC)
Prism.languages.cilkc = Prism.languages.insertBefore('c', 'function', {
'parallel-keyword': {
pattern: /\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,
alias: 'keyword'
}
})
Prism.languages['cilk-c'] = Prism.languages['cilkc']
}
17 changes: 17 additions & 0 deletions lang/cilkcpp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-nocheck
import refractorCpp from './cpp.js'
cilkcpp.displayName = 'cilkcpp'
cilkcpp.aliases = ['cilk', 'cilk-cpp']

/** @type {import('../core.js').Syntax} */
export default function cilkcpp(Prism) {
Prism.register(refractorCpp)
Prism.languages.cilkcpp = Prism.languages.insertBefore('cpp', 'function', {
'parallel-keyword': {
pattern: /\bcilk_(?:for|reducer|s(?:cope|pawn|ync))\b/,
alias: 'keyword'
}
})
Prism.languages['cilk-cpp'] = Prism.languages['cilkcpp']
Prism.languages['cilk'] = Prism.languages['cilkcpp']
}
2 changes: 1 addition & 1 deletion lang/css-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function cssExtras(Prism) {
color: [
{
pattern:
/(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,
/(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|RebeccaPurple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,
lookbehind: true
},
{
Expand Down
9 changes: 8 additions & 1 deletion lang/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ export default function css(Prism) {
Prism.languages.css = {
comment: /\/\*[\s\S]*?\*\//,
atrule: {
pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
pattern: RegExp(
'@[\\w-](?:' +
/[^;{\s"']|\s+(?!\s)/.source +
'|' +
string.source +
')*?' +
/(?:;|(?=\s*\{))/.source
),
inside: {
rule: /^@[\w-]+/,
'selector-function-argument': {
Expand Down
68 changes: 68 additions & 0 deletions lang/gradle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// @ts-nocheck
import refractorClike from './clike.js'
gradle.displayName = 'gradle'
gradle.aliases = []

/** @type {import('../core.js').Syntax} */
export default function gradle(Prism) {
Prism.register(refractorClike)
;(function (Prism) {
var interpolation = {
pattern: /((?:^|[^\\$])(?:\\{2})*)\$(?:\w+|\{[^{}]*\})/,
lookbehind: true,
inside: {
'interpolation-punctuation': {
pattern: /^\$\{?|\}$/,
alias: 'punctuation'
},
expression: {
pattern: /[\s\S]+/,
inside: null
}
}
}
Prism.languages.gradle = Prism.languages.extend('clike', {
string: {
pattern: /'''(?:[^\\]|\\[\s\S])*?'''|'(?:\\.|[^\\'\r\n])*'/,
greedy: true
},
keyword:
/\b(?:apply|def|dependencies|else|if|implementation|import|plugin|plugins|project|repositories|repository|sourceSets|tasks|val)\b/,
number:
/\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?\d+)?)[glidf]?\b/i,
operator: {
pattern:
/(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.\.(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
lookbehind: true
},
punctuation: /\.+|[{}[\];(),:$]/
})
Prism.languages.insertBefore('gradle', 'string', {
shebang: {
pattern: /#!.+/,
alias: 'comment',
greedy: true
},
'interpolation-string': {
pattern:
/"""(?:[^\\]|\\[\s\S])*?"""|(["/])(?:\\.|(?!\1)[^\\\r\n])*\1|\$\/(?:[^/$]|\$(?:[/$]|(?![/$]))|\/(?!\$))*\/\$/,
greedy: true,
inside: {
interpolation: interpolation,
string: /[\s\S]+/
}
}
})
Prism.languages.insertBefore('gradle', 'punctuation', {
'spock-block': /\b(?:and|cleanup|expect|given|setup|then|when|where):/
})
Prism.languages.insertBefore('gradle', 'function', {
annotation: {
pattern: /(^|[^.])@\w+/,
lookbehind: true,
alias: 'punctuation'
}
})
interpolation.inside.expression.inside = Prism.languages.gradle
})(Prism)
}
2 changes: 1 addition & 1 deletion lang/hoon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function hoon(Prism) {
greedy: true
},
string: {
pattern: /"[^"]*"|'[^']*'/,
pattern: /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/,
greedy: true
},
constant: /%(?:\.[ny]|[\w-]+)/,
Expand Down
3 changes: 2 additions & 1 deletion lang/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export default function java(Prism) {
pattern:
/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
lookbehind: true
}
},
constant: /\b[A-Z][A-Z_\d]+\b/
})
Prism.languages.insertBefore('java', 'string', {
'triple-quoted-string': {
Expand Down
5 changes: 4 additions & 1 deletion lang/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default function markup(Prism) {
pattern: /^=/,
alias: 'attr-equals'
},
/"|'/
{
pattern: /^(\s*)["']|["']$/,
lookbehind: true
}
]
}
},
Expand Down

0 comments on commit 82394d3

Please sign in to comment.