lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/powershell_highlight_rules.js in gollum-2.4.4 vs lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/powershell_highlight_rules.js in gollum-2.4.5
- old
+ new
@@ -1,21 +1,20 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
-var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PowershellHighlightRules = function() {
-
- var keywords = lang.arrayToMap(
- ("function|if|else|elseif|switch|while|default|for|do|until|break|continue|" +
- "foreach|return|filter|in|trap|throw|param|begin|process|end").split("|")
+
+ var keywords = (
+ "function|if|else|elseif|switch|while|default|for|do|until|break|continue|" +
+ "foreach|return|filter|in|trap|throw|param|begin|process|end"
);
- var builtinFunctions = lang.arrayToMap(
- ("Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" +
+ var builtinFunctions = (
+ "Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" +
"Set-Location|Get-ChildItem|Clear-Item|Get-Command|Measure-Command|Trace-Command|" +
"Add-Computer|Checkpoint-Computer|Remove-Computer|Restart-Computer|Restore-Computer|Stop-Computer|" +
"Reset-ComputerMachinePassword|Test-ComputerSecureChannel|Add-Content|Get-Content|Set-Content|Clear-Content|" +
"Get-Command|Invoke-Command|Enable-ComputerRestore|Disable-ComputerRestore|Get-ComputerRestorePoint|Test-Connection|" +
"ConvertFrom-CSV|ConvertTo-CSV|ConvertTo-Html|ConvertTo-Xml|ConvertFrom-SecureString|ConvertTo-SecureString|" +
@@ -51,26 +50,36 @@
"Update-Formatdata|Update-Typedata|Clear-Variable|Get-Variable|New-Variable|Remove-Variable|" +
"Set-Variable|New-WebServiceProxy|Where-Object|Write-Debug|Write-Error|Write-Host|" +
"Write-Output|Write-Progress|Write-Verbose|Write-Warning|Set-WmiInstance|Invoke-WmiMethod|" +
"Get-WmiObject|Remove-WmiObject|Connect-WSMan|Disconnect-WSMan|Test-WSMan|Invoke-WSManAction|" +
"Disable-WSManCredSSP|Enable-WSManCredSSP|Get-WSManCredSSP|New-WSManInstance|Get-WSManInstance|Set-WSManInstance|" +
- "Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption").split("|"));
+ "Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption"
+ );
+ var keywordMapper = this.createKeywordMapper({
+ "support.function": builtinFunctions,
+ "keyword": keywords
+ }, "identifier");
+
var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" +
"ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" +
"is|isnot|as|" +
- "and|or|band|bor|not";
+ "and|or|band|bor|not";
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "#.*$"
}, {
+ token : "comment.start",
+ regex : "<#",
+ next : "comment"
+ }, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
@@ -88,18 +97,11 @@
regex : "[$][Nn]ull\\b"
}, {
token : "variable.instance",
regex : "[$][a-zA-Z][a-zA-Z0-9_]*\\b"
}, {
- token : function(value) {
- if (keywords.hasOwnProperty(value))
- return "keyword";
- else if (builtinFunctions.hasOwnProperty(value))
- return "support.function";
- else
- return "identifier";
- },
+ token : keywordMapper,
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
}, {
token : "keyword.operator",
@@ -118,16 +120,24 @@
regex : "\\s+"
}
],
"comment" : [
{
- token : "comment", // closing comment
- regex : ".*?\\*\\/",
+ token : "comment.end",
+ regex : "#>",
next : "start"
}, {
- token : "comment", // comment spanning whole line
+ token : "doc.comment.tag",
merge : true,
- regex : ".+"
+ regex : "^\\.\\w+"
+ }, {
+ token : "comment",
+ merge : true,
+ regex : "\\w+"
+ }, {
+ token : "comment",
+ merge : true,
+ regex : "."
}
]
};
};