Fix HTML anchors in ToC generator

This commit is contained in:
Marcel Stör 2017-04-13 21:42:18 +02:00
parent b1dcb70593
commit dba73cf214
1 changed files with 3 additions and 2 deletions

View File

@ -38,7 +38,8 @@ var nodemcu = nodemcu || {};
}
function createTocTableRow(func, intro) {
// fragile attempt to auto-create the in-page anchor
var href = func.replace(/\.|:/g, '').replace('()', '').replace(' --', '-').replace(/ /g, '-');
// good tests: file.md,
var href = func.replace(/[\.:\(\)]/g, '').replace(/ --|, | /g, '-');
var link = '<a href="#' + href.toLowerCase() + '">' + func + '</a>';
return '<tr><td>' + link + '</td><td>' + intro + '</td></tr>';
}
@ -220,4 +221,4 @@ var nodemcu = nodemcu || {};
}
return values;
}
}());
}());