Skip to content

Commit 21d8f39

Browse files
ehussDylan-DPC
authored andcommitted
Fix "next chapter" spacer handling. (#1075)
1 parent c9dae17 commit 21d8f39

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/renderer/html_handlebars/helpers/navigation.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ fn find_chapter(
6969
// "index.md" (unless there really is an index.md in SUMMARY.md).
7070
match target {
7171
Target::Previous => return Ok(None),
72-
Target::Next => match chapters.iter().skip(1).next() {
72+
Target::Next => match chapters
73+
.iter()
74+
.filter(|chapter| {
75+
// Skip things like "spacer"
76+
chapter.contains_key("path")
77+
})
78+
.skip(1)
79+
.next()
80+
{
7381
Some(chapter) => return Ok(Some(chapter.clone())),
7482
None => return Ok(None),
7583
},

tests/dummy_book/src/SUMMARY.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Summary
22

33
[Dummy Book](README.md)
4+
5+
---
6+
47
[Introduction](intro.md)
58

69
- [First Chapter](first/index.md)

tests/rendered_output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn check_first_toc_level() {
306306
#[test]
307307
fn check_spacers() {
308308
let doc = root_index_html().unwrap();
309-
let should_be = 1;
309+
let should_be = 2;
310310

311311
let num_spacers = doc
312312
.find(Class("chapter").descendant(Name("li").and(Class("spacer"))))

0 commit comments

Comments
 (0)