Skip to content

armgit / mocha

Public Imported from GitHub
0

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

added links back to markdown TOC

TJ Holowaychuk739114e45cd6
diff --git a/lib/reporters/markdown.js b/lib/reporters/markdown.js
index 7d7842b2..a54b8d9a 100644
--- a/lib/reporters/markdown.js
+++ b/lib/reporters/markdown.js
@@ -36,8 +36,6 @@ function Markdown(runner) {
return Array(level).join(' ');
}
- // if (!suite.root) toc += indent() + '- [' + suite.title + '](#' + slug + ')\n';
-
function mapTOC(suite, obj) {
var ret = obj;
obj = obj[suite.title] = obj[suite.title] || {};
@@ -50,8 +48,10 @@ function Markdown(runner) {
function stringifyTOC(obj, level) {
++level;
var buf = '';
+ var link;
for (var key in obj) {
- if (key) buf += Array(level).join(' ') + ' - ' + key + '\n';
+ if (key) link = ' - [' + key + '](#' + utils.slug(key) + ')\n';
+ if (key) buf += Array(level).join(' ') + link;
buf += stringifyTOC(obj[key], level);
}
--level;