Skip to content

Commit

Permalink
Fix "next chapter" spacer handling. (#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss authored and Dylan-DPC committed Oct 25, 2019
1 parent c9dae17 commit 21d8f39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/renderer/html_handlebars/helpers/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand Down
3 changes: 3 additions & 0 deletions tests/dummy_book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Summary

[Dummy Book](README.md)

---

[Introduction](intro.md)

- [First Chapter](first/index.md)
Expand Down
2 changes: 1 addition & 1 deletion tests/rendered_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))
Expand Down

0 comments on commit 21d8f39

Please sign in to comment.