html/rainbow/rainbow.js
function _highlightCodeBlock(code_blocks, i, onComplete) {
        if (i < code_blocks.length) {
            var block = code_blocks[i],
                language = _getLanguageForBlock(block);

            if (!_hasClass(block, 'rainbow') && language) {
                language = language.toLowerCase();

                _addClass(block, 'rainbow');

                return _highlightBlockForLanguage(block.innerHTML, language, function(code) {
                    block.innerHTML = code;

                    // reset the replacement arrays
                    replacements = {};
                    replacement_positions = {};

                    // if you have a listener attached tell it that this block is now highlighted
                    if (onHighlight) {
                        onHighlight(block, language);
                    }

                    // process the next block
                    setTimeout(function() {
                        _highlightCodeBlock(code_blocks, ++i, onComplete);
                    }, 0);
                });
            }
            return _highlightCodeBlock(code_blocks, ++i, onComplete);
        }

        if (onComplete) {
            onComplete();
        }
    }
function _highlightCodeBlock(code_blocks, i, onComplete) {
        if (i < code_blocks.length) {
            var block = code_blocks[i],
                language = _getLanguageForBlock(block);

            if (!_hasClass(block, 'rainbow') && language) {
                language = language.toLowerCase();

                _addClass(block, 'rainbow');

                return _highlightBlockForLanguage(block.innerHTML, language, function(code) {
                    block.innerHTML = code;

                    // reset the replacement arrays
                    replacements = {};
                    replacement_positions = {};

                    // if you have a listener attached tell it that this block is now highlighted
                    if (onHighlight) {
                        onHighlight(block, language);
                    }

                    // process the next block
                    setTimeout(function() {
                        _highlightCodeBlock(code_blocks, ++i, onComplete);
                    }, 0);
                });
            }
            return _highlightCodeBlock(code_blocks, ++i, onComplete);
        }

        if (onComplete) {
            onComplete();
        }
    }
function _highlightCodeBlock ( code_blocks , i , onComplete ) { if ( i < code_blocks . length ) { var block = code_blocks [ i ] , language = _getLanguageForBlock ( block ) ; if ( ! _hasClass ( block , 'rainbow' ) && language ) { language = language . toLowerCase ( ) ; _addClass ( block , 'rainbow' ) ; return _highlightBlockForLanguage ( block . innerHTML , language , function ( code ) { block . innerHTML = code ; // reset the replacement arrays replacements = { } ; replacement_positions = { } ; // if you have a listener attached tell it that this block is now highlighted if ( onHighlight ) { onHighlight ( block , language ) ; } // process the next block setTimeout ( function ( ) { _highlightCodeBlock ( code_blocks , ++ i , onComplete ) ; } , 0 ) ; } ) ; } return _highlightCodeBlock ( code_blocks , ++ i , onComplete ) ; } if ( onComplete ) { onComplete ( ) ; } }
highlight an individual code block

@param {Array} code_blocks
@param {number} i
@returns void
highlight an individual code block