mirror of
https://codeberg.org/scip/epuppy.git
synced 2026-02-04 17:50:58 +01:00
fix #3:
- clean mobi page breaks - reorganize the code a little - avoid for duplicate sections
This commit is contained in:
@@ -112,6 +112,8 @@ func (bk *Book) getSections() error {
|
||||
|
||||
// we have ncx points from the TOC, try those
|
||||
if len(bk.Ncx.Points) > 0 {
|
||||
known := map[string]int{}
|
||||
|
||||
for _, block := range bk.Ncx.Points {
|
||||
sect := Section{
|
||||
File: "OEBPS/" + block.Content.Src,
|
||||
@@ -128,7 +130,13 @@ func (bk *Book) getSections() error {
|
||||
}
|
||||
}
|
||||
|
||||
sections = append(sections, sect)
|
||||
if _, haveFile := known[sect.File]; !haveFile {
|
||||
// sometimes epub's have many sections but they all
|
||||
// point to the same file. To avoid duplicate content
|
||||
// we ignore sections (thus files) we have already seen.
|
||||
sections = append(sections, sect)
|
||||
known[sect.File] = 1
|
||||
}
|
||||
}
|
||||
|
||||
if len(sections) < manifestcount {
|
||||
@@ -189,7 +197,7 @@ func (bk *Book) readSectionContent() error {
|
||||
ct := Content{Src: section.File, Title: section.Title}
|
||||
|
||||
if types.MatchString(section.MediaType) {
|
||||
if err := ct.String(content); err != nil {
|
||||
if err := ct.Extract(content); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user