1
0
Fork 0
forked from forgejo/forgejo

Moved vendored js/css into public/vendor and documented sources (#1484) (#2241)

* Cleaning up public/ and documenting js/css libs.

This commit mostly addresses #1484 by moving vendor'ed plugins into a
vendor/ directory and documenting their upstream source and license in
vendor/librejs.html.

This also proves gitea is using only open source js/css libraries which
helps toward reaching #1524.

* Removing unused css file.

The version of this file in use is located at:
  vendor/plugins/highlight/github.css

* Cleaned up librejs.html and added javascript header

A SafeJS function was added to templates/helper.go to allow keeping
comments inside of javascript.

A javascript comment was added in the header of templates/base/head.tmpl
to mark all non-inline source as free.

The librejs.html file was updated to meet the current librejs spec. I
have now verified that the librejs plugin detects most of the scripts
included in gitea and suspect the non-free detections are the result of
a bug in the plugin. I believe this commit is enough to meet the C0.0
requirement of #1534.

* Updating SafeJS function per lint suggestion

* Added VERSIONS file, per request
This commit is contained in:
Michael Lustfield 2017-08-23 09:58:05 -05:00 committed by Kim "BKC" Carlbäcker
parent 64b7068846
commit a915a09e4f
1339 changed files with 813 additions and 126 deletions

View file

@ -0,0 +1,204 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Powershell mode</title>
<link rel="stylesheet" href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="powershell.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
</head>
<body>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">JavaScript</a>
</ul>
</div>
<article>
<h2>PowerShell mode</h2>
<div><textarea id="code" name="code">
# Number Literals
0 12345
12kb 12mb 12gB 12Tb 12PB 12L 12D 12lkb 12dtb
1.234 1.234e56 1. 1.e2 .2 .2e34
1.2MB 1.kb .1dTb 1.e1gb
0x1 0xabcdef 0x3tb 0xelmb
# String Literals
'Literal escaping'''
'Literal $variable'
"Escaping 1`""
"Escaping 2"""
"Escaped `$variable"
"Text, $variable and more text"
"Text, ${variable with spaces} and more text."
"Text, $($expression + 3) and more text."
"Text, $("interpolation $("inception")") and more text."
@"
Multiline
string
"@
# --
@"
Multiline
string with quotes "'
"@
# --
@'
Multiline literal
string with quotes "'
'@
# Array and Hash literals
@( 'a','b','c' )
@{ 'key': 'value' }
# Variables
$Variable = 5
$global:variable = 5
${Variable with spaces} = 5
# Operators
= += -= *= /= %=
++ -- .. -f * / % + -
-not ! -bnot
-split -isplit -csplit
-join
-is -isnot -as
-eq -ieq -ceq -ne -ine -cne
-gt -igt -cgt -ge -ige -cge
-lt -ilt -clt -le -ile -cle
-like -ilike -clike -notlike -inotlike -cnotlike
-match -imatch -cmatch -notmatch -inotmatch -cnotmatch
-contains -icontains -ccontains -notcontains -inotcontains -cnotcontains
-replace -ireplace -creplace
-band -bor -bxor
-and -or -xor
# Punctuation
() [] {} , : ` = ; .
# Keywords
elseif begin function for foreach return else trap while do data dynamicparam
until end break if throw param continue finally in switch exit filter from try
process catch
# Built-in variables
$$ $? $^ $_
$args $ConfirmPreference $ConsoleFileName $DebugPreference $Error
$ErrorActionPreference $ErrorView $ExecutionContext $false $FormatEnumerationLimit
$HOME $Host $input $MaximumAliasCount $MaximumDriveCount $MaximumErrorCount
$MaximumFunctionCount $MaximumHistoryCount $MaximumVariableCount $MyInvocation
$NestedPromptLevel $null $OutputEncoding $PID $PROFILE $ProgressPreference
$PSBoundParameters $PSCommandPath $PSCulture $PSDefaultParameterValues
$PSEmailServer $PSHOME $PSScriptRoot $PSSessionApplicationName
$PSSessionConfigurationName $PSSessionOption $PSUICulture $PSVersionTable $PWD
$ShellId $StackTrace $true $VerbosePreference $WarningPreference $WhatIfPreference
$true $false $null
# Built-in functions
A:
Add-Computer Add-Content Add-History Add-Member Add-PSSnapin Add-Type
B:
C:
Checkpoint-Computer Clear-Content Clear-EventLog Clear-History Clear-Host Clear-Item
Clear-ItemProperty Clear-Variable Compare-Object Complete-Transaction Connect-PSSession
ConvertFrom-Csv ConvertFrom-Json ConvertFrom-SecureString ConvertFrom-StringData
Convert-Path ConvertTo-Csv ConvertTo-Html ConvertTo-Json ConvertTo-SecureString
ConvertTo-Xml Copy-Item Copy-ItemProperty
D:
Debug-Process Disable-ComputerRestore Disable-PSBreakpoint Disable-PSRemoting
Disable-PSSessionConfiguration Disconnect-PSSession
E:
Enable-ComputerRestore Enable-PSBreakpoint Enable-PSRemoting Enable-PSSessionConfiguration
Enter-PSSession Exit-PSSession Export-Alias Export-Clixml Export-Console Export-Counter
Export-Csv Export-FormatData Export-ModuleMember Export-PSSession
F:
ForEach-Object Format-Custom Format-List Format-Table Format-Wide
G:
Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-ComputerRestorePoint
Get-Content Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-Date
Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy Get-FormatData Get-Help
Get-History Get-Host Get-HotFix Get-Item Get-ItemProperty Get-Job Get-Location Get-Member
Get-Module Get-PfxCertificate Get-Process Get-PSBreakpoint Get-PSCallStack Get-PSDrive
Get-PSProvider Get-PSSession Get-PSSessionConfiguration Get-PSSnapin Get-Random Get-Service
Get-TraceSource Get-Transaction Get-TypeData Get-UICulture Get-Unique Get-Variable Get-Verb
Get-WinEvent Get-WmiObject Group-Object
H:
help
I:
Import-Alias Import-Clixml Import-Counter Import-Csv Import-LocalizedData Import-Module
Import-PSSession ImportSystemModules Invoke-Command Invoke-Expression Invoke-History
Invoke-Item Invoke-RestMethod Invoke-WebRequest Invoke-WmiMethod
J:
Join-Path
K:
L:
Limit-EventLog
M:
Measure-Command Measure-Object mkdir more Move-Item Move-ItemProperty
N:
New-Alias New-Event New-EventLog New-Item New-ItemProperty New-Module New-ModuleManifest
New-Object New-PSDrive New-PSSession New-PSSessionConfigurationFile New-PSSessionOption
New-PSTransportOption New-Service New-TimeSpan New-Variable New-WebServiceProxy
New-WinEvent
O:
oss Out-Default Out-File Out-GridView Out-Host Out-Null Out-Printer Out-String
P:
Pause Pop-Location prompt Push-Location
Q:
R:
Read-Host Receive-Job Receive-PSSession Register-EngineEvent Register-ObjectEvent
Register-PSSessionConfiguration Register-WmiEvent Remove-Computer Remove-Event
Remove-EventLog Remove-Item Remove-ItemProperty Remove-Job Remove-Module
Remove-PSBreakpoint Remove-PSDrive Remove-PSSession Remove-PSSnapin Remove-TypeData
Remove-Variable Remove-WmiObject Rename-Computer Rename-Item Rename-ItemProperty
Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service
Restore-Computer Resume-Job Resume-Service
S:
Save-Help Select-Object Select-String Select-Xml Send-MailMessage Set-Acl Set-Alias
Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item
Set-ItemProperty Set-Location Set-PSBreakpoint Set-PSDebug
Set-PSSessionConfiguration Set-Service Set-StrictMode Set-TraceSource Set-Variable
Set-WmiInstance Show-Command Show-ControlPanelItem Show-EventLog Sort-Object
Split-Path Start-Job Start-Process Start-Service Start-Sleep Start-Transaction
Start-Transcript Stop-Computer Stop-Job Stop-Process Stop-Service Stop-Transcript
Suspend-Job Suspend-Service
T:
TabExpansion2 Tee-Object Test-ComputerSecureChannel Test-Connection
Test-ModuleManifest Test-Path Test-PSSessionConfigurationFile Trace-Command
U:
Unblock-File Undo-Transaction Unregister-Event Unregister-PSSessionConfiguration
Update-FormatData Update-Help Update-List Update-TypeData Use-Transaction
V:
W:
Wait-Event Wait-Job Wait-Process Where-Object Write-Debug Write-Error Write-EventLog
Write-Host Write-Output Write-Progress Write-Verbose Write-Warning
X:
Y:
Z:</textarea></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "powershell",
lineNumbers: true,
indentUnit: 4,
tabMode: "shift",
matchBrackets: true
});
</script>
<p><strong>MIME types defined:</strong> <code>application/x-powershell</code>.</p>
</article>
</body>
</html>

View file

@ -0,0 +1,396 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
'use strict';
if (typeof exports == 'object' && typeof module == 'object') // CommonJS
mod(require('codemirror'));
else if (typeof define == 'function' && define.amd) // AMD
define(['codemirror'], mod);
else // Plain browser env
mod(window.CodeMirror);
})(function(CodeMirror) {
'use strict';
CodeMirror.defineMode('powershell', function() {
function buildRegexp(patterns, options) {
options = options || {};
var prefix = options.prefix !== undefined ? options.prefix : '^';
var suffix = options.suffix !== undefined ? options.suffix : '\\b';
for (var i = 0; i < patterns.length; i++) {
if (patterns[i] instanceof RegExp) {
patterns[i] = patterns[i].source;
}
else {
patterns[i] = patterns[i].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
}
return new RegExp(prefix + '(' + patterns.join('|') + ')' + suffix, 'i');
}
var notCharacterOrDash = '(?=[^A-Za-z\\d\\-_]|$)';
var varNames = /[\w\-:]/
var keywords = buildRegexp([
/begin|break|catch|continue|data|default|do|dynamicparam/,
/else|elseif|end|exit|filter|finally|for|foreach|from|function|if|in/,
/param|process|return|switch|throw|trap|try|until|where|while/
], { suffix: notCharacterOrDash });
var punctuation = /[\[\]{},;`\.]|@[({]/;
var wordOperators = buildRegexp([
'f',
/b?not/,
/[ic]?split/, 'join',
/is(not)?/, 'as',
/[ic]?(eq|ne|[gl][te])/,
/[ic]?(not)?(like|match|contains)/,
/[ic]?replace/,
/b?(and|or|xor)/
], { prefix: '-' });
var symbolOperators = /[+\-*\/%]=|\+\+|--|\.\.|[+\-*&^%:=!|\/]|<(?!#)|(?!#)>/;
var operators = buildRegexp([wordOperators, symbolOperators], { suffix: '' });
var numbers = /^((0x[\da-f]+)|((\d+\.\d+|\d\.|\.\d+|\d+)(e[\+\-]?\d+)?))[ld]?([kmgtp]b)?/i;
var identifiers = /^[A-Za-z\_][A-Za-z\-\_\d]*\b/;
var symbolBuiltins = /[A-Z]:|%|\?/i;
var namedBuiltins = buildRegexp([
/Add-(Computer|Content|History|Member|PSSnapin|Type)/,
/Checkpoint-Computer/,
/Clear-(Content|EventLog|History|Host|Item(Property)?|Variable)/,
/Compare-Object/,
/Complete-Transaction/,
/Connect-PSSession/,
/ConvertFrom-(Csv|Json|SecureString|StringData)/,
/Convert-Path/,
/ConvertTo-(Csv|Html|Json|SecureString|Xml)/,
/Copy-Item(Property)?/,
/Debug-Process/,
/Disable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/,
/Disconnect-PSSession/,
/Enable-(ComputerRestore|PSBreakpoint|PSRemoting|PSSessionConfiguration)/,
/(Enter|Exit)-PSSession/,
/Export-(Alias|Clixml|Console|Counter|Csv|FormatData|ModuleMember|PSSession)/,
/ForEach-Object/,
/Format-(Custom|List|Table|Wide)/,
new RegExp('Get-(Acl|Alias|AuthenticodeSignature|ChildItem|Command|ComputerRestorePoint|Content|ControlPanelItem|Counter|Credential'
+ '|Culture|Date|Event|EventLog|EventSubscriber|ExecutionPolicy|FormatData|Help|History|Host|HotFix|Item|ItemProperty|Job'
+ '|Location|Member|Module|PfxCertificate|Process|PSBreakpoint|PSCallStack|PSDrive|PSProvider|PSSession|PSSessionConfiguration'
+ '|PSSnapin|Random|Service|TraceSource|Transaction|TypeData|UICulture|Unique|Variable|Verb|WinEvent|WmiObject)'),
/Group-Object/,
/Import-(Alias|Clixml|Counter|Csv|LocalizedData|Module|PSSession)/,
/ImportSystemModules/,
/Invoke-(Command|Expression|History|Item|RestMethod|WebRequest|WmiMethod)/,
/Join-Path/,
/Limit-EventLog/,
/Measure-(Command|Object)/,
/Move-Item(Property)?/,
new RegExp('New-(Alias|Event|EventLog|Item(Property)?|Module|ModuleManifest|Object|PSDrive|PSSession|PSSessionConfigurationFile'
+ '|PSSessionOption|PSTransportOption|Service|TimeSpan|Variable|WebServiceProxy|WinEvent)'),
/Out-(Default|File|GridView|Host|Null|Printer|String)/,
/Pause/,
/(Pop|Push)-Location/,
/Read-Host/,
/Receive-(Job|PSSession)/,
/Register-(EngineEvent|ObjectEvent|PSSessionConfiguration|WmiEvent)/,
/Remove-(Computer|Event|EventLog|Item(Property)?|Job|Module|PSBreakpoint|PSDrive|PSSession|PSSnapin|TypeData|Variable|WmiObject)/,
/Rename-(Computer|Item(Property)?)/,
/Reset-ComputerMachinePassword/,
/Resolve-Path/,
/Restart-(Computer|Service)/,
/Restore-Computer/,
/Resume-(Job|Service)/,
/Save-Help/,
/Select-(Object|String|Xml)/,
/Send-MailMessage/,
new RegExp('Set-(Acl|Alias|AuthenticodeSignature|Content|Date|ExecutionPolicy|Item(Property)?|Location|PSBreakpoint|PSDebug' +
'|PSSessionConfiguration|Service|StrictMode|TraceSource|Variable|WmiInstance)'),
/Show-(Command|ControlPanelItem|EventLog)/,
/Sort-Object/,
/Split-Path/,
/Start-(Job|Process|Service|Sleep|Transaction|Transcript)/,
/Stop-(Computer|Job|Process|Service|Transcript)/,
/Suspend-(Job|Service)/,
/TabExpansion2/,
/Tee-Object/,
/Test-(ComputerSecureChannel|Connection|ModuleManifest|Path|PSSessionConfigurationFile)/,
/Trace-Command/,
/Unblock-File/,
/Undo-Transaction/,
/Unregister-(Event|PSSessionConfiguration)/,
/Update-(FormatData|Help|List|TypeData)/,
/Use-Transaction/,
/Wait-(Event|Job|Process)/,
/Where-Object/,
/Write-(Debug|Error|EventLog|Host|Output|Progress|Verbose|Warning)/,
/cd|help|mkdir|more|oss|prompt/,
/ac|asnp|cat|cd|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|dnsn|ebp/,
/echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps/,
/group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md/,
/measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri/,
/rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls/,
/sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|where|wjb|write/
], { prefix: '', suffix: '' });
var variableBuiltins = buildRegexp([
/[$?^_]|Args|ConfirmPreference|ConsoleFileName|DebugPreference|Error|ErrorActionPreference|ErrorView|ExecutionContext/,
/FormatEnumerationLimit|Home|Host|Input|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount/,
/MaximumHistoryCount|MaximumVariableCount|MyInvocation|NestedPromptLevel|OutputEncoding|Pid|Profile|ProgressPreference/,
/PSBoundParameters|PSCommandPath|PSCulture|PSDefaultParameterValues|PSEmailServer|PSHome|PSScriptRoot|PSSessionApplicationName/,
/PSSessionConfigurationName|PSSessionOption|PSUICulture|PSVersionTable|Pwd|ShellId|StackTrace|VerbosePreference/,
/WarningPreference|WhatIfPreference/,
/Event|EventArgs|EventSubscriber|Sender/,
/Matches|Ofs|ForEach|LastExitCode|PSCmdlet|PSItem|PSSenderInfo|This/,
/true|false|null/
], { prefix: '\\$', suffix: '' });
var builtins = buildRegexp([symbolBuiltins, namedBuiltins, variableBuiltins], { suffix: notCharacterOrDash });
var grammar = {
keyword: keywords,
number: numbers,
operator: operators,
builtin: builtins,
punctuation: punctuation,
identifier: identifiers
};
// tokenizers
function tokenBase(stream, state) {
// Handle Comments
//var ch = stream.peek();
var parent = state.returnStack[state.returnStack.length - 1];
if (parent && parent.shouldReturnFrom(state)) {
state.tokenize = parent.tokenize;
state.returnStack.pop();
return state.tokenize(stream, state);
}
if (stream.eatSpace()) {
return null;
}
if (stream.eat('(')) {
state.bracketNesting += 1;
return 'punctuation';
}
if (stream.eat(')')) {
state.bracketNesting -= 1;
return 'punctuation';
}
for (var key in grammar) {
if (stream.match(grammar[key])) {
return key;
}
}
var ch = stream.next();
// single-quote string
if (ch === "'") {
return tokenSingleQuoteString(stream, state);
}
if (ch === '$') {
return tokenVariable(stream, state);
}
// double-quote string
if (ch === '"') {
return tokenDoubleQuoteString(stream, state);
}
if (ch === '<' && stream.eat('#')) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (ch === '#') {
stream.skipToEnd();
return 'comment';
}
if (ch === '@') {
var quoteMatch = stream.eat(/["']/);
if (quoteMatch && stream.eol()) {
state.tokenize = tokenMultiString;
state.startQuote = quoteMatch[0];
return tokenMultiString(stream, state);
} else if (stream.peek().match(/[({]/)) {
return 'punctuation';
} else if (stream.peek().match(varNames)) {
// splatted variable
return tokenVariable(stream, state);
}
}
return 'error';
}
function tokenSingleQuoteString(stream, state) {
var ch;
while ((ch = stream.peek()) != null) {
stream.next();
if (ch === "'" && !stream.eat("'")) {
state.tokenize = tokenBase;
return 'string';
}
}
return 'error';
}
function tokenDoubleQuoteString(stream, state) {
var ch;
while ((ch = stream.peek()) != null) {
if (ch === '$') {
state.tokenize = tokenStringInterpolation;
return 'string';
}
stream.next();
if (ch === '`') {
stream.next();
continue;
}
if (ch === '"' && !stream.eat('"')) {
state.tokenize = tokenBase;
return 'string';
}
}
return 'error';
}
function tokenStringInterpolation(stream, state) {
return tokenInterpolation(stream, state, tokenDoubleQuoteString);
}
function tokenMultiStringReturn(stream, state) {
state.tokenize = tokenMultiString;
state.startQuote = '"'
return tokenMultiString(stream, state);
}
function tokenHereStringInterpolation(stream, state) {
return tokenInterpolation(stream, state, tokenMultiStringReturn);
}
function tokenInterpolation(stream, state, parentTokenize) {
if (stream.match('$(')) {
var savedBracketNesting = state.bracketNesting;
state.returnStack.push({
/*jshint loopfunc:true */
shouldReturnFrom: function(state) {
return state.bracketNesting === savedBracketNesting;
},
tokenize: parentTokenize
});
state.tokenize = tokenBase;
state.bracketNesting += 1;
return 'punctuation';
} else {
stream.next();
state.returnStack.push({
shouldReturnFrom: function() { return true; },
tokenize: parentTokenize
});
state.tokenize = tokenVariable;
return state.tokenize(stream, state);
}
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while ((ch = stream.next()) != null) {
if (maybeEnd && ch == '>') {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch === '#');
}
return 'comment';
}
function tokenVariable(stream, state) {
var ch = stream.peek();
if (stream.eat('{')) {
state.tokenize = tokenVariableWithBraces;
return tokenVariableWithBraces(stream, state);
} else if (ch != undefined && ch.match(varNames)) {
stream.eatWhile(varNames);
state.tokenize = tokenBase;
return 'variable-2';
} else {
state.tokenize = tokenBase;
return 'error';
}
}
function tokenVariableWithBraces(stream, state) {
var ch;
while ((ch = stream.next()) != null) {
if (ch === '}') {
state.tokenize = tokenBase;
break;
}
}
return 'variable-2';
}
function tokenMultiString(stream, state) {
var quote = state.startQuote;
if (stream.sol() && stream.match(new RegExp(quote + '@'))) {
state.tokenize = tokenBase;
}
else if (quote === '"') {
while (!stream.eol()) {
var ch = stream.peek();
if (ch === '$') {
state.tokenize = tokenHereStringInterpolation;
return 'string';
}
stream.next();
if (ch === '`') {
stream.next();
}
}
}
else {
stream.skipToEnd();
}
return 'string';
}
var external = {
startState: function() {
return {
returnStack: [],
bracketNesting: 0,
tokenize: tokenBase
};
},
token: function(stream, state) {
return state.tokenize(stream, state);
},
blockCommentStart: '<#',
blockCommentEnd: '#>',
lineComment: '#',
fold: 'brace'
};
return external;
});
CodeMirror.defineMIME('application/x-powershell', 'powershell');
});

View file

@ -0,0 +1,72 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "powershell");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT('comment', '[number 1][comment # A]');
MT('comment_multiline', '[number 1][comment <#]',
'[comment ABC]',
'[comment #>][number 2]');
[
'0', '1234',
'12kb', '12mb', '12Gb', '12Tb', '12PB', '12L', '12D', '12lkb', '12dtb',
'1.234', '1.234e56', '1.', '1.e2', '.2', '.2e34',
'1.2MB', '1.kb', '.1dTB', '1.e1gb', '.2', '.2e34',
'0x1', '0xabcdef', '0x3tb', '0xelmb'
].forEach(function(number) {
MT("number_" + number, "[number " + number + "]");
});
MT('string_literal_escaping', "[string 'a''']");
MT('string_literal_variable', "[string 'a $x']");
MT('string_escaping_1', '[string "a `""]');
MT('string_escaping_2', '[string "a """]');
MT('string_variable_escaping', '[string "a `$x"]');
MT('string_variable', '[string "a ][variable-2 $x][string b"]');
MT('string_variable_spaces', '[string "a ][variable-2 ${x y}][string b"]');
MT('string_expression', '[string "a ][punctuation $(][variable-2 $x][operator +][number 3][punctuation )][string b"]');
MT('string_expression_nested', '[string "A][punctuation $(][string "a][punctuation $(][string "w"][punctuation )][string b"][punctuation )][string B"]');
MT('string_heredoc', '[string @"]',
'[string abc]',
'[string "@]');
MT('string_heredoc_quotes', '[string @"]',
'[string abc "\']',
'[string "@]');
MT('string_heredoc_variable', '[string @"]',
'[string a ][variable-2 $x][string b]',
'[string "@]');
MT('string_heredoc_nested_string', '[string @"]',
'[string a][punctuation $(][string "w"][punctuation )][string b]',
'[string "@]');
MT('string_heredoc_literal_quotes', "[string @']",
'[string abc "\']',
"[string '@]");
MT('array', "[punctuation @(][string 'a'][punctuation ,][string 'b'][punctuation )]");
MT('hash', "[punctuation @{][string 'key'][operator :][string 'value'][punctuation }]");
MT('variable', "[variable-2 $test]");
MT('variable_global', "[variable-2 $global:test]");
MT('variable_spaces', "[variable-2 ${test test}]");
MT('operator_splat', "[variable-2 @x]");
MT('variable_builtin', "[builtin $ErrorActionPreference]");
MT('variable_builtin_symbols', "[builtin $$]");
MT('operator', "[operator +]");
MT('operator_unary', "[operator +][number 3]");
MT('operator_long', "[operator -match]");
[
'(', ')', '[[', ']]', '{', '}', ',', '`', ';', '.'
].forEach(function(punctuation) {
MT("punctuation_" + punctuation.replace(/^[\[\]]/,''), "[punctuation " + punctuation + "]");
});
MT('keyword', "[keyword if]");
MT('call_builtin', "[builtin Get-ChildItem]");
})();