aboutsummaryrefslogtreecommitdiffstats
path: root/src/epub.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-05-17 03:39:30 -0700
committerJames Campos <james.r.campos@gmail.com>2020-05-17 03:39:30 -0700
commit176c17613800f3cea278342bcfcdb83aece6f96f (patch)
treef9d17605580fe59ce96eae9b89b324a16c68e40e /src/epub.rs
parent6100ffbfab86081fa1e9e033717c54b0edc99d08 (diff)
downloadbk-176c17613800f3cea278342bcfcdb83aece6f96f.tar.gz
internal
Diffstat (limited to 'src/epub.rs')
-rw-r--r--src/epub.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/epub.rs b/src/epub.rs
index 48263c2..795f4d1 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -6,8 +6,7 @@ use roxmltree::{Document, Node};
pub struct Epub {
container: zip::ZipArchive<File>,
- pub nav: Vec<String>,
- pub chapters: Vec<String>,
+ pub chapters: Vec<(String, String)>,
}
impl Epub {
@@ -15,13 +14,12 @@ impl Epub {
let file = File::open(path)?;
let mut epub = Epub {
container: zip::ZipArchive::new(file)?,
- nav: Vec::new(),
chapters: Vec::new(),
};
- let (nav, chapters) = epub
+ epub.chapters = epub
.get_nav()
.into_iter()
- .filter_map(|(path, label)| {
+ .filter_map(|(path, title)| {
let xml = epub.get_text(&path);
// https://github.com/RazrFalcon/roxmltree/issues/12
// UnknownEntityReference for HTML entities
@@ -32,12 +30,10 @@ impl Epub {
if chapter.is_empty() {
None
} else {
- Some((label, chapter))
+ Some((title, chapter))
}
})
- .unzip();
- epub.nav = nav;
- epub.chapters = chapters;
+ .collect();
Ok(epub)
}
fn render(buf: &mut String, n: Node) {