src/rainbow.js
function color(...args) {

    // If you want to straight up highlight a string you can pass the
    // string of code, the language, and a callback function.
    //
    // Example:
    //
    // Rainbow.color(code, language, function(highlightedCode, language) {
    //     // this code block is now highlighted
    // });
    if (typeof args[0] === 'string') {
        const workerData = _getWorkerData(args[0], args[1]);
        _messageWorker(workerData, (function(cb) {
            return function(data) {
                if (cb) {
                    cb(data.result, data.lang);
                }
            };
        }(args[2])));
        return;
    }

    // If you pass a callback function then we rerun the color function
    // on all the code and call the callback function on complete.
    //
    // Example:
    //
    // Rainbow.color(function() {
    //     console.log('All matching tags on the page are now highlighted');
    // });
    if (typeof args[0] === 'function') {
        _highlight(0, args[0]);
        return;
    }

    // Otherwise we use whatever node you passed in with an optional
    // callback function as the second parameter.
    //
    // Example:
    //
    // var preElement = document.createElement('pre');
    // var codeElement = document.createElement('code');
    // codeElement.setAttribute('data-language', 'javascript');
    // codeElement.innerHTML = '// Here is some JavaScript';
    // preElement.appendChild(codeElement);
    // Rainbow.color(preElement, function() {
    //     // New element is now highlighted
    // });
    //
    // If you don't pass an element it will default to `document`
    _highlight(args[0], args[1]);
}
function color(...args) {

    // If you want to straight up highlight a string you can pass the
    // string of code, the language, and a callback function.
    //
    // Example:
    //
    // Rainbow.color(code, language, function(highlightedCode, language) {
    //     // this code block is now highlighted
    // });
    if (typeof args[0] === 'string') {
        const workerData = _getWorkerData(args[0], args[1]);
        _messageWorker(workerData, (function(cb) {
            return function(data) {
                if (cb) {
                    cb(data.result, data.lang);
                }
            };
        }(args[2])));
        return;
    }

    // If you pass a callback function then we rerun the color function
    // on all the code and call the callback function on complete.
    //
    // Example:
    //
    // Rainbow.color(function() {
    //     console.log('All matching tags on the page are now highlighted');
    // });
    if (typeof args[0] === 'function') {
        _highlight(0, args[0]);
        return;
    }

    // Otherwise we use whatever node you passed in with an optional
    // callback function as the second parameter.
    //
    // Example:
    //
    // var preElement = document.createElement('pre');
    // var codeElement = document.createElement('code');
    // codeElement.setAttribute('data-language', 'javascript');
    // codeElement.innerHTML = '// Here is some JavaScript';
    // preElement.appendChild(codeElement);
    // Rainbow.color(preElement, function() {
    //     // New element is now highlighted
    // });
    //
    // If you don't pass an element it will default to `document`
    _highlight(args[0], args[1]);
}
function color ( ... args ) { // If you want to straight up highlight a string you can pass the // string of code, the language, and a callback function. // // Example: // // Rainbow.color(code, language, function(highlightedCode, language) { //     // this code block is now highlighted // }); if ( typeof args [ 0 ] === 'string' ) { const workerData = _getWorkerData ( args [ 0 ] , args [ 1 ] ) ; _messageWorker ( workerData , ( function ( cb ) { return function ( data ) { if ( cb ) { cb ( data . result , data . lang ) ; } } ; } ( args [ 2 ] ) ) ) ; return ; } // If you pass a callback function then we rerun the color function // on all the code and call the callback function on complete. // // Example: // // Rainbow.color(function() { //     console.log('All matching tags on the page are now highlighted'); // }); if ( typeof args [ 0 ] === 'function' ) { _highlight ( 0 , args [ 0 ] ) ; return ; } // Otherwise we use whatever node you passed in with an optional // callback function as the second parameter. // // Example: // // var preElement = document.createElement('pre'); // var codeElement = document.createElement('code'); // codeElement.setAttribute('data-language', 'javascript'); // codeElement.innerHTML = '// Here is some JavaScript'; // preElement.appendChild(codeElement); // Rainbow.color(preElement, function() { //     // New element is now highlighted // }); // // If you don't pass an element it will default to `document` _highlight ( args [ 0 ] , args [ 1 ] ) ; }
Starts the magic rainbow

@return {void}
Starts the magic rainbow