Skip to content

Commit 27c5b69

Browse files
committed
fix(prism): keep named capture groups for lookbehind patterns
Reverts the plain-capture-group change: the repo's eslint config enforces prefer-named-capture-group, and Prism's lookbehind:true requires a capturing (not non-capturing) group, so named groups are the only option that satisfies both. Named capture groups are ES2018 and supported across the project's browserslist targets.
1 parent 116872c commit 27c5b69

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/prism/z-shell-languages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function registerZShellLanguages(Prism: typeof PrismNamespace): void {
77
Prism.languages.insertBefore("zsh", "function", {
88
"zsh-builtin": {
99
pattern:
10-
/(^|[\s;|&])(?:autoload|bindkey|builtin|compctl|compdump|compinit|compdef|compfiles|compgroups|compquote|comptags|comptry|compvalues|declare|dirs|disable|disown|emulate|enable|fc|float|functions|getcap|getln|getopts|history|integer|jobs|let|limit|local|log|noglob|popd|print|printf|pushd|pushln|pwd|read|readonly|sched|set|setcap|setopt|shift|source|stat|suspend|ttyctl|type|typeset|ulimit|umask|unalias|unfunction|unhash|unlimit|unset|unsetopt|vared|wait|whence|where|which|zcompile|zformat|zle|zmodload|zparseopts|zpty|zregexparse|zsocket|zstyle|ztcp)(?=\s|;|$)/,
10+
/(?<lb>^|[\s;|&])(?:autoload|bindkey|builtin|compctl|compdump|compinit|compdef|compfiles|compgroups|compquote|comptags|comptry|compvalues|declare|dirs|disable|disown|emulate|enable|fc|float|functions|getcap|getln|getopts|history|integer|jobs|let|limit|local|log|noglob|popd|print|printf|pushd|pushln|pwd|read|readonly|sched|set|setcap|setopt|shift|source|stat|suspend|ttyctl|type|typeset|ulimit|umask|unalias|unfunction|unhash|unlimit|unset|unsetopt|vared|wait|whence|where|which|zcompile|zformat|zle|zmodload|zparseopts|zpty|zregexparse|zsocket|zstyle|ztcp)(?=\s|;|$)/,
1111
lookbehind: true,
1212
alias: "builtin",
1313
},
@@ -24,7 +24,7 @@ export function registerZShellLanguages(Prism: typeof PrismNamespace): void {
2424
alias: "variable",
2525
},
2626
"zsh-glob-qualifier": {
27-
pattern: /(^|[^\w])(?:\*\*\/)?\*[^ \n]*(?:\([^)]+\))/,
27+
pattern: /(?<lb>^|[^\w])(?:\*\*\/)?\*[^ \n]*(?:\([^)]+\))/,
2828
lookbehind: true,
2929
alias: "operator",
3030
},
@@ -64,7 +64,7 @@ export function registerZShellLanguages(Prism: typeof PrismNamespace): void {
6464
alias: "function",
6565
},
6666
"zunit-command": {
67-
pattern: /(^|[\s;|&])zunit(?=[\s;|&]|$)/,
67+
pattern: /(?<lb>^|[\s;|&])zunit(?=[\s;|&]|$)/,
6868
lookbehind: true,
6969
alias: "builtin",
7070
},

0 commit comments

Comments
 (0)