lots of fixes and additions:

- add color and color config support
- fix epub parsing
- add variable margin (left and right arrow keys)
- add help screen (hit `?`)
- add config file support
This commit is contained in:
2025-10-15 14:36:43 +02:00
parent 0d4c44ee11
commit 7544f8877a
12 changed files with 337 additions and 65 deletions

View File

@@ -2,6 +2,7 @@ package epub
import (
"archive/zip"
"strings"
)
// Open open a epub file
@@ -34,19 +35,29 @@ func Open(fn string) (*Book, error) {
for _, mf := range bk.Opf.Manifest {
if mf.ID == bk.Opf.Spine.Toc {
err = bk.readXML(bk.filename(mf.Href), &bk.Ncx)
if err != nil {
return &bk, err
}
break
}
}
for _, ncx := range bk.Ncx.Points {
content, err := bk.readBytes(bk.filename(ncx.Content.Src))
for _, file := range bk.Files() {
content, err := bk.readBytes(file)
if err != nil {
return &bk, err
}
if err := ncx.Content.String(content); err != nil {
return &bk, err
ct := Content{Src: file}
if strings.Contains(string(content), "DOCTYPE") {
if err := ct.String(content); err != nil {
return &bk, err
}
}
bk.Content = append(bk.Content, ct)
}
return &bk, nil