mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-26 04:17:21 +00:00
add table of content to ebooks
This commit is contained in:
@@ -127,6 +127,22 @@ func ToEpub(c chapter, filename string) string {
|
||||
func AppendToEpub(e *epub.Epub, c chapter) {
|
||||
content := ""
|
||||
|
||||
// append table of content
|
||||
if len(c.SubChapters()) > 1 {
|
||||
html := "<h1>Table of Contents</h1>"
|
||||
|
||||
html += "<ol>"
|
||||
for _, sc := range c.SubChapters() {
|
||||
html += fmt.Sprintf("<li>%s</li>", sc.Name())
|
||||
}
|
||||
html += "</ol>"
|
||||
|
||||
_, err := e.AddSection(html, "Table of Contents", "", "")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// chapter content
|
||||
if c.config.Include {
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user