-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathprism-lang-cli.js
executable file
·61 lines (61 loc) · 1.35 KB
/
prism-lang-cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
exports.setupPrismCLILang = void 0
const prism_ = require('prismjs')
function setupPrismCLILang(prism = prism_) {
prism.languages.cli = {
comment: [/^#.*/gm, ...prism.languages.js.comment],
output: {
pattern: /^\$\:.*/gms,
greedy: true,
inside: {
hidden: /^\$\:/,
},
},
command: {
// pattern: /^(\S+)\s(.*)/gm,
pattern: /^(?:\$\s)?(?:.+\s\\(?:\r\n|\r|\n))*.+/gm,
inside: {
'command-line-break': {
pattern: /\s\\(?:\r\n|\r|\n)/,
alias: ['comment'],
},
'command-name': {
pattern: /^(?:\$\s)?(\S+)/g,
alias: ['keyword'],
inside: {
visual: /\$\s/,
},
},
'command-flag': {
pattern: /\s-\w\S*\s?/g,
inside: {
punctuation: /^\s-/,
bold: /\S+/,
},
},
'command-parameter': {
pattern: /\s--\S+([\s=]\S+)?/g,
inside: {
'command-parameter-name': {
pattern: /^(\s--)([\w-]+)/g,
lookbehind: true,
alias: ['bold'],
},
'command-parameter-value': {
pattern: /(\s|=)(?!-)(\S+)/,
lookbehind: true,
alias: ['function-name'],
},
punctuation: /(--|=)/,
},
},
'command-subcommand-name': {
pattern: /^\s\w\S*\s?/g,
alias: ['function'],
},
},
},
}
}
exports.setupPrismCLILang = setupPrismCLILang