UNPKG

1.31 kBJavaScriptView Raw
1(function (Prism) {
2
3 // CAREFUL!
4 // The following patterns are concatenated, so the group referenced by a back reference is non-obvious!
5
6 var strings = [
7 // normal string
8 // 1 capturing group
9 /(["'])(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|(?!\1)[^\\`$])*\1/.source,
10
11 // here doc
12 // 2 capturing groups
13 /<<-?\s*(["']?)(\w+)\2\s[\s\S]*?[\r\n]\3/.source
14 ].join('|');
15
16 Prism.languages['shell-session'] = {
17 'command': {
18 pattern: RegExp(/^(?:[^\s@:$#*!/\\]+@[^\s@:$#*!/\\]+(?::[^\0-\x1F$#*?"<>:;|]+)?)?[$#](?:[^\\\r\n'"<]|\\.|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }), 'm'),
19 greedy: true,
20 inside: {
21 'info': {
22 // foo@bar:~/files$ exit
23 // foo@bar$ exit
24 pattern: /^[^#$]+/,
25 alias: 'punctuation',
26 inside: {
27 'path': {
28 pattern: /(:)[\s\S]+/,
29 lookbehind: true
30 },
31 'user': /^[^:]+/,
32 'punctuation': /:/
33 }
34 },
35 'bash': {
36 pattern: /(^[$#]\s*)\S[\s\S]*/,
37 lookbehind: true,
38 alias: 'language-bash',
39 inside: Prism.languages.bash
40 },
41 'shell-symbol': {
42 pattern: /^[$#]/,
43 alias: 'important'
44 }
45 }
46 },
47 'output': /.(?:.*(?:[\r\n]|.$))*/
48 };
49
50 Prism.languages['sh-session'] = Prism.languages['shellsession'] = Prism.languages['shell-session'];
51
52}(Prism));