// Earlier version attempting to use quick-xml // Dropped because SQLite appears to be what most of the time is spent in anyway, and because quick-xml had some issues wrt. escaping use std::fs; use anyhow::{Result, Context}; use crossbeam::channel::{bounded}; use crossbeam::thread; use std::path::PathBuf; use rusqlite::{params, Connection}; use std::fs::File; use xml::reader::{EventReader, XmlEvent, ParserConfig}; use quick_xml::{Reader, events::Event}; use std::io::BufReader; use epub::doc::EpubDoc; use lazy_static::lazy_static; use std::collections::HashMap; #[derive(Debug, Clone)] struct BookMeta { title: String, author: String, description: String } #[derive(Debug, Clone, Copy, PartialEq)] enum XMLReadState { None, ReadingTitle, ReadingAuthor, ReadingDescription } lazy_static! { static ref ESCAPES: HashMap, Vec> = { let mut m = HashMap::new(); m.insert(b"nbsp".to_vec(), b"\xc2\xa0".to_vec()); m.insert(b"copy".to_vec(), b"\xc2\xa9".to_vec()); m.insert(b"eacute".to_vec(), b"\xc3\x89".to_vec()); m.insert(b"shy".to_vec(), b"\xc2\xad".to_vec()); m.insert(b"iuml".to_vec(), b"\xc3\x8f".to_vec()); m }; } // Extract text from an XHTML page in an ebook // Ignores