diff --git a/reader.go b/reader.go index d59cb7c..e047816 100644 --- a/reader.go +++ b/reader.go @@ -16,6 +16,8 @@ type chapter struct { Link string Depth int Active bool + In bool // one level in depth + Out bool // one level out depth } type readData struct { @@ -78,15 +80,24 @@ func chapterList(e *epub.Epub, file string, id string, base string) (string, str defer tit.Close() activeIndx := -1 + depth := 0 for ; tit.Valid(); tit.Next() { var c chapter c.Label = tit.Label() c.Link = genLink(id, base, tit.Link()) - c.Depth = tit.Depth() if cleanLink(tit.Link()) == file { c.Active = true activeIndx = len(chapters) } + c.Depth = tit.Depth() + if c.Depth > depth { + c.In = true + depth = c.Depth + } + if c.Depth < depth { + c.Out = true + depth = c.Depth + } chapters = append(chapters, c) } diff --git a/templates/read.html b/templates/read.html index 3c59232..c073ee1 100644 --- a/templates/read.html +++ b/templates/read.html @@ -18,11 +18,18 @@
- +{{end}}