diff --git a/src/bigblow_theme/css/bigblow.css b/src/bigblow_theme/css/bigblow.css
index 4a3836c..0282348 100644
--- a/src/bigblow_theme/css/bigblow.css
+++ b/src/bigblow_theme/css/bigblow.css
@@ -620,6 +620,7 @@ span.todo .selected {
padding: 4px;
position: fixed;
width: auto;
+ white-space: pre;
}
#minitoc a {
diff --git a/src/bigblow_theme/js/bigblow.js b/src/bigblow_theme/js/bigblow.js
index 7ae30f3..6ee48da 100644
--- a/src/bigblow_theme/js/bigblow.js
+++ b/src/bigblow_theme/js/bigblow.js
@@ -45,13 +45,27 @@ $(function() {
// generate contents of minitoc
function generateMiniToc(divId) {
- $('#minitoc').empty().append('
In this section
');
- $('#' + divId).find('h3').each(function(i) {
- let pos = $(this).text().search(" ");
- let text = $(this).text().substring(0, pos);
- $("#minitoc").append(""
- + text + "");
- });
+ let headers = null;
+ if(divId) {
+ $('#minitoc').empty().append('In this section
');
+ headers = $('#' + divId).find('h3');
+ }
+ else {
+ $('#minitoc').empty().append('In this document
');
+ headers = $('div#content').find(':header');
+ }
+ headers.each(function(i) {
+ let text = $(this)
+ .clone() //clone the element
+ .children() //select all the children
+ .remove() //remove all the children
+ .end() //again go back to selected element
+ .text().trim();
+ var level = parseInt(this.nodeName.substring(1), 10);
+ let prefix = "".padStart(level-1, " ");
+ $("#minitoc").append(""
+ + prefix + text + "");
+ });
// Ensure that the target is expanded (hideShow)
$('#minitoc a[href^="#"]').click(function() {
var href = $(this).attr('href');