Merge pull request #152 from quornian/master

Make sure <ul><li> and </li></ul> are balanced
This commit is contained in:
Mathieu David 2016-07-23 15:04:51 +02:00 committed by GitHub
commit b6df992420
1 changed files with 11 additions and 4 deletions

View File

@ -39,14 +39,17 @@ impl HelperDef for RenderToc {
};
if level > current_level {
try!(rc.writer.write("<li>".as_bytes()));
try!(rc.writer.write("<ul class=\"section\">".as_bytes()));
while level > current_level {
try!(rc.writer.write("<li>".as_bytes()));
try!(rc.writer.write("<ul class=\"section\">".as_bytes()));
current_level += 1;
}
try!(rc.writer.write("<li>".as_bytes()));
} else if level < current_level {
while level < current_level {
try!(rc.writer.write("</ul>".as_bytes()));
try!(rc.writer.write("</li>".as_bytes()));
current_level = current_level - 1;
current_level -= 1;
}
try!(rc.writer.write("<li>".as_bytes()));
} else {
@ -122,7 +125,11 @@ impl HelperDef for RenderToc {
try!(rc.writer.write("</li>".as_bytes()));
current_level = level;
}
while current_level > 1 {
try!(rc.writer.write("</ul>".as_bytes()));
try!(rc.writer.write("</li>".as_bytes()));
current_level -= 1;
}
try!(rc.writer.write("</ul>".as_bytes()));