src/cm/media/js/lib/yui/yui_3.0.0b1/assets/dpSyntaxHighlighter.js
author raph
Fri, 15 Jan 2010 09:21:47 +0100
changeset 82 2d964b42de45
parent 0 40c8f766c9b8
permissions -rw-r--r--
fix howto generate message files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
/**
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
 * Code Syntax Highlighter.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
 * Version 1.3.0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     4
 * Copyright (C) 2004 Alex Gorbatchev.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     5
 * http://www.dreamprojections.com/syntaxhighlighter/
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     6
 * 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     7
 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     8
 * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     9
 * any later version.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    10
 *
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    11
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    13
 * details.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    14
 *
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    16
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    17
 */
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    18
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    20
// create namespaces
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    21
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    22
var dp = {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    23
	sh :					// dp.sh
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    24
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    25
		Utils	: {},		// dp.sh.Utils
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    26
		Brushes	: {},		// dp.sh.Brushes
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    27
		Strings : {},
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    28
		Version : '1.3.0'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    29
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    30
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    31
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    32
dp.sh.Strings = {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    33
	AboutDialog : '<html><head><title>About...</title></head><body class="dp-about"><table cellspacing="0"><tr><td class="copy"><p class="title">dp.SyntaxHighlighter</div><div class="para">Version: {V}</p><p><a href="http://www.dreamprojections.com/syntaxhighlighter/?ref=about" target="_blank">http://www.dreamprojections.com/SyntaxHighlighter</a></p>&copy;2004-2005 Alex Gorbatchev. All right reserved.</td></tr><tr><td class="footer"><input type="button" class="close" value="OK" onClick="window.close()"/></td></tr></table></body></html>',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    34
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    35
	// tools
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    36
	ExpandCode : '+ expand code',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    37
	ViewPlain : 'view plain',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    38
	Print : 'print',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    39
	CopyToClipboard : 'copy to clipboard',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    40
	About : '?',
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    41
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    42
	CopiedToClipboard : 'The code is in your clipboard now.'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    43
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    44
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    45
dp.SyntaxHighlighter = dp.sh;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    46
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    47
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    48
// Dialog and toolbar functions
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    49
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    50
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    51
dp.sh.Utils.Expand = function(sender)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    52
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    53
	var table = sender;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    54
	var span = sender;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    55
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    56
	// find the span in which the text label and pipe contained so we can hide it
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    57
	while(span != null && span.tagName != 'SPAN')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    58
		span = span.parentNode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    59
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    60
	// find the table
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    61
	while(table != null && table.tagName != 'TABLE')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    62
		table = table.parentNode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    63
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    64
	// remove the 'expand code' button
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    65
	span.parentNode.removeChild(span);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    66
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    67
	table.tBodies[0].className = 'show';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    68
	table.parentNode.style.height = '100%'; // containing div isn't getting updated properly when the TBODY is shown
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    69
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    70
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    71
// opens a new windows and puts the original unformatted source code inside.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    72
dp.sh.Utils.ViewSource = function(sender)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    73
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    74
	var code = sender.parentNode.originalCode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    75
	var wnd = window.open('', '_blank', 'width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=1');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    76
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    77
	code = code.replace(/</g, '&lt;');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    78
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    79
	wnd.document.write('<pre>' + code + '</pre>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    80
	wnd.document.close();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    81
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    82
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    83
// copies the original source code in to the clipboard (IE only)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    84
dp.sh.Utils.ToClipboard = function(sender)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    85
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    86
	var code = sender.parentNode.originalCode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    87
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    88
	// This works only for IE. There's a way to make it work with Mozilla as well,
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    89
	// but it requires security settings changed on the client, which isn't by
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    90
	// default, so 99% of users won't have it working anyways.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    91
	if(window.clipboardData)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    92
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    93
		window.clipboardData.setData('text', code);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    94
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    95
		alert(dp.sh.Strings.CopiedToClipboard);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    96
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    97
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    98
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    99
// creates an invisible iframe, puts the original source code inside and prints it
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   100
dp.sh.Utils.PrintSource = function(sender)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   101
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   102
	var td		= sender.parentNode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   103
	var code	= td.processedCode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   104
	var iframe	= document.createElement('IFRAME');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   105
	var doc		= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   106
	var wnd		= 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   107
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   108
	// this hides the iframe
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   109
	iframe.style.cssText = 'position:absolute; width:0px; height:0px; left:-5px; top:-5px;';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   110
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   111
	td.appendChild(iframe);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   112
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   113
	doc = iframe.contentWindow.document;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   114
	code = code.replace(/</g, '&lt;');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   115
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   116
	doc.open();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   117
	doc.write('<pre>' + code + '</pre>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   118
	doc.close();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   119
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   120
	iframe.contentWindow.focus();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   121
	iframe.contentWindow.print();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   122
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   123
	td.removeChild(iframe);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   124
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   125
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   126
dp.sh.Utils.About = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   127
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   128
	var wnd	= window.open('', '_blank', 'dialog,width=320,height=150,scrollbars=0');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   129
	var doc	= wnd.document;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   130
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   131
	var styles = document.getElementsByTagName('style');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   132
	var links = document.getElementsByTagName('link');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   133
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   134
	doc.write(dp.sh.Strings.AboutDialog.replace('{V}', dp.sh.Version));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   135
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   136
	// copy over ALL the styles from the parent page
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   137
	for(var i = 0; i < styles.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   138
		doc.write('<style>' + styles[i].innerHTML + '</style>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   139
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   140
	for(var i = 0; i < links.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   141
		if(links[i].rel.toLowerCase() == 'stylesheet')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   142
			doc.write('<link type="text/css" rel="stylesheet" href="' + links[i].href + '"></link>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   143
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   144
	doc.close();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   145
	wnd.focus();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   146
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   147
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   148
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   149
// Match object
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   150
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   151
dp.sh.Match = function(value, index, css)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   152
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   153
	this.value		= value;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   154
	this.index		= index;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   155
	this.length		= value.length;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   156
	this.css		= css;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   157
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   158
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   159
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   160
// Highlighter object
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   161
//
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   162
dp.sh.Highlighter = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   163
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   164
	this.addGutter = true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   165
	this.addControls = true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   166
	this.collapse = false;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   167
	this.tabsToSpaces = true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   168
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   169
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   170
// static callback for the match sorting
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   171
dp.sh.Highlighter.SortCallback = function(m1, m2)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   172
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   173
	// sort matches by index first
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   174
	if(m1.index < m2.index)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   175
		return -1;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   176
	else if(m1.index > m2.index)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   177
		return 1;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   178
	else
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   179
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   180
		// if index is the same, sort by length
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   181
		if(m1.length < m2.length)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   182
			return -1;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   183
		else if(m1.length > m2.length)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   184
			return 1;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   185
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   186
	return 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   187
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   188
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   189
// gets a list of all matches for a given regular expression
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   190
dp.sh.Highlighter.prototype.GetMatches = function(regex, css)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   191
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   192
	var index = 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   193
	var match = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   194
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   195
	while((match = regex.exec(this.code)) != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   196
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   197
		this.matches[this.matches.length] = new dp.sh.Match(match[0], match.index, css);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   198
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   199
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   200
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   201
dp.sh.Highlighter.prototype.AddBit = function(str, css)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   202
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   203
	var span = document.createElement('span');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   204
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   205
	str = str.replace(/&/g, '&amp;');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   206
	str = str.replace(/ /g, '&nbsp;');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   207
	str = str.replace(/</g, '&lt;');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   208
	str = str.replace(/\n/gm, '&nbsp;<br>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   209
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   210
	// when adding a piece of code, check to see if it has line breaks in it 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   211
	// and if it does, wrap individual line breaks with span tags
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   212
	if(css != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   213
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   214
		var regex = new RegExp('<br>', 'gi');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   215
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   216
		if(regex.test(str))
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   217
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   218
			var lines = str.split('&nbsp;<br>');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   219
			
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   220
			str = '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   221
			
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   222
			for(var i = 0; i < lines.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   223
			{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   224
				span			= document.createElement('SPAN');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   225
				span.className	= css;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   226
				span.innerHTML	= lines[i];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   227
				
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   228
				this.div.appendChild(span);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   229
				
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   230
				// don't add a <BR> for the last line
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   231
				if(i + 1 < lines.length)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   232
					this.div.appendChild(document.createElement('BR'));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   233
			}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   234
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   235
		else
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   236
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   237
			span.className = css;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   238
			span.innerHTML = str;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   239
			this.div.appendChild(span);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   240
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   241
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   242
	else
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   243
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   244
		span.innerHTML = str;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   245
		this.div.appendChild(span);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   246
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   247
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   248
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   249
// checks if one match is inside any other match
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   250
dp.sh.Highlighter.prototype.IsInside = function(match)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   251
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   252
	if(match == null || match.length == 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   253
		return;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   254
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   255
	for(var i = 0; i < this.matches.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   256
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   257
		var c = this.matches[i];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   258
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   259
		if(c == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   260
			continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   261
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   262
		if((match.index > c.index) && (match.index <= c.index + c.length))
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   263
			return true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   264
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   265
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   266
	return false;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   267
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   268
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   269
dp.sh.Highlighter.prototype.ProcessRegexList = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   270
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   271
	for(var i = 0; i < this.regexList.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   272
		this.GetMatches(this.regexList[i].regex, this.regexList[i].css);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   273
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   274
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   275
dp.sh.Highlighter.prototype.ProcessSmartTabs = function(code)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   276
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   277
	var lines	= code.split('\n');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   278
	var result	= '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   279
	var tabSize	= 4;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   280
	var tab		= '\t';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   281
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   282
	// This function inserts specified amount of spaces in the string
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   283
	// where a tab is while removing that given tab. 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   284
	function InsertSpaces(line, pos, count)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   285
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   286
		var left	= line.substr(0, pos);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   287
		var right	= line.substr(pos + 1, line.length);	// pos + 1 will get rid of the tab
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   288
		var spaces	= '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   289
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   290
		for(var i = 0; i < count; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   291
			spaces += ' ';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   292
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   293
		return left + spaces + right;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   294
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   295
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   296
	// This function process one line for 'smart tabs'
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   297
	function ProcessLine(line, tabSize)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   298
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   299
		if(line.indexOf(tab) == -1)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   300
			return line;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   301
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   302
		var pos = 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   303
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   304
		while((pos = line.indexOf(tab)) != -1)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   305
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   306
			// This is pretty much all there is to the 'smart tabs' logic.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   307
			// Based on the position within the line and size of a tab, 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   308
			// calculate the amount of spaces we need to insert.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   309
			var spaces = tabSize - pos % tabSize;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   310
			
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   311
			line = InsertSpaces(line, pos, spaces);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   312
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   313
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   314
		return line;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   315
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   316
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   317
	// Go through all the lines and do the 'smart tabs' magic.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   318
	for(var i = 0; i < lines.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   319
		result += ProcessLine(lines[i], tabSize) + '\n';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   320
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   321
	return result;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   322
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   323
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   324
dp.sh.Highlighter.prototype.SwitchToTable = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   325
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   326
	// thanks to Lachlan Donald from SitePoint.com for this <br/> tag fix.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   327
	var html	= this.div.innerHTML.replace(/<(br)\/?>/gi, '\n');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   328
	var lines	= html.split('\n');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   329
	var row		= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   330
	var cell	= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   331
	var tBody	= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   332
	var html	= '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   333
	var pipe	= ' | ';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   334
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   335
	// creates an anchor to a utility
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   336
	function UtilHref(util, text)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   337
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   338
		return '<a href="#" onclick="dp.sh.Utils.' + util + '(this); return false;">' + text + '</a>';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   339
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   340
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   341
	tBody = document.createElement('TBODY');	// can be created and all others go to tBodies collection.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   342
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   343
	this.table.appendChild(tBody);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   344
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   345
	if(this.addGutter == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   346
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   347
		row = tBody.insertRow(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   348
		cell = row.insertCell(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   349
		cell.className = 'tools-corner';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   350
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   351
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   352
	if(this.addControls == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   353
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   354
		var tHead = document.createElement('THEAD');	// controls will be placed in here
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   355
		this.table.appendChild(tHead);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   356
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   357
		row = tHead.insertRow(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   358
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   359
		// add corner if there's a gutter
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   360
		if(this.addGutter == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   361
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   362
			cell = row.insertCell(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   363
			cell.className = 'tools-corner';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   364
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   365
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   366
		cell = row.insertCell(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   367
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   368
		// preserve some variables for the controls
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   369
		cell.originalCode = this.originalCode;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   370
		cell.processedCode = this.code;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   371
		cell.className = 'tools';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   372
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   373
		if(this.collapse == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   374
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   375
			tBody.className = 'hide';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   376
			cell.innerHTML += '<span><b>' + UtilHref('Expand', dp.sh.Strings.ExpandCode) + '</b>' + pipe + '</span>';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   377
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   378
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   379
		cell.innerHTML += UtilHref('ViewSource', dp.sh.Strings.ViewPlain) + pipe + UtilHref('PrintSource', dp.sh.Strings.Print);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   380
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   381
		// IE has this clipboard object which is easy enough to use
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   382
		if(window.clipboardData)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   383
			cell.innerHTML += pipe + UtilHref('ToClipboard', dp.sh.Strings.CopyToClipboard);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   384
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   385
		cell.innerHTML += pipe + UtilHref('About', dp.sh.Strings.About);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   386
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   387
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   388
	for(var i = 0, lineIndex = this.firstLine; i < lines.length - 1; i++, lineIndex++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   389
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   390
		row = tBody.insertRow(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   391
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   392
		if(this.addGutter == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   393
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   394
			cell = row.insertCell(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   395
			cell.className = 'gutter';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   396
			cell.innerHTML = lineIndex;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   397
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   398
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   399
		cell = row.insertCell(-1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   400
		cell.className = 'line' + (i % 2 + 1);		// uses .line1 and .line2 css styles for alternating lines
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   401
		cell.innerHTML = lines[i];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   402
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   403
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   404
	this.div.innerHTML	= '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   405
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   406
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   407
dp.sh.Highlighter.prototype.Highlight = function(code)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   408
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   409
	function Trim(str)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   410
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   411
		return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   412
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   413
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   414
	function Chop(str)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   415
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   416
		return str.replace(/\n*$/, '').replace(/^\n*/, '');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   417
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   418
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   419
	function Unindent(str)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   420
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   421
		var lines = str.split('\n');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   422
		var indents = new Array();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   423
		var regex = new RegExp('^\\s*', 'g');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   424
		var min = 1000;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   425
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   426
		// go through every line and check for common number of indents
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   427
		for(var i = 0; i < lines.length && min > 0; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   428
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   429
			if(Trim(lines[i]).length == 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   430
				continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   431
				
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   432
			var matches = regex.exec(lines[i]);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   433
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   434
			if(matches != null && matches.length > 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   435
				min = Math.min(matches[0].length, min);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   436
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   437
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   438
		// trim minimum common number of white space from the begining of every line
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   439
		if(min > 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   440
			for(var i = 0; i < lines.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   441
				lines[i] = lines[i].substr(min);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   442
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   443
		return lines.join('\n');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   444
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   445
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   446
	// This function returns a portions of the string from pos1 to pos2 inclusive
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   447
	function Copy(string, pos1, pos2)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   448
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   449
		return string.substr(pos1, pos2 - pos1);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   450
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   451
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   452
	var pos	= 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   453
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   454
	this.originalCode = code;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   455
	this.code = Chop(Unindent(code));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   456
	this.div = document.createElement('DIV');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   457
	this.table = document.createElement('TABLE');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   458
	this.matches = new Array();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   459
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   460
	if(this.CssClass != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   461
		this.table.className = this.CssClass;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   462
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   463
	// replace tabs with spaces
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   464
	if(this.tabsToSpaces == true)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   465
		this.code = this.ProcessSmartTabs(this.code);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   466
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   467
	this.table.border = 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   468
	this.table.cellSpacing = 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   469
	this.table.cellPadding = 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   470
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   471
	this.ProcessRegexList();	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   472
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   473
	// if no matches found, add entire code as plain text
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   474
	if(this.matches.length == 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   475
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   476
		this.AddBit(this.code, null);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   477
		this.SwitchToTable();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   478
		return;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   479
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   480
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   481
	// sort the matches
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   482
	this.matches = this.matches.sort(dp.sh.Highlighter.SortCallback);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   483
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   484
	// The following loop checks to see if any of the matches are inside
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   485
	// of other matches. This process would get rid of highligting strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   486
	// inside comments, keywords inside strings and so on.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   487
	for(var i = 0; i < this.matches.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   488
		if(this.IsInside(this.matches[i]))
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   489
			this.matches[i] = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   490
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   491
	// Finally, go through the final list of matches and pull the all
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   492
	// together adding everything in between that isn't a match.
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   493
	for(var i = 0; i < this.matches.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   494
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   495
		var match = this.matches[i];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   496
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   497
		if(match == null || match.length == 0)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   498
			continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   499
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   500
		this.AddBit(Copy(this.code, pos, match.index), null);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   501
		this.AddBit(match.value, match.css);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   502
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   503
		pos = match.index + match.length;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   504
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   505
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   506
	this.AddBit(this.code.substr(pos), null);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   507
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   508
	this.SwitchToTable();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   509
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   510
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   511
dp.sh.Highlighter.prototype.GetKeywords = function(str) 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   512
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   513
	return '\\b' + str.replace(/ /g, '\\b|\\b') + '\\b';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   514
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   515
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   516
// highlightes all elements identified by name and gets source code from specified property
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   517
dp.sh.HighlightAll = function(name, showGutter /* optional */, showControls /* optional */, collapseAll /* optional */, firstLine /* optional */)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   518
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   519
	function FindValue()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   520
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   521
		var a = arguments;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   522
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   523
		for(var i = 0; i < a.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   524
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   525
			if(a[i] == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   526
				continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   527
				
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   528
			if(typeof(a[i]) == 'string' && a[i] != '')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   529
				return a[i] + '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   530
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   531
			if(typeof(a[i]) == 'object' && a[i].value != '')
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   532
				return a[i].value + '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   533
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   534
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   535
		return null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   536
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   537
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   538
	function IsOptionSet(value, list)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   539
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   540
		for(var i = 0; i < list.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   541
			if(list[i] == value)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   542
				return true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   543
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   544
		return false;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   545
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   546
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   547
	function GetOptionValue(name, list, defaultValue)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   548
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   549
		var regex = new RegExp('^' + name + '\\[(\\w+)\\]$', 'gi');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   550
		var matches = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   551
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   552
		for(var i = 0; i < list.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   553
			if((matches = regex.exec(list[i])) != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   554
				return matches[1];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   555
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   556
		return defaultValue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   557
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   558
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   559
	var elements = document.getElementsByName(name);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   560
	var highlighter = null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   561
	var registered = new Object();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   562
	var propertyName = 'value';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   563
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   564
	// if no code blocks found, leave
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   565
	if(elements == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   566
		return;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   567
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   568
	// register all brushes
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   569
	for(var brush in dp.sh.Brushes)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   570
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   571
		var aliases = dp.sh.Brushes[brush].Aliases;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   572
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   573
		if(aliases == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   574
			continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   575
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   576
		for(var i = 0; i < aliases.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   577
			registered[aliases[i]] = brush;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   578
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   579
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   580
	for(var i = 0; i < elements.length; i++)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   581
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   582
		var element = elements[i];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   583
		var options = FindValue(
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   584
				element.attributes['class'], element.className, 
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   585
				element.attributes['language'], element.language
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   586
				);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   587
		var language = '';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   588
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   589
		if(options == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   590
			continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   591
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   592
		options = options.split(':');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   593
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   594
		language = options[0].toLowerCase();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   595
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   596
		if(registered[language] == null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   597
			continue;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   598
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   599
		// instantiate a brush
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   600
		highlighter = new dp.sh.Brushes[registered[language]]();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   601
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   602
		// hide the original element
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   603
		element.style.display = 'none';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   604
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   605
		highlighter.addGutter = (showGutter == null) ? !IsOptionSet('nogutter', options) : showGutter;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   606
		highlighter.addControls = (showControls == null) ? !IsOptionSet('nocontrols', options) : showControls;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   607
		highlighter.collapse = (collapseAll == null) ? IsOptionSet('collapse', options) : collapseAll;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   608
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   609
		// first line idea comes from Andrew Collington, thanks!
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   610
		highlighter.firstLine = (firstLine == null) ? parseInt(GetOptionValue('firstline', options, 1)) : firstLine;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   611
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   612
		highlighter.Highlight(element[propertyName]);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   613
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   614
		// place the result table inside a div
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   615
		var div = document.createElement('DIV');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   616
		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   617
		div.className = 'dp-highlighter';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   618
		div.appendChild(highlighter.table);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   619
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   620
		element.parentNode.insertBefore(div, element);		
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   621
	}	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   622
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   623
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   624
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   625
dp.sh.Brushes.Xml = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   626
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   627
	this.CssClass = 'dp-xml';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   628
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   629
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   630
dp.sh.Brushes.Xml.prototype	= new dp.sh.Highlighter();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   631
dp.sh.Brushes.Xml.Aliases	= ['xml', 'xhtml', 'xslt', 'html', 'xhtml'];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   632
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   633
dp.sh.Brushes.Xml.prototype.ProcessRegexList = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   634
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   635
	function push(array, value)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   636
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   637
		array[array.length] = value;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   638
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   639
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   640
	/* If only there was a way to get index of a group within a match, the whole XML
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   641
	   could be matched with the expression looking something like that:
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   642
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   643
	   (<!\[CDATA\[\s*.*\s*\]\]>)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   644
	   | (<!--\s*.*\s*?-->)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   645
	   | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)*
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   646
	   | (</?)(.*?)(/?>)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   647
	*/
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   648
	var index	= 0;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   649
	var match	= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   650
	var regex	= null;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   651
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   652
	// Match CDATA in the following format <![ ... [ ... ]]>
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   653
	// <\!\[[\w\s]*?\[(.|\s)*?\]\]>
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   654
	this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   655
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   656
	// Match comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   657
	// <!--\s*.*\s*?-->
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   658
	this.GetMatches(new RegExp('<!--\\s*.*\\s*?-->', 'gm'), 'comments');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   659
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   660
	// Match attributes and their values
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   661
	// (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)*
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   662
	regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   663
	while((match = regex.exec(this.code)) != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   664
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   665
		push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute'));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   666
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   667
		// if xml is invalid and attribute has no property value, ignore it	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   668
		if(match[2] != undefined)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   669
		{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   670
			push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value'));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   671
		}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   672
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   673
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   674
	// Match opening and closing tag brackets
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   675
	// </*\?*(?!\!)|/*\?*>
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   676
	this.GetMatches(new RegExp('</*\\?*(?!\\!)|/*\\?*>', 'gm'), 'tag');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   677
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   678
	// Match tag names
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   679
	// </*\?*\s*(\w+)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   680
	regex = new RegExp('</*\\?*\\s*([\\w-\.]+)', 'gm');
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   681
	while((match = regex.exec(this.code)) != null)
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   682
	{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   683
		push(this.matches, new dp.sh.Match(match[1], match.index + match[0].indexOf(match[1]), 'tag-name'));
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   684
	}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   685
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   686
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   687
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   688
dp.sh.Brushes.Php = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   689
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   690
	var keywords =	'and or xor __FILE__ __LINE__ array as break case ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   691
					'cfunction class const continue declare default die do echo else ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   692
					'elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exit ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   693
					'extends for foreach function global if include include_once isset list ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   694
					'new old_function print require require_once return static switch unset use ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   695
					'var while __FUNCTION__ __CLASS__';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   696
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   697
	this.regexList = [
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   698
		{ regex: new RegExp('//.*$', 'gm'),							css: 'comment' },			// one line comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   699
		{ regex: new RegExp('/\\*[\\s\\S]*?\\*/', 'g'),				css: 'comment' },			// multiline comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   700
		{ regex: new RegExp('"(?:[^"\n]|[\"])*?"', 'g'),			css: 'string' },			// double quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   701
		{ regex: new RegExp("'(?:[^'\n]|[\'])*?'", 'g'),			css: 'string' },			// single quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   702
		{ regex: new RegExp('\\$\\w+', 'g'),						css: 'vars' },				// variables
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   703
		{ regex: new RegExp(this.GetKeywords(keywords), 'gm'),		css: 'keyword' }			// keyword
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   704
		];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   705
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   706
	this.CssClass = 'dp-c';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   707
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   708
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   709
dp.sh.Brushes.Php.prototype	= new dp.sh.Highlighter();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   710
dp.sh.Brushes.Php.Aliases	= ['php'];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   711
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   712
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   713
dp.sh.Brushes.JScript = function()
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   714
{
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   715
	var keywords =	'abstract boolean break byte case catch char class const continue debugger ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   716
					'default delete do double else enum export extends false final finally float ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   717
					'for function goto if implements import in instanceof int interface long native ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   718
					'new null package private protected public return short static super switch ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   719
					'synchronized this throw throws transient true try typeof var void volatile while with';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   720
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   721
	this.regexList = [
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   722
		{ regex: new RegExp('//.*$', 'gm'),							css: 'comment' },			// one line comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   723
		{ regex: new RegExp('/\\*[\\s\\S]*?\\*/', 'g'),				css: 'comment' },			// multiline comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   724
		{ regex: new RegExp('"(?:[^"\n]|[\"])*?"', 'g'),			css: 'string' },			// double quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   725
		{ regex: new RegExp("'(?:[^'\n]|[\'])*?'", 'g'),			css: 'string' },			// single quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   726
		{ regex: new RegExp('^\\s*#.*', 'gm'),						css: 'preprocessor' },		// preprocessor tags like #region and #endregion
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   727
		{ regex: new RegExp(this.GetKeywords(keywords), 'gm'),		css: 'keyword' }			// keywords
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   728
		];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   729
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   730
	this.CssClass = 'dp-c';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   731
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   732
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   733
dp.sh.Brushes.JScript.prototype	= new dp.sh.Highlighter();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   734
dp.sh.Brushes.JScript.Aliases	= ['js', 'jscript', 'javascript'];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   735
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   736
dp.sh.Brushes.CSS = function() {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   737
    //Not used yet - added to values
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   738
    var tags = 'abbr acronym address applet area a b base basefont bdo big blockquote body br button ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   739
            'caption center cite code col colgroup dd del dfn dir div dl dt em fieldset form frame frameset h1 h2 h3 h4 h5 h6 head hr html img i ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   740
            'iframe img input ins isindex kbd label legend li link map menu meta noframes noscript ol optgroup option p param pre q s samp script select ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   741
            'span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt ul u';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   742
	var keywords =	'ascent azimuth background-attachment background-color background-image background-position ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   743
			'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   744
			'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   745
			'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   746
			'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   747
			'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   748
			'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   749
			'height letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   750
			'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   751
			'outline-color outline-style outline-width outline overflow-x overflow-y overflow padding-top padding-right padding-bottom padding-left padding page ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   752
			'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   753
			'quotes richness right left bottom top size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   754
			'table-layout text-align text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   755
			'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index zoom important after filter opacity';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   756
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   757
    var values = 'progid:DXImageTransform.Microsoft.AlphaImageLoader src sizingMethod alpha opacity ' +
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   758
            'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder both bottom braille capitalize center center-left center-right circle close-quote code collapse compact condensed '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   759
			'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   760
			'gray green groove handheld hebrew help hidden hide high higher inline-table inline inset inside invert italic justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   761
			'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   762
			'outside overline pointer portrait print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   763
			'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   764
			'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   765
	
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   766
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   767
	this.regexList = [
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   768
		{ regex: new RegExp('//.*$', 'gm'),							css: 'comment' },			// one line comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   769
		{ regex: new RegExp('/\\*[\\s\\S]*?\\*/', 'g'),				css: 'comment' },			// multiline comments
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   770
		{ regex: new RegExp('"(?:[^"\n]|[\"])*?"', 'g'),			css: 'string' },			// double quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   771
		{ regex: new RegExp("'(?:[^'\n]|[\'])*?'", 'g'),			css: 'string' },			// single quoted strings
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   772
		{ regex: new RegExp('^\\s*.*{', 'gm'),						css: 'preprocessor' },		// everything before a {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   773
		{ regex: new RegExp('}', 'gm'),						css: 'preprocessor' },		// The }
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   774
		{ regex: new RegExp(this.GetKeywordsCSS(keywords), 'gm'),		css: 'keyword' },		// keywords
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   775
		{ regex: new RegExp(this.GetValuesCSS(values), 'gm'),		css: 'value' },			// values
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   776
        { regex: new RegExp('(-?\\d+)(\.\\d+)?(px|em|pt|\:|\%|)', 'g'),  css: 'value' }        //Sizes
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   777
		];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   778
        //Not used any more
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   779
        /*
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   780
        { regex: new RegExp('(-?\\d+)(\.\\d+)', 'g'),  css: 'value' },        //Plain Numbers
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   781
        { regex: new RegExp('(0(?=;))', 'g'),  css: 'value' }        //Number 0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   782
		{ regex: new RegExp('\([.]\)', 'gm'),			css: 'string' },			// Things in parenthesis
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   783
        { regex: new RegExp('\\#[a-zA-Z0-9]{3,6}', 'g'),            css: 'colors' },            // html colors  
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   784
		{ regex: new RegExp(this.GetKeywords(tags), 'g'),		css: 'tags' },			// keywords
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   785
        */
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   786
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   787
	this.CssClass = 'dp-css';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   788
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   789
dp.sh.Highlighter.prototype.GetKeywordsCSS = function(str) {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   790
	//var str = '\\b' + str.replace(/ /g, '(?=:)\\b|\\b') + '\:\\b';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   791
	var str = '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   792
    //console.log(str);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   793
    return str;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   794
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   795
dp.sh.Highlighter.prototype.GetValuesCSS = function(str) {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   796
	var str = '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b';
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   797
    //console.log(str);
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   798
    return str;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   799
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   800
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   801
dp.sh.Brushes.CSS.prototype	= new dp.sh.Highlighter();
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   802
dp.sh.Brushes.CSS.Aliases	= ['css'];
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   803
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   804
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   805