diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs
index 7ecb4da6..7164a222 100644
--- a/src/renderer/html_handlebars/helpers/toc.rs
+++ b/src/renderer/html_handlebars/helpers/toc.rs
@@ -39,14 +39,17 @@ impl HelperDef for RenderToc {
};
if level > current_level {
- try!(rc.writer.write("
".as_bytes()));
- try!(rc.writer.write("".as_bytes()));
+ while level > current_level {
+ try!(rc.writer.write("- ".as_bytes()));
+ try!(rc.writer.write("
".as_bytes()));
+ current_level += 1;
+ }
try!(rc.writer.write("- ".as_bytes()));
} else if level < current_level {
while level < current_level {
try!(rc.writer.write("
".as_bytes()));
try!(rc.writer.write(" ".as_bytes()));
- current_level = current_level - 1;
+ current_level -= 1;
}
try!(rc.writer.write("- ".as_bytes()));
} else {
@@ -122,7 +125,11 @@ impl HelperDef for RenderToc {
try!(rc.writer.write("
".as_bytes()));
- current_level = level;
+ }
+ while current_level > 1 {
+ try!(rc.writer.write("
".as_bytes()));
+ try!(rc.writer.write("".as_bytes()));
+ current_level -= 1;
}
try!(rc.writer.write("".as_bytes()));