html/rainbow/rainbow.js
function _processCodeWithPatterns(code, patterns, callback)
    {
        // we have to increase the level here so that the
        // replacements will not conflict with each other when
        // processing sub blocks of code
        ++CURRENT_LEVEL;

        // patterns are processed one at a time through this function
        function _workOnPatterns(patterns, i)
        {
            // still have patterns to process, keep going
            if (i < patterns.length) {
                return _processPattern(patterns[i]['pattern'], patterns[i], code, function() {
                    _workOnPatterns(patterns, ++i);
                });
            }

            // we are done processing the patterns
            // process the replacements and update the DOM
            _processReplacements(code, function(code) {

                // when we are done processing replacements
                // we are done at this level so we can go back down
                delete replacements[CURRENT_LEVEL];
                delete replacement_positions[CURRENT_LEVEL];
                --CURRENT_LEVEL;
                callback(code);
            });
        }

        _workOnPatterns(patterns, 0);
    }
function _processCodeWithPatterns(code, patterns, callback)
    {
        // we have to increase the level here so that the
        // replacements will not conflict with each other when
        // processing sub blocks of code
        ++CURRENT_LEVEL;

        // patterns are processed one at a time through this function
        function _workOnPatterns(patterns, i)
        {
            // still have patterns to process, keep going
            if (i < patterns.length) {
                return _processPattern(patterns[i]['pattern'], patterns[i], code, function() {
                    _workOnPatterns(patterns, ++i);
                });
            }

            // we are done processing the patterns
            // process the replacements and update the DOM
            _processReplacements(code, function(code) {

                // when we are done processing replacements
                // we are done at this level so we can go back down
                delete replacements[CURRENT_LEVEL];
                delete replacement_positions[CURRENT_LEVEL];
                --CURRENT_LEVEL;
                callback(code);
            });
        }

        _workOnPatterns(patterns, 0);
    }
function _processCodeWithPatterns ( code , patterns , callback ) { // we have to increase the level here so that the // replacements will not conflict with each other when // processing sub blocks of code ++ CURRENT_LEVEL ; // patterns are processed one at a time through this function function _workOnPatterns ( patterns , i ) { // still have patterns to process, keep going if ( i < patterns . length ) { return _processPattern ( patterns [ i ] [ 'pattern' ] , patterns [ i ] , code , function ( ) { _workOnPatterns ( patterns , ++ i ) ; } ) ; } // we are done processing the patterns // process the replacements and update the DOM _processReplacements ( code , function ( code ) { // when we are done processing replacements // we are done at this level so we can go back down delete replacements [ CURRENT_LEVEL ] ; delete replacement_positions [ CURRENT_LEVEL ] ; -- CURRENT_LEVEL ; callback ( code ) ; } ) ; } _workOnPatterns ( patterns , 0 ) ; }
processes a block of code using specified patterns

@param {string} code
@param {Array} patterns
@returns void
processes a block of code using specified patterns