Got the string passed to the HTML Module. Content is <String, Error> so I unwrapped it and saved the value as only a string. Tomorrow I parse the HTML in html_module.

This commit is contained in:
Daniel Jones 2023-05-18 22:01:14 -05:00
parent e7dfddc8f8
commit 14eb1a482e
2 changed files with 18 additions and 24 deletions

View File

@ -4,14 +4,18 @@ Language: Rustc 1.69.0
ide: CLion ide: CLion
Operating system: Fedora 38/WSL Operating system: Fedora 38/WSL
Purpose: This class is meant to process and return HTML formatted text as strings. Purpose: This class is meant to process and return HTML formatted text as strings.
Last edited: 5/15/23 Last edited: 5/18/23
*/ */
extern crate horrorshow; extern crate horrorshow;
use epub::archive;
use horrorshow::prelude::*; use horrorshow::prelude::*;
use horrorshow::helper::doctype; use horrorshow::helper::doctype;
pub fn main(){ pub fn main(content: String) -> String{
println!("if you can read this, you reached the HTML class.");
println!("IF YOU CAN READ THIS, I HAVE ENTERED THE HTML MODULE");
let mut str_content = content;
return str_content;
} }

View File

@ -4,7 +4,7 @@ Language: Rustc 1.69.0
ide: CLion ide: CLion
Operating system: Fedora 38/WSL Operating system: Fedora 38/WSL
Purpose: ncurses based ereader and library manager for Linux terminal environments. Purpose: ncurses based ereader and library manager for Linux terminal environments.
Last edited: 5/15/23 Last edited: 5/18/23
*/ */
@ -12,7 +12,7 @@ mod html_module;
use epub::doc::EpubDoc; //library for navigating epubs use epub::doc::EpubDoc; //library for navigating epubs
use std::env; use std::env;
use std::io; use std::io;
use horrorshow::Template;
//initial function. Reads the ebook passed by argument. //initial function. Reads the ebook passed by argument.
@ -20,36 +20,26 @@ use std::io;
fn main() { fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
let filename = &args[1]; let filename = &args[1];
epub(filename); epub_func(filename);
} }
//parses epub files //parses epub files
fn epub(epub_file: &str){ fn epub_func(epub_file: &str){
let item_count = 1; //let item_count = 1;
let doc = EpubDoc::new(&epub_file); let doc = EpubDoc::new(&epub_file);
assert!(doc.is_ok()); assert!(doc.is_ok());
let mut doc = doc.unwrap(); let mut doc = doc.unwrap();
doc.set_current_page(50); doc.set_current_page(50);
let content = doc.get_current_str(); let mut content = doc.get_current_str();
let mut str_content = content.unwrap();
//while true{ let mut next = String::new();
let mut next = String::new();
io::stdin()
.read_line(&mut next)
.expect("Failed to read line");
//if next == "n"{
doc.go_next();
println!("{:?}", content);
//}
html_module::main();
str_content = html_module::main(str_content);
//} println!("{}", str_content);
} }