From 47cf88ef55f2a2d82c1b0da98a9c995315768d49 Mon Sep 17 00:00:00 2001 From: Daniel Jones <104509116+DanielReddJones@users.noreply.github.com> Date: Wed, 28 Jun 2023 12:53:13 -0500 Subject: [PATCH] - Can now format HTML - No longer returns to main.rs. Main function in html_module.rs now reads to console locally. --- src/html_module.rs | 15 ++++++++++----- src/main.rs | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/html_module.rs b/src/html_module.rs index c893443..5e4920b 100644 --- a/src/html_module.rs +++ b/src/html_module.rs @@ -9,12 +9,17 @@ Last edited: 6/28/23 use scraper::{Html, Selector}; -pub fn main(content: String) -> String { - let str_content = content; +pub fn main(content: String){ - println!("{}", str_content); - let page = str_content; + let str_content = Html::parse_document(&content); + let selector = Selector::parse("html").unwrap(); + + let unwrapped_page = str_content.select(&selector).next().unwrap(); + let page = unwrapped_page.text().collect::>(); + for i in 0..page.len() { + println!("{}", page[i]); + } + - return page; } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index ecce242..a0f0ecd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,8 +46,8 @@ fn epub_func(epub_file: &str){ let content = doc.get_current_str(); let str_content = content.unwrap(); - let page = html_module::main(str_content); - println!("{}", page); + html_module::main(str_content); + let input_size = std::io::stdin().read_line(&mut next_or_last); let input_size_len = input_size.unwrap() - 1;