Fix "next chapter" spacer handling. (#1075)
This commit is contained in:
parent
c9dae170f3
commit
21d8f394ae
|
@ -69,7 +69,15 @@ fn find_chapter(
|
||||||
// "index.md" (unless there really is an index.md in SUMMARY.md).
|
// "index.md" (unless there really is an index.md in SUMMARY.md).
|
||||||
match target {
|
match target {
|
||||||
Target::Previous => return Ok(None),
|
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())),
|
Some(chapter) => return Ok(Some(chapter.clone())),
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
# Summary
|
# Summary
|
||||||
|
|
||||||
[Dummy Book](README.md)
|
[Dummy Book](README.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
[Introduction](intro.md)
|
[Introduction](intro.md)
|
||||||
|
|
||||||
- [First Chapter](first/index.md)
|
- [First Chapter](first/index.md)
|
||||||
|
|
|
@ -306,7 +306,7 @@ fn check_first_toc_level() {
|
||||||
#[test]
|
#[test]
|
||||||
fn check_spacers() {
|
fn check_spacers() {
|
||||||
let doc = root_index_html().unwrap();
|
let doc = root_index_html().unwrap();
|
||||||
let should_be = 1;
|
let should_be = 2;
|
||||||
|
|
||||||
let num_spacers = doc
|
let num_spacers = doc
|
||||||
.find(Class("chapter").descendant(Name("li").and(Class("spacer"))))
|
.find(Class("chapter").descendant(Name("li").and(Class("spacer"))))
|
||||||
|
|
Loading…
Reference in New Issue