3 * http://alexgorbatchev.com/SyntaxHighlighter
5 * SyntaxHighlighter is donationware. If you are using it, please donate.
6 * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
9 * 3.0.83 (July 02 2010)
12 * Copyright (C) 2004-2010 Alex Gorbatchev.
15 * Dual licensed under the MIT and GPL licenses.
18 SyntaxHighlighter : {}
21 dp.SyntaxHighlighter = {
22 parseParams: function(
31 function getValue(list, name)
33 var regex = new XRegExp('^' + name + '\\[(?<value>\\w+)\\]$', 'gi'),
37 for (var i = 0; i < list.length; i++)
38 if ((match = regex.exec(list[i])) != null)
44 function defaultValue(value, def)
46 return value != null ? value : def;
49 function asString(value)
51 return value != null ? value.toString() : null;
54 var parts = input.split(':'),
57 straight = { 'true' : true }
58 reverse = { 'true' : false },
60 defaults = SyntaxHighlighter.defaults
64 options[parts[i]] = 'true';
66 showGutter = asString(defaultValue(showGutter, defaults.gutter));
67 showControls = asString(defaultValue(showControls, defaults.toolbar));
68 collapseAll = asString(defaultValue(collapseAll, defaults.collapse));
69 showColumns = asString(defaultValue(showColumns, defaults.ruler));
70 firstLine = asString(defaultValue(firstLine, defaults['first-line']));
74 gutter : defaultValue(reverse[options.nogutter], showGutter),
75 toolbar : defaultValue(reverse[options.nocontrols], showControls),
76 collapse : defaultValue(straight[options.collapse], collapseAll),
77 // ruler : defaultValue(straight[options.showcolumns], showColumns),
78 'first-line' : defaultValue(getValue(parts, 'firstline'), firstLine)
82 HighlightAll: function(
84 showGutter /* optional */,
85 showControls /* optional */,
86 collapseAll /* optional */,
87 firstLine /* optional */,
88 showColumns /* optional */
95 for (var i = 0; i < a.length; i++)
100 if (typeof(a[i]) == 'string' && a[i] != '')
103 if (typeof(a[i]) == 'object' && a[i].value != '')
104 return a[i].value + '';
110 function findTagsByName(list, name, tagName)
112 var tags = document.getElementsByTagName(tagName);
114 for (var i = 0; i < tags.length; i++)
115 if (tags[i].getAttribute('name') == name)
122 propertyName = 'innerHTML'
125 // for some reason IE doesn't find <pre/> by name, however it does see them just fine by tag name...
126 findTagsByName(elements, name, 'pre');
127 findTagsByName(elements, name, 'textarea');
129 if (elements.length === 0)
132 for (var i = 0; i < elements.length; i++)
134 var element = elements[i],
136 element.attributes['class'], element.className,
137 element.attributes['language'], element.language
145 params = dp.SyntaxHighlighter.parseParams(
154 SyntaxHighlighter.highlight(params, element);