1;(function()
2{
3	// CommonJS
4	SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
5
6	function Brush()
7	{
8		// Contributed by Joel 'Jaykul' Bennett, http://PoshCode.org | http://HuddledMasses.org
9		var keywords =	'while validateset validaterange validatepattern validatelength validatecount ' +
10						'until trap switch return ref process param parameter in if global: '+
11						'function foreach for finally filter end elseif else dynamicparam do default ' +
12						'continue cmdletbinding break begin alias \\? % #script #private #local #global '+
13						'mandatory parametersetname position valuefrompipeline ' +
14						'valuefrompipelinebypropertyname valuefromremainingarguments helpmessage ';
15
16		var operators =	' and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle ' +
17						'clike clt cmatch cne cnotcontains cnotlike cnotmatch contains ' +
18						'creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt ' +
19						'imatch ine inotcontains inotlike inotmatch ireplace is isnot le like ' +
20						'lt match ne not notcontains notlike notmatch or regex replace wildcard';
21
22		var verbs =		'write where wait use update unregister undo trace test tee take suspend ' +
23						'stop start split sort skip show set send select scroll resume restore ' +
24						'restart resolve resize reset rename remove register receive read push ' +
25						'pop ping out new move measure limit join invoke import group get format ' +
26						'foreach export expand exit enter enable disconnect disable debug cxnew ' +
27						'copy convertto convertfrom convert connect complete compare clear ' +
28						'checkpoint aggregate add';
29
30		// I can't find a way to match the comment based help in multi-line comments, because SH won't highlight in highlights, and javascript doesn't support lookbehind
31		var commenthelp = ' component description example externalhelp forwardhelpcategory forwardhelptargetname forwardhelptargetname functionality inputs link notes outputs parameter remotehelprunspace role synopsis';
32
33		this.regexList = [
34			{ regex: new RegExp('^\\s*#[#\\s]*\\.('+this.getKeywords(commenthelp)+').*$', 'gim'),			css: 'preprocessor help bold' },		// comment-based help
35			{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments,										css: 'comments' },						// one line comments
36			{ regex: /(&lt;|<)#[\s\S]*?#(&gt;|>)/gm,														css: 'comments here' },					// multi-line comments
37
38			{ regex: new RegExp('@"\\n[\\s\\S]*?\\n"@', 'gm'),												css: 'script string here' },			// double quoted here-strings
39			{ regex: new RegExp("@'\\n[\\s\\S]*?\\n'@", 'gm'),												css: 'script string single here' },		// single quoted here-strings
40			{ regex: new RegExp('"(?:\\$\\([^\\)]*\\)|[^"]|`"|"")*[^`]"','g'),								css: 'string' },						// double quoted strings
41			{ regex: new RegExp("'(?:[^']|'')*'", 'g'),														css: 'string single' },					// single quoted strings
42
43			{ regex: new RegExp('[\\$|@|@@](?:(?:global|script|private|env):)?[A-Z0-9_]+', 'gi'),			css: 'variable' },						// $variables
44			{ regex: new RegExp('(?:\\b'+verbs.replace(/ /g, '\\b|\\b')+')-[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'),	css: 'functions' },						// functions and cmdlets
45			{ regex: new RegExp(this.getKeywords(keywords), 'gmi'),											css: 'keyword' },						// keywords
46			{ regex: new RegExp('-'+this.getKeywords(operators), 'gmi'),									css: 'operator value' },				// operators
47			{ regex: new RegExp('\\[[A-Z_\\[][A-Z0-9_. `,\\[\\]]*\\]', 'gi'),								css: 'constants' },						// .Net [Type]s
48			{ regex: new RegExp('\\s+-(?!'+this.getKeywords(operators)+')[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'),	css: 'color1' },						// parameters
49		];
50	};
51
52	Brush.prototype	= new SyntaxHighlighter.Highlighter();
53	Brush.aliases	= ['powershell', 'ps', 'posh'];
54
55	SyntaxHighlighter.brushes.PowerShell = Brush;
56
57	// CommonJS
58	typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
59})();
60