Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

highlight code

TJ Holowaychuke294b1e4b268
diff --git a/support/tail.js b/support/tail.js
index f3d0afb6..c12e1e37 100644
--- a/support/tail.js
+++ b/support/tail.js
@@ -87,6 +87,17 @@ window.mocha = require('mocha');
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
}
+ /**
+ * Highlight code contents.
+ */
+
+ function highlightCode() {
+ var code = document.getElementsByTagName('code');
+ for (var i = 0, len = code.length; i < len; ++i) {
+ code[i].innerHTML = highlight(code[i].innerHTML);
+ }
+ }
+
/**
* Parse the given `qs`.
*/
@@ -124,11 +135,7 @@ window.mocha = require('mocha');
var reporter = new Reporter(runner);
var query = parse(window.location.search || "");
if (query.grep) runner.grep(new RegExp(query.grep));
- runner.on('end', function(){
- // $('code').each(function(){
- // $(this).html(highlight($(this).text()));
- // });
- });
+ runner.on('end', highlightCode);
return runner.run();
};
})();