3
* http://alexgorbatchev.com/
5
* SyntaxHighlighter is donationware. If you are using it, please donate.
6
* http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
9
* 2.0.296 (March 01 2009)
12
* Copyright (C) 2004-2009 Alex Gorbatchev.
15
* This file is part of SyntaxHighlighter.
17
* SyntaxHighlighter is free software: you can redistribute it and/or modify
18
* it under the terms of the GNU General Public License as published by
19
* the Free Software Foundation, either version 3 of the License, or
20
* (at your option) any later version.
22
* SyntaxHighlighter is distributed in the hope that it will be useful,
23
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
* GNU General Public License for more details.
27
* You should have received a copy of the GNU General Public License
28
* along with SyntaxHighlighter. If not, see <http://www.gnu.org/licenses/>.
31
SyntaxHighlighter : {}
34
dp.SyntaxHighlighter = {
35
parseParams: function(
44
function getValue(list, name)
46
var regex = new XRegExp('^' + name + '\\[(?<value>\\w+)\\]$', 'gi'),
50
for (var i = 0; i < list.length; i++)
51
if ((match = regex.exec(list[i])) != null)
57
function defaultValue(value, def)
59
return value != null ? value : def;
62
function asString(value)
64
return value != null ? value.toString() : null;
67
var parts = input.split(':'),
70
straight = { 'true' : 'true' }
71
reverse = { 'true' : 'false' },
73
defaults = SyntaxHighlighter.defaults
77
options[parts[i]] = 'true';
79
showGutter = asString(defaultValue(showGutter, defaults.gutter));
80
showControls = asString(defaultValue(showControls, defaults.toolbar));
81
collapseAll = asString(defaultValue(collapseAll, defaults.collapse));
82
showColumns = asString(defaultValue(showColumns, defaults.ruler));
83
firstLine = asString(defaultValue(firstLine, defaults['first-line']));
87
gutter : defaultValue(reverse[options.nogutter], showGutter),
88
toolbar : defaultValue(reverse[options.nocontrols], showControls),
89
collapse : defaultValue(straight[options.collapse], collapseAll),
90
ruler : defaultValue(straight[options.showcolumns], showColumns),
91
'first-line' : defaultValue(getValue(parts, 'firstline'), firstLine)
97
HighlightAll: function(
99
showGutter /* optional */,
100
showControls /* optional */,
101
collapseAll /* optional */,
102
firstLine /* optional */,
103
showColumns /* optional */
110
for (var i = 0; i < a.length; i++)
115
if (typeof(a[i]) == 'string' && a[i] != '')
118
if (typeof(a[i]) == 'object' && a[i].value != '')
119
return a[i].value + '';
125
function findTagsByName(list, name, tagName)
127
var tags = document.getElementsByTagName(tagName);
129
for (var i = 0; i < tags.length; i++)
130
if (tags[i].getAttribute('name') == name)
137
propertyName = 'innerHTML'
140
// for some reason IE doesn't find <pre/> by name, however it does see them just fine by tag name...
141
findTagsByName(elements, name, 'pre');
142
findTagsByName(elements, name, 'textarea');
144
if (elements.length === 0)
147
for (var i = 0; i < elements.length; i++)
149
var element = elements[i],
151
element.attributes['class'], element.className,
152
element.attributes['language'], element.language
160
params = dp.SyntaxHighlighter.parseParams(
169
SyntaxHighlighter.highlight(params, element);