diff --git a/Cargo.toml b/Cargo.toml index fe0e644..4043ea9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" [dependencies] epub = "1.2.2" -horrorshow = "0.8.4" +regex = "1.8.1" +soup = "0.5.1" diff --git a/src/html_module.rs b/src/html_module.rs index cdb4d2d..05a9676 100644 --- a/src/html_module.rs +++ b/src/html_module.rs @@ -7,15 +7,30 @@ Purpose: This class is meant to process and return HTML formatted text as string Last edited: 5/18/23 */ -extern crate horrorshow; + +use regex::Regex; use epub::archive; -use horrorshow::prelude::*; -use horrorshow::helper::doctype; +use soup::{NodeExt, QueryBuilderExt, Soup}; pub fn main(content: String) -> String{ println!("IF YOU CAN READ THIS, I HAVE ENTERED THE HTML MODULE"); + + let mut str_content = content; - return str_content; + let soup = Soup::new(&str_content); + let results = soup.tag(true) + .find_all() + .map(|tag| tag.name().to_string()) + .collect::>(); + assert_eq!(results, vec![ + "html".to_string(), + "head".to_string(), + "body".to_string(), + "p".to_string(), + "b".to_string(), + ]); + + return results.join("\n"); } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 78e79c3..2370020 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ mod html_module; use epub::doc::EpubDoc; //library for navigating epubs use std::env; use std::io; -use horrorshow::Template; + //initial function. Reads the ebook passed by argument. @@ -38,8 +38,8 @@ fn epub_func(epub_file: &str){ - str_content = html_module::main(str_content); - println!("{}", str_content); + let page = html_module::main(str_content); + println!("{}", page); }