Skip to content

Commit 4492b62

Browse files
authored
Shell-session: Added support for the percent sign as shell symbol (#3010)
1 parent b38fc89 commit 4492b62

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

components/prism-shell-session.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
'command': {
1919
pattern: RegExp(
2020
// user info
21-
/^(?:[^\s@:$#*!/\\]+@[^\r\n@:$#*!/\\]+(?::[^\0-\x1F$#*?"<>:;|]+)?|[^\0-\x1F$#*?"<>@:;|]+)?/.source +
21+
/^(?:[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+(?::[^\0-\x1F$#%*?"<>:;|]+)?|[^\0-\x1F$#%*?"<>@:;|]+)?/.source +
2222
// shell symbol
23-
/[$#]/.source +
23+
/[$#%]/.source +
2424
// bash command
2525
/(?:[^\\\r\n'"<$]|\\(?:[^\r]|\r\n?)|\$(?!')|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }),
2626
'm'
@@ -31,22 +31,22 @@
3131
// foo@bar:~/files$ exit
3232
// foo@bar$ exit
3333
// ~/files$ exit
34-
pattern: /^[^#$]+/,
34+
pattern: /^[^#$%]+/,
3535
alias: 'punctuation',
3636
inside: {
37-
'user': /^[^\s@:$#*!/\\]+@[^\r\n@:$#*!/\\]+/,
37+
'user': /^[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+/,
3838
'punctuation': /:/,
3939
'path': /[\s\S]+/
4040
}
4141
},
4242
'bash': {
43-
pattern: /(^[$#]\s*)\S[\s\S]*/,
43+
pattern: /(^[$#%]\s*)\S[\s\S]*/,
4444
lookbehind: true,
4545
alias: 'language-bash',
4646
inside: Prism.languages.bash
4747
},
4848
'shell-symbol': {
49-
pattern: /^[$#]/,
49+
pattern: /^[$#%]/,
5050
alias: 'important'
5151
}
5252
}

components/prism-shell-session.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/shell-session/info_feature.test

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ foo@bar:~$ sudo -i
44
root@bar:~# echo "hello!"
55
hello!
66

7-
foo@bar$ exit
7+
foo@bar$ zsh
8+
foo@bar% exit
89

910
----------------------------------------------------
1011

@@ -54,6 +55,15 @@ foo@bar$ exit
5455
["user", "foo@bar"]
5556
]],
5657
["shell-symbol", "$"],
58+
["bash", [
59+
["function", "zsh"]
60+
]]
61+
]],
62+
["command", [
63+
["info", [
64+
["user", "foo@bar"]
65+
]],
66+
["shell-symbol", "%"],
5767
["bash", [
5868
["builtin", "exit"]
5969
]]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy