'use strict'; /** * Highlight the given string of `js`. * * @private * @param {string} js * @return {string} */ function highlight(js) { return js .replace(//g, '>') .replace(/\/\/(.*)/gm, '//$1') .replace(/('.*?')/gm, '$1') .replace(/(\d+\.\d+)/gm, '$1') .replace(/(\d+)/gm, '$1') .replace( /\bnew[ \t]+(\w+)/gm, 'new $1' ) .replace( /\b(function|new|throw|return|var|if|else)\b/gm, '$1' ); } /** * Highlight the contents of tag `name`. * * @private * @param {string} name */ module.exports = function highlightTags(name) { var code = document.getElementById('mocha').getElementsByTagName(name); for (var i = 0, len = code.length; i < len; ++i) { code[i].innerHTML = highlight(code[i].innerHTML); } };