This commit is contained in:
Shi-Chao Xia 2020-09-04 15:25:34 +08:00 committed by GitHub
commit ff7cb15ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -47,8 +47,17 @@ $(function() {
function generateMiniToc(divId) {
$('#minitoc').empty().append('<h2>In this section</h2>');
$('#' + divId).find('h3').each(function(i) {
let pos = $(this).text().search(" ");
let text = $(this).text().substring(0, pos);
// Get text up to non-breaking space, to omit the
// tags. If there are no tags, there will be no
// &nbsp;, so get all the text.
let text = null;
let pos = $(this).text().search(/ | ►/);
if (pos > 0) {
text = $(this).text().substring(0, pos);
}
else {
text = $(this).text();
}
$("#minitoc").append("<a href='#" + $(this).attr("id") + "'>"
+ text + "</a>");
});