Fix "next chapter" spacer handling. (#1075)

This commit is contained in:
Eric Huss 2019-10-25 08:33:21 -07:00 committed by Dylan DPC
parent c9dae170f3
commit 21d8f394ae
3 changed files with 13 additions and 2 deletions

View File

@ -69,7 +69,15 @@ fn find_chapter(
// "index.md" (unless there really is an index.md in SUMMARY.md).
match target {
Target::Previous => return Ok(None),
Target::Next => match chapters.iter().skip(1).next() {
Target::Next => match chapters
.iter()
.filter(|chapter| {
// Skip things like "spacer"
chapter.contains_key("path")
})
.skip(1)
.next()
{
Some(chapter) => return Ok(Some(chapter.clone())),
None => return Ok(None),
},

View File

@ -1,6 +1,9 @@
# Summary
[Dummy Book](README.md)
---
[Introduction](intro.md)
- [First Chapter](first/index.md)

View File

@ -306,7 +306,7 @@ fn check_first_toc_level() {
#[test]
fn check_spacers() {
let doc = root_index_html().unwrap();
let should_be = 1;
let should_be = 2;
let num_spacers = doc
.find(Class("chapter").descendant(Name("li").and(Class("spacer"))))