var XRegExp; (function () { function s(f, i) { if (!XRegExp.isRegExp(f)) throw TypeError("type RegExp expected"); var g = f._xregexp; f = XRegExp(f.source, t(f) + (i || "")); if (g) f._xregexp = { source: g.source, captureNames: g.captureNames ? g.captureNames.slice(0) : null }; return f } function t(f) { return (f.global ? "g" : "") + (f.ignoreCase ? "i" : "") + (f.multiline ? "m" : "") + (f.extended ? "x" : "") + (f.sticky ? "y" : "") } function z(f, i, g, a) { var b = v.length, c, d, e; A = true; try { for (; b--;) { e = v[b]; if (g & e.scope && (!e.trigger || e.trigger.call(a))) { e.pattern.lastIndex = i; if ((d = e.pattern.exec(f)) && d.index === i) { c = { output: e.handler.call(a, d, g), match: d }; break } } } } catch (h) { throw h } finally { A = false } return c } function B(f, i, g) { if (Array.prototype.indexOf) return f.indexOf(i, g); for (g = g || 0; g < f.length; g++) if (f[g] === i) return g; return -1 } XRegExp = function (f, i) { var g = [], a = XRegExp.OUTSIDE_CLASS, b = 0, c, d; if (XRegExp.isRegExp(f)) { if (i !== undefined) throw TypeError("can't supply flags when constructing one RegExp from another"); return s(f) } if (A) throw Error("can't call the XRegExp constructor within token definition functions"); i = i || ""; for (c = { hasNamedCapture: false, captureNames: [], hasFlag: function (e) { return i.indexOf(e) > -1 }, setFlag: function (e) { i += e } }; b < f.length;) if (d = z(f, b, a, c)) { g.push(d.output); b += d.match[0].length || 1 } else if (d = o.exec.call(C[a], f.slice(b))) { g.push(d[0]); b += d[0].length } else { d = f.charAt(b); if (d === "[") a = XRegExp.INSIDE_CLASS; else if (d === "]") a = XRegExp.OUTSIDE_CLASS; g.push(d); b++ } g = RegExp(g.join(""), o.replace.call(i, D, "")); g._xregexp = { source: f, captureNames: c.hasNamedCapture ? c.captureNames : null }; return g }; XRegExp.version = "1.5.0"; XRegExp.INSIDE_CLASS = 1; XRegExp.OUTSIDE_CLASS = 2; var q = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g, D = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, w = /^(?:[?*+]|{\d+(?:,\d*)?})\??/, A = false, v = [], o = { exec: RegExp.prototype.exec, test: RegExp.prototype.test, match: String.prototype.match, replace: String.prototype.replace, split: String.prototype.split }, F = o.exec.call(/()??/, "")[1] === undefined, x = function () { var f = /^/g; o.test.call(f, ""); return !f.lastIndex }(), G = function () { var f = /x/g; o.replace.call("x", f, ""); return !f.lastIndex }(), y = RegExp.prototype.sticky !== undefined, C = {}; C[XRegExp.INSIDE_CLASS] = /^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/; C[XRegExp.OUTSIDE_CLASS] = /^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/; XRegExp.addToken = function (f, i, g, a) { v.push({ pattern: s(f, "g" + (y ? "y" : "")), handler: i, scope: g || XRegExp.OUTSIDE_CLASS, trigger: a || null }) }; XRegExp.cache = function (f, i) { var g = f + "/" + (i || ""); return XRegExp.cache[g] || (XRegExp.cache[g] = XRegExp(f, i)) }; XRegExp.copyAsGlobal = function (f) { return s(f, "g") }; XRegExp.escape = function (f) { return f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") }; XRegExp.execAt = function (f, i, g, a) { i = s(i, "g" + (a && y ? "y" : "")); i.lastIndex = g = g || 0; f = i.exec(f); return a ? f && f.index === g ? f : null : f }; XRegExp.freezeTokens = function () { XRegExp.addToken = function () { throw Error("can't run addToken after freezeTokens") } }; XRegExp.isRegExp = function (f) { return Object.prototype.toString.call(f) === "[object RegExp]" }; XRegExp.iterate = function (f, i, g, a) { for (var b = s(i, "g"), c = -1, d; d = b.exec(f) ;) { g.call(a, d, ++c, f, b); b.lastIndex === d.index && b.lastIndex++ } if (i.global) i.lastIndex = 0 }; XRegExp.matchChain = function (f, i) { return function g(a, b) { var c = i[b].regex ? i[b] : { regex: i[b] }, d = s(c.regex, "g"), e = [], h; for (h = 0; h < a.length; h++) XRegExp.iterate(a[h], d, function (j) { e.push(c.backref ? j[c.backref] || "" : j[0]) }); return b === i.length - 1 || !e.length ? e : g(e, b + 1) }([f], 0) }; RegExp.prototype.apply = function (f, i) { return this.exec(i[0]) }; RegExp.prototype.call = function (f, i) { return this.exec(i) }; RegExp.prototype.exec = function (f) { var i = o.exec.apply(this, arguments), g; if (i) { if (!F && i.length > 1 && B(i, "") > -1) { g = RegExp(this.source, o.replace.call(t(this), "g", "")); o.replace.call(f.toString().slice(i.index), g, function () { for (var b = 1; b < arguments.length - 2; b++) if (arguments[b] === undefined) i[b] = undefined }) } if (this._xregexp && this._xregexp.captureNames) for (var a = 1; a < i.length; a++) if (g = this._xregexp.captureNames[a - 1]) i[g] = i[a]; !x && this.global && !i[0].length && this.lastIndex > i.index && this.lastIndex-- } return i }; if (!x) RegExp.prototype.test = function (f) { (f = o.exec.call(this, f)) && this.global && !f[0].length && this.lastIndex > f.index && this.lastIndex--; return !!f }; String.prototype.match = function (f) { XRegExp.isRegExp(f) || (f = RegExp(f)); if (f.global) { var i = o.match.apply(this, arguments); f.lastIndex = 0; return i } return f.exec(this) }; String.prototype.replace = function (f, i) { var g = XRegExp.isRegExp(f), a, b; if (g && typeof i.valueOf() === "string" && i.indexOf("${") === -1 && G) return o.replace.apply(this, arguments); if (g) { if (f._xregexp) a = f._xregexp.captureNames } else f += ""; if (typeof i === "function") b = o.replace.call(this, f, function () { if (a) { arguments[0] = new String(arguments[0]); for (var c = 0; c < a.length; c++) if (a[c]) arguments[0][a[c]] = arguments[c + 1] } if (g && f.global) f.lastIndex = arguments[arguments.length - 2] + arguments[0].length; return i.apply(null, arguments) }); else { b = this + ""; b = o.replace.call(b, f, function () { var c = arguments; return o.replace.call(i, q, function (d, e, h) { if (e) switch (e) { case "$": return "$"; case "&": return c[0]; case "`": return c[c.length - 1].slice(0, c[c.length - 2]); case "'": return c[c.length - 1].slice(c[c.length - 2] + c[0].length); default: h = ""; e = +e; if (!e) return d; for (; e > c.length - 3;) { h = String.prototype.slice.call(e, -1) + h; e = Math.floor(e / 10) } return (e ? c[e] || "" : "$") + h } else { e = +h; if (e <= c.length - 3) return c[e]; e = a ? B(a, h) : -1; return e > -1 ? c[e + 1] : d } }) }) } if (g && f.global) f.lastIndex = 0; return b }; String.prototype.split = function (f, i) { if (!XRegExp.isRegExp(f)) return o.split.apply(this, arguments); var g = this + "", a = [], b = 0, c, d; if (i === undefined || +i < 0) i = Infinity; else { i = Math.floor(+i); if (!i) return [] } for (f = XRegExp.copyAsGlobal(f) ; c = f.exec(g) ;) { if (f.lastIndex > b) { a.push(g.slice(b, c.index)); c.length > 1 && c.index < g.length && Array.prototype.push.apply(a, c.slice(1)); d = c[0].length; b = f.lastIndex; if (a.length >= i) break } f.lastIndex === c.index && f.lastIndex++ } if (b === g.length) { if (!o.test.call(f, "") || d) a.push("") } else a.push(g.slice(b)); return a.length > i ? a.slice(0, i) : a }; XRegExp.addToken(/\(\?#[^)]*\)/, function (f) { return o.test.call(w, f.input.slice(f.index + f[0].length)) ? "" : "(?:)" }); XRegExp.addToken(/\((?!\?)/, function () { this.captureNames.push(null); return "(" }); XRegExp.addToken(/\(\?<([$\w]+)>/, function (f) { this.captureNames.push(f[1]); this.hasNamedCapture = true; return "(" }); XRegExp.addToken(/\\k<([\w$]+)>/, function (f) { var i = B(this.captureNames, f[1]); return i > -1 ? "\\" + (i + 1) + (isNaN(f.input.charAt(f.index + f[0].length)) ? "" : "(?:)") : f[0] }); XRegExp.addToken(/\[\^?]/, function (f) { return f[0] === "[]" ? "\\b\\B" : "[\\s\\S]" }); XRegExp.addToken(/^\(\?([imsx]+)\)/, function (f) { this.setFlag(f[1]); return "" }); XRegExp.addToken(/(?:\s+|#.*)+/, function (f) { return o.test.call(w, f.input.slice(f.index + f[0].length)) ? "" : "(?:)" }, XRegExp.OUTSIDE_CLASS, function () { return this.hasFlag("x") }); XRegExp.addToken(/\./, function () { return "[\\s\\S]" }, XRegExp.OUTSIDE_CLASS, function () { return this.hasFlag("s") }) })(); /** * SyntaxHighlighter * http://alexgorbatchev.com/SyntaxHighlighter * * SyntaxHighlighter is donationware. If you are using it, please donate. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html * * @version * 3.0.83 (July 02 2010) * * @copyright * Copyright (C) 2004-2010 Alex Gorbatchev. * * @license * Dual licensed under the MIT and GPL licenses. */ // // Begin anonymous function. This is used to contain local scope variables without polutting global scope. // var SyntaxHighlighter = function () { // CommonJS if (typeof (require) != 'undefined' && typeof (XRegExp) == 'undefined') { XRegExp = require('XRegExp').XRegExp; } // Shortcut object which will be assigned to the SyntaxHighlighter variable. // This is a shorthand for local reference in order to avoid long namespace // references to SyntaxHighlighter.whatever... var sh = { defaults: { /** Additional CSS class names to be added to highlighter elements. */ 'class-name': '', /** First line number. */ 'first-line': 1, /** * Pads line numbers. Possible values are: * * false - don't pad line numbers. * true - automaticaly pad numbers with minimum required number of leading zeroes. * [int] - length up to which pad line numbers. */ 'pad-line-numbers': false, /** Lines to highlight. */ 'highlight': null, /** Title to be displayed above the code block. */ 'title': null, /** Enables or disables smart tabs. */ 'smart-tabs': true, /** Gets or sets tab size. */ 'tab-size': 4, /** Enables or disables gutter. */ 'gutter': true, /** Enables or disables toolbar. */ 'toolbar': false, /** Enables quick code copy and paste from double click. */ 'quick-code': true, /** Forces code view to be collapsed. */ 'collapse': false, /** Enables or disables automatic links. */ 'auto-links': true, /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */ 'light': false, 'html-script': false }, config: { space: ' ', /** Enables use of tags. */ useScriptTags: true, /** Blogger mode flag. */ bloggerMode: false, stripBrs: false, /** Name of the tag that SyntaxHighlighter will automatically look for. */ tagName: 'SyntaxHighlighter', strings: { expandSource: 'expand source', help: '?', alert: 'SyntaxHighlighter\n\n', noBrush: 'Can\'t find brush for: ', brushNotHtmlScript: 'Brush wasn\'t configured for html-script option: ', // this is populated by the build script aboutDialog: '
{ target: DOMElement, params: Object }
objects.
*/
findElements: function (globalParams, element) {
var elements = element ? [element] : toArray(document.getElementsByName(sh.config.tagName)),
conf = sh.config,
result = []
;
// support for feature
if (conf.useScriptTags)
elements = elements.concat(getSyntaxHighlighterScriptTags());
if (elements.length === 0)
return result;
for (var i = 0; i < elements.length; i++) {
var item = {
target: elements[i],
// local params take precedence over globals
params: merge(globalParams, parseParams(elements[i].className))
};
if (item.params['brush'] == null)
continue;
result.push(item);
}
return result;
},
/**
* Shorthand to highlight all elements on the page that are marked as
* SyntaxHighlighter source code.
*
* @param {Object} globalParams Optional parameters which override element's
* parameters. Only used if element is specified.
*
* @param {Object} element Optional element to highlight. If none is
* provided, all elements in the current document
* are highlighted.
*/
highlight: function (globalParams, element) {
var elements = this.findElements(globalParams, element),
propertyName = 'innerHTML',
highlighter = null,
conf = sh.config
;
if (elements.length === 0)
return;
for (var i = 0; i < elements.length; i++) {
var element = elements[i],
target = element.target,
params = element.params,
brushName = params.brush,
code
;
if (brushName == null)
continue;
// Instantiate a brush
if (params['html-script'] == 'true' || sh.defaults['html-script'] == true) {
highlighter = new sh.HtmlScript(brushName);
brushName = 'htmlscript';
}
else {
var brush = findBrush(brushName);
if (brush)
highlighter = new brush();
else
continue;
}
code = target[propertyName];
// remove CDATA from tags if it's present
if (conf.useScriptTags)
code = stripCData(code);
// Inject title if the attribute is present
if ((target.title || '') != '')
params.title = target.title;
params['brush'] = brushName;
highlighter.init(params);
element = highlighter.getDiv(code);
// carry over ID
if ((target.id || '') != '')
element.id = target.id;
target.parentNode.replaceChild(element, target);
}
},
/**
* Main entry point for the SyntaxHighlighter.
* @param {Object} params Optional params to apply to all highlighted elements.
*/
all: function (params) {
attachEvent(
window,
'load',
function () { sh.highlight(params); }
);
}
}; // end of sh
sh['all'] = sh.all;
sh['highlight'] = sh.highlight;
/**
* Checks if target DOM elements has specified CSS class.
* @param {DOMElement} target Target DOM element to check.
* @param {String} className Name of the CSS class to check for.
* @return {Boolean} Returns true if class name is present, false otherwise.
*/
function hasClass(target, className) {
return target.className.indexOf(className) != -1;
};
/**
* Adds CSS class name to the target DOM element.
* @param {DOMElement} target Target DOM element.
* @param {String} className New CSS class to add.
*/
function addClass(target, className) {
if (!hasClass(target, className))
target.className += ' ' + className;
};
/**
* Removes CSS class name from the target DOM element.
* @param {DOMElement} target Target DOM element.
* @param {String} className CSS class to remove.
*/
function removeClass(target, className) {
target.className = target.className.replace(className, '');
};
/**
* Converts the source to array object. Mostly used for function arguments and
* lists returned by getElementsByTagName() which aren't Array objects.
* @param {List} source Source list.
* @return {Array} Returns array.
*/
function toArray(source) {
var result = [];
for (var i = 0; i < source.length; i++)
result.push(source[i]);
return result;
};
/**
* Splits block of text into lines.
* @param {String} block Block of text.
* @return {Array} Returns array of lines.
*/
function splitLines(block) {
return block.split('\n');
}
/**
* Generates HTML ID for the highlighter.
* @param {String} highlighterId Highlighter ID.
* @return {String} Returns HTML ID.
*/
function getHighlighterId(id) {
var prefix = 'highlighter_';
return id.indexOf(prefix) == 0 ? id : prefix + id;
};
/**
* Finds Highlighter instance by ID.
* @param {String} highlighterId Highlighter ID.
* @return {Highlighter} Returns instance of the highlighter.
*/
function getHighlighterById(id) {
return sh.vars.highlighters[getHighlighterId(id)];
};
/**
* Finds highlighter's DIV container.
* @param {String} highlighterId Highlighter ID.
* @return {Element} Returns highlighter's DIV element.
*/
function getHighlighterDivById(id) {
return document.getElementById(getHighlighterId(id));
};
/**
* Stores highlighter so that getHighlighterById() can do its thing. Each
* highlighter must call this method to preserve itself.
* @param {Highilghter} highlighter Highlighter instance.
*/
function storeHighlighter(highlighter) {
sh.vars.highlighters[getHighlighterId(highlighter.id)] = highlighter;
};
/**
* Looks for a child or parent node which has specified classname.
* Equivalent to jQuery's $(container).find(".className")
* @param {Element} target Target element.
* @param {String} search Class name or node name to look for.
* @param {Boolean} reverse If set to true, will go up the node tree instead of down.
* @return {Element} Returns found child or parent element on null.
*/
function findElement(target, search, reverse /* optional */) {
if (target == null)
return null;
var nodes = reverse != true ? target.childNodes : [target.parentNode],
propertyToFind = { '#': 'id', '.': 'className' }[search.substr(0, 1)] || 'nodeName',
expectedValue,
found
;
expectedValue = propertyToFind != 'nodeName'
? search.substr(1)
: search.toUpperCase()
;
// main return of the found node
if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
return target;
for (var i = 0; nodes && i < nodes.length && found == null; i++)
found = findElement(nodes[i], search, reverse);
return found;
};
/**
* Looks for a parent node which has specified classname.
* This is an alias to findElement(container, className, true)
.
* @param {Element} target Target element.
* @param {String} className Class name to look for.
* @return {Element} Returns found parent element on null.
*/
function findParentElement(target, className) {
return findElement(target, className, true);
};
/**
* Finds an index of element in the array.
* @ignore
* @param {Object} searchElement
* @param {Number} fromIndex
* @return {Number} Returns index of element if found; -1 otherwise.
*/
function indexOf(array, searchElement, fromIndex) {
fromIndex = Math.max(fromIndex || 0, 0);
for (var i = fromIndex; i < array.length; i++)
if (array[i] == searchElement)
return i;
return -1;
};
/**
* Generates a unique element ID.
*/
function guid(prefix) {
return (prefix || '') + Math.round(Math.random() * 1000000).toString();
};
/**
* Merges two objects. Values from obj2 override values in obj1.
* Function is NOT recursive and works only for one dimensional objects.
* @param {Object} obj1 First object.
* @param {Object} obj2 Second object.
* @return {Object} Returns combination of both objects.
*/
function merge(obj1, obj2) {
var result = {}, name;
for (name in obj1)
result[name] = obj1[name];
for (name in obj2)
result[name] = obj2[name];
return result;
};
/**
* Attempts to convert string to boolean.
* @param {String} value Input string.
* @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
*/
function toBoolean(value) {
var result = { "true": true, "false": false }[value];
return result == null ? value : result;
};
/**
* Opens up a centered popup window.
* @param {String} url URL to open in the window.
* @param {String} name Popup name.
* @param {int} width Popup width.
* @param {int} height Popup height.
* @param {String} options window.open() options.
* @return {Window} Returns window instance.
*/
function popup(url, name, width, height, options) {
var x = (screen.width - width) / 2,
y = (screen.height - height) / 2
;
options += ', left=' + x +
', top=' + y +
', width=' + width +
', height=' + height
;
options = options.replace(/^,/, '');
var win = window.open(url, name, options);
win.focus();
return win;
};
/**
* Adds event handler to the target object.
* @param {Object} obj Target object.
* @param {String} type Name of the event.
* @param {Function} func Handling function.
*/
function attachEvent(obj, type, func, scope) {
function handler(e) {
e = e || window.event;
if (!e.target) {
e.target = e.srcElement;
e.preventDefault = function () {
this.returnValue = false;
};
}
func.call(scope || window, e);
};
if (obj.attachEvent) {
obj.attachEvent('on' + type, handler);
}
else {
obj.addEventListener(type, handler, false);
}
};
/**
* Displays an alert.
* @param {String} str String to display.
*/
function alert(str) {
window.alert(sh.config.strings.alert + str);
};
/**
* Finds a brush by its alias.
*
* @param {String} alias Brush alias.
* @param {Boolean} showAlert Suppresses the alert if false.
* @return {Brush} Returns bursh constructor if found, null otherwise.
*/
function findBrush(alias, showAlert) {
var brushes = sh.vars.discoveredBrushes,
result = null
;
if (brushes == null) {
brushes = {};
// Find all brushes
for (var brush in sh.brushes) {
var info = sh.brushes[brush],
aliases = info.aliases
;
if (aliases == null)
continue;
// keep the brush name
info.brushName = brush.toLowerCase();
for (var i = 0; i < aliases.length; i++)
brushes[aliases[i]] = brush;
}
sh.vars.discoveredBrushes = brushes;
}
result = sh.brushes[brushes[alias]];
if (result == null && showAlert != false)
alert(sh.config.strings.noBrush + alias);
return result;
};
/**
* Executes a callback on each line and replaces each line with result from the callback.
* @param {Object} str Input string.
* @param {Object} callback Callback function taking one string argument and returning a string.
*/
function eachLine(str, callback) {
var lines = splitLines(str);
for (var i = 0; i < lines.length; i++)
lines[i] = callback(lines[i], i);
return lines.join('\n');
};
/**
* This is a special trim which only removes first and last empty lines
* and doesn't affect valid leading space on the first line.
*
* @param {String} str Input string
* @return {String} Returns string without empty first and last lines.
*/
function trimFirstAndLastLines(str) {
return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
};
/**
* Parses key/value pairs into hash object.
*
* Understands the following formats:
* - name: word;
* - name: [word, word];
* - name: "string";
* - name: 'string';
*
* For example:
* name1: value; name2: [value, value]; name3: 'value'
*
* @param {String} str Input string.
* @return {Object} Returns deserialized object.
*/
function parseParams(str) {
var match,
result = {},
arrayRegex = new XRegExp("^\\[(?
tag with given style applied to it.
*
* @param {String} str Input string.
* @param {String} css Style name to apply to the string.
* @return {String} Returns input string with each line surrounded by tag.
*/
function wrapLinesWithCode(str, css) {
if (str == null || str.length == 0 || str == '\n')
return str;
str = str.replace(/... to them so that
// leading spaces aren't included.
if (css != null)
str = eachLine(str, function (line) {
if (line.length == 0)
return '';
var spaces = '';
line = line.replace(/^( | )+/, function (s) {
spaces = s;
return '';
});
if (line.length == 0)
return spaces;
return spaces + '' + line + '
';
});
return str;
};
/**
* Pads number with zeros until it's length is the same as given length.
*
* @param {Number} number Number to pad.
* @param {Number} length Max string length with.
* @return {String} Returns a string padded with proper amount of '0'.
*/
function padNumber(number, length) {
var result = number.toString();
while (result.length < length)
result = '0' + result;
return result;
};
/**
* Replaces tabs with spaces.
*
* @param {String} code Source code.
* @param {Number} tabSize Size of the tab.
* @return {String} Returns code with all tabs replaces by spaces.
*/
function processTabs(code, tabSize) {
var tab = '';
for (var i = 0; i < tabSize; i++)
tab += ' ';
return code.replace(/\t/g, tab);
};
/**
* Replaces tabs with smart spaces.
*
* @param {String} code Code to fix the tabs in.
* @param {Number} tabSize Number of spaces in a column.
* @return {String} Returns code with all tabs replaces with roper amount of spaces.
*/
function processSmartTabs(code, tabSize) {
var lines = splitLines(code),
tab = '\t',
spaces = ''
;
// Create a string with 1000 spaces to copy spaces from...
// It's assumed that there would be no indentation longer than that.
for (var i = 0; i < 50; i++)
spaces += ' '; // 20 spaces * 50
// This function inserts specified amount of spaces in the string
// where a tab is while removing that given tab.
function insertSpaces(line, pos, count) {
return line.substr(0, pos)
+ spaces.substr(0, count)
+ line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
;
};
// Go through all the lines and do the 'smart tabs' magic.
code = eachLine(code, function (line) {
if (line.indexOf(tab) == -1)
return line;
var pos = 0;
while ((pos = line.indexOf(tab)) != -1) {
// This is pretty much all there is to the 'smart tabs' logic.
// Based on the position within the line and size of a tab,
// calculate the amount of spaces we need to insert.
var spaces = tabSize - pos % tabSize;
line = insertSpaces(line, pos, spaces);
}
return line;
});
return code;
};
/**
* Performs various string fixes based on configuration.
*/
function fixInputString(str) {
var br = /regexList
collection.
* @return {Array} Returns a list of Match objects.
*/
function getMatches(code, regexInfo) {
function defaultAdd(match, regexInfo) {
return match[0];
};
var index = 0,
match = null,
matches = [],
func = regexInfo.func ? regexInfo.func : defaultAdd
;
while ((match = regexInfo.regex.exec(code)) != null) {
var resultMatch = func(match, regexInfo);
if (typeof (resultMatch) == 'string')
resultMatch = [new sh.Match(resultMatch, match.index, regexInfo.css)];
matches = matches.concat(resultMatch);
}
return matches;
};
/**
* Turns all URLs in the code into tags.
* @param {String} code Input code.
* @return {String} Returns code with tags.
*/
function processUrls(code) {
var gt = /(.*)((>|<).*)/;
return code.replace(sh.regexLib.url, function (m) {
var suffix = '',
match = null
;
// We include < and > in the URL for the common cases like ' + spaces + '
' : '') + line
);
}
return html;
},
/**
* Returns HTML for the table title or empty string if title is null.
*/
getTitleHtml: function (title) {
return title ? '' + this.getLineNumbersHtml(code) + ' | ' : '') + ''
+ ' '
+ html
+ ' '
+ ' | '
+ '
.*?)" +
"(?" + regexGroup.right.source + ")",
"sgi"
)
};
}
}; // end of Highlighter
return sh;
}(); // end of anonymous function
// CommonJS
typeof (exports) != 'undefined' ? exports['SyntaxHighlighter'] = SyntaxHighlighter : null;