diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index 3349edc1..5914d42f 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -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), }, diff --git a/tests/dummy_book/src/SUMMARY.md b/tests/dummy_book/src/SUMMARY.md index ee559df6..7e9d3d1f 100644 --- a/tests/dummy_book/src/SUMMARY.md +++ b/tests/dummy_book/src/SUMMARY.md @@ -1,6 +1,9 @@ # Summary [Dummy Book](README.md) + +--- + [Introduction](intro.md) - [First Chapter](first/index.md) diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index 808ed172..95ff8594 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -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"))))