var Syntax = {
base: "", /* base path */
tab: " ",
_registry: {},
_todo: {},
/* apply to all elements */
all: function() {
var all = document.getElementsByTagName("*");
var todo = [];
for (var i=0;i/g, ">");
for (var i=0;i 1) {
for (var j=1;j$"+index+"";
code = code.replace(pattern.re, replacement);
}
code = code.replace(/\t/g, this.tab);
if (node.outerHTML) { /* IE hack; innerHTML normalizes whitespace */
node.innerHTML = "";
var tmp = document.createElement("div");
tmp.style.display = "none";
document.body.insertBefore(tmp, document.body.firstChild);
var pre = document.createElement("pre");
tmp.appendChild(pre);
pre.outerHTML = "" + code + "
";
while (tmp.firstChild.firstChild) { node.appendChild(tmp.firstChild.firstChild); }
tmp.parentNode.removeChild(tmp);
} else {
node.innerHTML = code;
}
},
_append: function(syntax) {
var s = document.createElement("script");
s.src = this.base + "syntax-"+syntax+".js";
var thisp = this;
var loaded = function() { thisp._loaded(); }
if (s.addEventListener) {
s.addEventListener("load", loaded, false);
} else {
s.attachEvent("onreadystatechange", loaded);
}
document.body.insertBefore(s, document.body.firstChild);
},
_loaded: function() {
for (var syntax in this._registry) {
if (!(syntax in this._todo)) { continue; }
while (this._todo[syntax].length) {
this._process(this._todo[syntax].shift(), syntax);
}
delete this._todo[syntax];
}
}
};
Syntax.init();