Skip to content

Fix "next chapter" spacer handling. #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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