function walk()

in content/resources/js/prettify.js [510:540]


        function walk(node) {
            switch (node.nodeType) {
                case 1:  // Element
                    if (nocode.test(node.className)) { return; }
                    for (var child = node.firstChild; child; child = child.nextSibling) {
                        walk(child);
                    }
                    var nodeName = node.nodeName;
                    if ('BR' === nodeName || 'LI' === nodeName) {
                        chunks[k] = '\n';
                        spans[k << 1] = length++;
                        spans[(k++ << 1) | 1] = node;
                    }
                    break;
                case 3: case 4:  // Text
                var text = node.nodeValue;
                if (text.length) {
                    if (!isPreformatted) {
                        text = text.replace(/[ \t\r\n]+/g, ' ');
                    } else {
                        text = text.replace(/\r\n?/g, '\n');  // Normalize newlines.
                    }
                    // TODO: handle tabs here?
                    chunks[k] = text;
                    spans[k << 1] = length;
                    length += text.length;
                    spans[(k++ << 1) | 1] = node;
                }
                break;
            }
        }