test-code-highlight

    /**
     * This is a JavaScript sample.
     */
    var matches = require('./matches');
    
    module.exports = {
        /**
         * Applies all regular expression to the code and stores all found
         * matches in the `this.matches` array.
         */
        parse: function (code, regexList, opts) {
            var result = [];

            regexList = regexList || [];

            for (var i = 0, l = regexList.length; i < l; i++)
                // BUG: length returns len+1 for array if methods added to prototype chain (oising@gmail.com)
                if (typeof regexList[i] === 'object')
                    result = result.concat(matches.find(code, regexList[i]));

            result = matches.sort(result);
            result = matches.removeNested(result);
            result = matches.compact(result);

            return result;
        }
    };
posted @ 2017-09-13 17:17  FigureSkating  阅读(139)  评论(0编辑  收藏  举报