Handle the nesting properly
This commit is contained in:
parent
de721f5ff3
commit
9a3e50b193
2 changed files with 11 additions and 11 deletions
14
reader.go
14
reader.go
|
@ -73,7 +73,7 @@ func cleanLink(link string) string {
|
|||
|
||||
/* return next and prev urls from document and the list of chapters */
|
||||
func chapterList(e *epub.Epub, file string, id string, base string) (string, string, []chapter) {
|
||||
chapters := make([]chapter, 0)
|
||||
var chapters []chapter
|
||||
prev := ""
|
||||
next := ""
|
||||
tit := e.Titerator(epub.TITERATOR_NAVMAP)
|
||||
|
@ -90,13 +90,13 @@ func chapterList(e *epub.Epub, file string, id string, base string) (string, str
|
|||
activeIndx = len(chapters)
|
||||
}
|
||||
c.Depth = tit.Depth()
|
||||
if c.Depth > depth {
|
||||
c.In = true
|
||||
depth = c.Depth
|
||||
for c.Depth > depth {
|
||||
c.In = append(c.In, true)
|
||||
depth++
|
||||
}
|
||||
if c.Depth < depth {
|
||||
c.Out = true
|
||||
depth = c.Depth
|
||||
for c.Depth < depth {
|
||||
c.Out = append(c.Out, true)
|
||||
depth--
|
||||
}
|
||||
chapters = append(chapters, c)
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
<div class="row">
|
||||
<div class="span4">
|
||||
{{range .Chapters}}
|
||||
{{if .In}}
|
||||
{{range .Out}}
|
||||
</ul>
|
||||
{{end}}
|
||||
{{range .In}}
|
||||
<ul class="nav nav-list">
|
||||
{{end}}
|
||||
<li {{if .Active}}class="active"{{end}}><a href="{{.Link}}">{{.Label}}</a></li>
|
||||
{{if .Out}}
|
||||
</ul>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .Chapters}}
|
||||
</ul>
|
||||
|
|
Reference in a new issue