mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 14:52:37 +00:00
Make sure <ul><li> and </li></ul> are balanced
This commit is contained in:
parent
a4a277cb50
commit
b0e5f375ba
1 changed files with 11 additions and 4 deletions
|
@ -39,14 +39,17 @@ impl HelperDef for RenderToc {
|
||||||
};
|
};
|
||||||
|
|
||||||
if level > current_level {
|
if level > current_level {
|
||||||
|
while level > current_level {
|
||||||
try!(rc.writer.write("<li>".as_bytes()));
|
try!(rc.writer.write("<li>".as_bytes()));
|
||||||
try!(rc.writer.write("<ul class=\"section\">".as_bytes()));
|
try!(rc.writer.write("<ul class=\"section\">".as_bytes()));
|
||||||
|
current_level += 1;
|
||||||
|
}
|
||||||
try!(rc.writer.write("<li>".as_bytes()));
|
try!(rc.writer.write("<li>".as_bytes()));
|
||||||
} else if level < current_level {
|
} else if level < current_level {
|
||||||
while level < current_level {
|
while level < current_level {
|
||||||
try!(rc.writer.write("</ul>".as_bytes()));
|
try!(rc.writer.write("</ul>".as_bytes()));
|
||||||
try!(rc.writer.write("</li>".as_bytes()));
|
try!(rc.writer.write("</li>".as_bytes()));
|
||||||
current_level = current_level - 1;
|
current_level -= 1;
|
||||||
}
|
}
|
||||||
try!(rc.writer.write("<li>".as_bytes()));
|
try!(rc.writer.write("<li>".as_bytes()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +125,11 @@ impl HelperDef for RenderToc {
|
||||||
|
|
||||||
try!(rc.writer.write("</li>".as_bytes()));
|
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()));
|
try!(rc.writer.write("</ul>".as_bytes()));
|
||||||
|
|
Loading…
Reference in a new issue