Figured out HTML rendering, backing up just in case if I mess something up in the future.
This commit is contained in:
parent
f491225902
commit
5418a2b7c6
@ -4,33 +4,14 @@ Language: Rustc 1.69.0
|
||||
ide: CLion
|
||||
Operating system: Fedora 38/WSL
|
||||
Purpose: This class is meant to process and return HTML formatted text as strings.
|
||||
Last edited: 5/18/23
|
||||
Last edited: 5/19/23
|
||||
*/
|
||||
|
||||
|
||||
use regex::Regex;
|
||||
use epub::archive;
|
||||
use soup::{NodeExt, QueryBuilderExt, Soup};
|
||||
|
||||
|
||||
pub fn main(content: String) -> String{
|
||||
|
||||
println!("IF YOU CAN READ THIS, I HAVE ENTERED THE HTML MODULE");
|
||||
|
||||
|
||||
pub fn main(content: String) -> String {
|
||||
let mut str_content = 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");
|
||||
let page = soup.text();
|
||||
return page;
|
||||
}
|
Loading…
Reference in New Issue
Block a user