/* CANONML TO HTML */
window.onload = CanonMLtoHTML;
function CanonMLtoHTML() {
	var node = document.getElementsByTagName('*');
	var pattern = new RegExp('(^|\\s)'+ 'CanonML' +'(\\s|$)');
	for (i = 0; i < node.length; i++) {
		if (pattern.test(node[i].className)) {
			if (node[i].firstChild.nodeValue != null) {
				var content = node[i].firstChild.nodeValue;
				var CanonML = content;
				content = content.replace(/\s+/g, " ");
				content = content.replace(/\(\s/g, "(");
				content = content.replace(/\s\)/g, ")");
				content = content.replace(/\)\s\(/g, ")(");
				while (node[i].firstChild) node[i].removeChild(node[i].firstChild);
				var pointer = node[i];
				pointer.setAttribute("TITLE", "CanonML: " + CanonML);
				pointer.setAttribute("ALT", "CanonML: " + CanonML);
				for (j = 0; j < content.length; j++) {
					var token = content.charAt(j);
					var nextoken = content.charAt(j+1);
					if (token == "(") {
						var inline = document.createElement("SPAN");
						pointer.appendChild(inline);
						pointer = inline;}
					else {
						if (token == "\\" && (nextoken == "(" || nextoken == ")" || nextoken == "\\")) {
							pointer.appendChild(document.createTextNode(nextoken));
							j = j+1;}
							else {
							if (token == "\\") {
								var k = content.indexOf(" ", j+1);
								var label = content.substring(j+1, k);
								pointer.setAttribute("CLASS", label);
								j = k;}
							else {
								if (token == ")") {
									pointer = pointer.parentNode;}
								else {
									pointer.appendChild(document.createTextNode(token));}}}}}}}}}
/* Rights reserved - Center for CANONICAL |SCIENCE) */
