Getting error "assertion failed" when running. Backing up to github until I figure something out.

This commit is contained in:
Daniel Redd Jones 2023-05-19 18:15:48 -05:00
parent 14eb1a482e
commit f491225902
3 changed files with 24 additions and 8 deletions

View File

@ -7,4 +7,5 @@ edition = "2021"
[dependencies]
epub = "1.2.2"
horrorshow = "0.8.4"
regex = "1.8.1"
soup = "0.5.1"

View File

@ -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::<Vec<_>>();
assert_eq!(results, vec![
"html".to_string(),
"head".to_string(),
"body".to_string(),
"p".to_string(),
"b".to_string(),
]);
return results.join("\n");
}

View File

@ -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);
}