/
prism-powershell.js
19 lines (15 loc) · 1.07 KB
/
prism-powershell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Prism.languages.powershell = {
// This comment regex is ugly because prism.js replaces "<" with "<" behind the scenes for some reason
'comment': /(\<\;#[\w\W]*?#>)|(\#.*)/g,
'string': /(\@\"[\w\W]*?\"\@)|((\'|\")[\w\W]*?(\'|\"))/g,
'keyword': /\b(switch|if|else|while|do|for|return|function|new|try|throw|catch|finally|break|exit|begin|process|end)(?![-\S])?\b/ig,
'boolean': /(\$true|\$false)/g,
// This is for PowerShell Actions, leveraging the theme's pre-defined color scheme for attr-value
'attr-value': /(add|get|read|test|start|new|set|write|output|where)-\S*/ig,
// This is for PowerShell Variables, leveraging the theme's pre-defined color scheme for symbol
'symbol': /(?!(\$true|\$false))(\$[a-z|A-Z|0-9|_|-]*)\b/g,
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,
'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%|-or|-and|-lt|-le|-gt|-ge|-match|-like/g,
'ignore': /&(lt|gt|amp);/gi,
'punctuation': /[{}[\];(),.:]/g
};