src/rainbow.js
function _highlightCodeBlocks(codeBlocks, callback) {
    const waitingOn = { c: 0 };
    for (const block of codeBlocks) {
        const language = getLanguageForBlock(block);
        if (block.classList.contains('rainbow') || !language) {
            continue;
        }

        // This cancels the pending animation to fade the code in on load
        // since we want to delay doing this until it is actually
        // highlighted
        block.classList.add('loading');
        block.classList.add('rainbow');

        // We need to make sure to also add the loading class to the pre tag
        // because that is how we will know to show a preloader
        if (block.parentNode.tagName === 'PRE') {
            block.parentNode.classList.add('loading');
        }

        const globalClass = block.getAttribute('data-global-class');
        const delay = parseInt(block.getAttribute('data-delay'), 10);

        ++waitingOn.c;
        _messageWorker(_getWorkerData(block.innerHTML, { language, globalClass, delay }), _generateHandler(block, waitingOn, callback));
    }

    if (waitingOn.c === 0) {
        callback();
    }
}
function _highlightCodeBlocks(codeBlocks, callback) {
    const waitingOn = { c: 0 };
    for (const block of codeBlocks) {
        const language = getLanguageForBlock(block);
        if (block.classList.contains('rainbow') || !language) {
            continue;
        }

        // This cancels the pending animation to fade the code in on load
        // since we want to delay doing this until it is actually
        // highlighted
        block.classList.add('loading');
        block.classList.add('rainbow');

        // We need to make sure to also add the loading class to the pre tag
        // because that is how we will know to show a preloader
        if (block.parentNode.tagName === 'PRE') {
            block.parentNode.classList.add('loading');
        }

        const globalClass = block.getAttribute('data-global-class');
        const delay = parseInt(block.getAttribute('data-delay'), 10);

        ++waitingOn.c;
        _messageWorker(_getWorkerData(block.innerHTML, { language, globalClass, delay }), _generateHandler(block, waitingOn, callback));
    }

    if (waitingOn.c === 0) {
        callback();
    }
}
function _highlightCodeBlocks ( codeBlocks , callback ) { const waitingOn = { c : 0 } ; for ( const block of codeBlocks ) { const language = getLanguageForBlock ( block ) ; if ( block . classList . contains ( 'rainbow' ) || ! language ) { continue ; } // This cancels the pending animation to fade the code in on load // since we want to delay doing this until it is actually // highlighted block . classList . add ( 'loading' ) ; block . classList . add ( 'rainbow' ) ; // We need to make sure to also add the loading class to the pre tag // because that is how we will know to show a preloader if ( block . parentNode . tagName === 'PRE' ) { block . parentNode . classList . add ( 'loading' ) ; } const globalClass = block . getAttribute ( 'data-global-class' ) ; const delay = parseInt ( block . getAttribute ( 'data-delay' ) , 10 ) ; ++ waitingOn . c ; _messageWorker ( _getWorkerData ( block . innerHTML , { language , globalClass , delay } ) , _generateHandler ( block , waitingOn , callback ) ) ; } if ( waitingOn . c === 0 ) { callback ( ) ; } }
Browser Only - Sends messages to web worker to highlight elements passed
in

@param {Array} codeBlocks
@param {Function} callback
@return {void}
Browser Only - Sends messages to web worker to highlight elements passed in