docs/scripts/sunlight.js
function highlightRecursive(node) {
				var match,
					languageId,
					currentNodeCount,
					j,
					nodes,
					k,
					partialContext,
					container,
					codeContainer;
				
				if (this.isAlreadyHighlighted(node) || (match = this.matchSunlightNode(node)) === null) {
					return;
				}

				languageId = match[1];
				currentNodeCount = 0;
				fireEvent("beforeHighlightNode", this, { node: node });
				for (j = 0; j < node.childNodes.length; j++) {
					if (node.childNodes[j].nodeType === 3) {
						//text nodes
						partialContext = highlightText.call(this, node.childNodes[j].nodeValue, languageId, partialContext);
						HIGHLIGHTED_NODE_COUNT++;
						currentNodeCount = currentNodeCount || HIGHLIGHTED_NODE_COUNT;
						nodes = partialContext.getNodes();

						node.replaceChild(nodes[0], node.childNodes[j]);
						for (k = 1; k < nodes.length; k++) {
							node.insertBefore(nodes[k], nodes[k - 1].nextSibling);
						}
					} else if (node.childNodes[j].nodeType === 1) {
						//element nodes
						highlightRecursive.call(this, node.childNodes[j]);
					}
				}

				//indicate that this node has been highlighted
				node.className += " " + this.options.classPrefix + "highlighted";
				
				//if the node is block level, we put it in a container, otherwise we just leave it alone
				if (getComputedStyle(node, "display") === "block") {
					container = document.createElement("div");
					container.className = this.options.classPrefix + "container";
					
					codeContainer = document.createElement("div");
					codeContainer.className = this.options.classPrefix + "code-container";

					//apply max height if specified in options
					if (this.options.maxHeight !== false) {
						codeContainer.style.overflowY = "auto";
						codeContainer.style.maxHeight = this.options.maxHeight + (/^\d+$/.test(this.options.maxHeight) ? "px" : "");
					}
					
					container.appendChild(codeContainer);
					
					node.parentNode.insertBefore(codeContainer, node);
					node.parentNode.removeChild(node);
					codeContainer.appendChild(node);
					
					codeContainer.parentNode.insertBefore(container, codeContainer);
					codeContainer.parentNode.removeChild(codeContainer);
					container.appendChild(codeContainer);
				}
				
				fireEvent("afterHighlightNode", this, { 
					container: container,
					codeContainer: codeContainer,
					node: node, 
					count: currentNodeCount
				});
			}
function highlightRecursive(node) {
				var match,
					languageId,
					currentNodeCount,
					j,
					nodes,
					k,
					partialContext,
					container,
					codeContainer;
				
				if (this.isAlreadyHighlighted(node) || (match = this.matchSunlightNode(node)) === null) {
					return;
				}

				languageId = match[1];
				currentNodeCount = 0;
				fireEvent("beforeHighlightNode", this, { node: node });
				for (j = 0; j < node.childNodes.length; j++) {
					if (node.childNodes[j].nodeType === 3) {
						//text nodes
						partialContext = highlightText.call(this, node.childNodes[j].nodeValue, languageId, partialContext);
						HIGHLIGHTED_NODE_COUNT++;
						currentNodeCount = currentNodeCount || HIGHLIGHTED_NODE_COUNT;
						nodes = partialContext.getNodes();

						node.replaceChild(nodes[0], node.childNodes[j]);
						for (k = 1; k < nodes.length; k++) {
							node.insertBefore(nodes[k], nodes[k - 1].nextSibling);
						}
					} else if (node.childNodes[j].nodeType === 1) {
						//element nodes
						highlightRecursive.call(this, node.childNodes[j]);
					}
				}

				//indicate that this node has been highlighted
				node.className += " " + this.options.classPrefix + "highlighted";
				
				//if the node is block level, we put it in a container, otherwise we just leave it alone
				if (getComputedStyle(node, "display") === "block") {
					container = document.createElement("div");
					container.className = this.options.classPrefix + "container";
					
					codeContainer = document.createElement("div");
					codeContainer.className = this.options.classPrefix + "code-container";

					//apply max height if specified in options
					if (this.options.maxHeight !== false) {
						codeContainer.style.overflowY = "auto";
						codeContainer.style.maxHeight = this.options.maxHeight + (/^\d+$/.test(this.options.maxHeight) ? "px" : "");
					}
					
					container.appendChild(codeContainer);
					
					node.parentNode.insertBefore(codeContainer, node);
					node.parentNode.removeChild(node);
					codeContainer.appendChild(node);
					
					codeContainer.parentNode.insertBefore(container, codeContainer);
					codeContainer.parentNode.removeChild(codeContainer);
					container.appendChild(codeContainer);
				}
				
				fireEvent("afterHighlightNode", this, { 
					container: container,
					codeContainer: codeContainer,
					node: node, 
					count: currentNodeCount
				});
			}
function highlightRecursive ( node ) { var match , languageId , currentNodeCount , j , nodes , k , partialContext , container , codeContainer ; if ( this . isAlreadyHighlighted ( node ) || ( match = this . matchSunlightNode ( node ) ) === null ) { return ; } languageId = match [ 1 ] ; currentNodeCount = 0 ; fireEvent ( "beforeHighlightNode" , this , { node : node } ) ; for ( j = 0 ; j < node . childNodes . length ; j ++ ) { if ( node . childNodes [ j ] . nodeType === 3 ) { //text nodes partialContext = highlightText . call ( this , node . childNodes [ j ] . nodeValue , languageId , partialContext ) ; HIGHLIGHTED_NODE_COUNT ++ ; currentNodeCount = currentNodeCount || HIGHLIGHTED_NODE_COUNT ; nodes = partialContext . getNodes ( ) ; node . replaceChild ( nodes [ 0 ] , node . childNodes [ j ] ) ; for ( k = 1 ; k < nodes . length ; k ++ ) { node . insertBefore ( nodes [ k ] , nodes [ k - 1 ] . nextSibling ) ; } } else if ( node . childNodes [ j ] . nodeType === 1 ) { //element nodes highlightRecursive . call ( this , node . childNodes [ j ] ) ; } } //indicate that this node has been highlighted node . className += " " + this . options . classPrefix + "highlighted" ; //if the node is block level, we put it in a container, otherwise we just leave it alone if ( getComputedStyle ( node , "display" ) === "block" ) { container = document . createElement ( "div" ) ; container . className = this . options . classPrefix + "container" ; codeContainer = document . createElement ( "div" ) ; codeContainer . className = this . options . classPrefix + "code-container" ; //apply max height if specified in options if ( this . options . maxHeight !== false ) { codeContainer . style . overflowY = "auto" ; codeContainer . style . maxHeight = this . options . maxHeight + ( / ^\d+$ / . test ( this . options . maxHeight ) ? "px" : "" ) ; } container . appendChild ( codeContainer ) ; node . parentNode . insertBefore ( codeContainer , node ) ; node . parentNode . removeChild ( node ) ; codeContainer . appendChild ( node ) ; codeContainer . parentNode . insertBefore ( container , codeContainer ) ; codeContainer . parentNode . removeChild ( codeContainer ) ; container . appendChild ( codeContainer ) ; } fireEvent ( "afterHighlightNode" , this , { container : container , codeContainer : codeContainer , node : node , count : currentNodeCount } ) ; }
recursively highlights a DOM node
recursively highlights a DOM node