- Refactored code to return text
- This is to make sending data to the TUI easier
This commit is contained in:
parent
305b74abd3
commit
2fe2421e6d
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -14,6 +14,7 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="- Can now format HTML - No longer returns to main.rs. Main function in html_module.rs now reads to console locally.">
|
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="- Can now format HTML - No longer returns to main.rs. Main function in html_module.rs now reads to console locally.">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/html_module.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/html_module.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -59,6 +60,8 @@
|
|||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
|
||||||
|
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/html_module.rs": "true",
|
||||||
|
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/main.rs": "true",
|
||||||
"settings.editor.selected.configurable": "org.jetbrains.plugins.github.ui.GithubSettingsConfigurable",
|
"settings.editor.selected.configurable": "org.jetbrains.plugins.github.ui.GithubSettingsConfigurable",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
@ -120,6 +123,7 @@
|
|||||||
<workItem from="1684345543022" duration="781000" />
|
<workItem from="1684345543022" duration="781000" />
|
||||||
<workItem from="1687970763540" duration="4628000" />
|
<workItem from="1687970763540" duration="4628000" />
|
||||||
<workItem from="1689824866342" duration="40000" />
|
<workItem from="1689824866342" duration="40000" />
|
||||||
|
<workItem from="1689861266305" duration="5017000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead.">
|
<task id="LOCAL-00001" summary="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead.">
|
||||||
<created>1687972565061</created>
|
<created>1687972565061</created>
|
||||||
|
@ -9,4 +9,5 @@ edition = "2021"
|
|||||||
epub = "2.0.0"
|
epub = "2.0.0"
|
||||||
ncurses = "5.101.0"
|
ncurses = "5.101.0"
|
||||||
scraper = "0.17.1"
|
scraper = "0.17.1"
|
||||||
|
tuikit = "0.5.0"
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
Program: Bibliofile
|
Program: Bibliofile
|
||||||
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: 6/28/23
|
Last edited: 7/20/23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
|
|
||||||
pub fn main(content: String){
|
pub fn main(content: String) -> String{
|
||||||
|
|
||||||
|
|
||||||
let str_content = Html::parse_document(&content);
|
let str_content = Html::parse_document(&content);
|
||||||
@ -15,11 +16,21 @@ pub fn main(content: String){
|
|||||||
let selector = Selector::parse("html").unwrap();
|
let selector = Selector::parse("html").unwrap();
|
||||||
let unwrapped_page = str_content.select(&selector).next().unwrap();
|
let unwrapped_page = str_content.select(&selector).next().unwrap();
|
||||||
let page = unwrapped_page.text().collect::<Vec<_>>();
|
let page = unwrapped_page.text().collect::<Vec<_>>();
|
||||||
|
let mut text = String::new();
|
||||||
//every line in document is an entry into the vector. For loop iterates through every entry and displays it.
|
//every line in document is an entry into the vector. For loop iterates through every entry and displays it.
|
||||||
for i in 0..page.len() {
|
for i in 0..page.len() {
|
||||||
println!("{}", page[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if i < page.len() {
|
||||||
|
text = text + page[i];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if i == page.len(){
|
||||||
|
text = text + page[i];
|
||||||
|
return text.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return text.to_string();
|
||||||
|
|
||||||
}
|
}
|
@ -3,8 +3,8 @@ Program: Bibliofile
|
|||||||
Language: Rustc 1.70.0
|
Language: Rustc 1.70.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: TUI-based ereader and library manager for Linux terminal environments.
|
||||||
Last edited: 6/28/23
|
Last edited: 7/20/23
|
||||||
*/
|
*/
|
||||||
//this is a test change to see if gitea is accepting pushes.
|
//this is a test change to see if gitea is accepting pushes.
|
||||||
|
|
||||||
@ -46,8 +46,8 @@ fn epub_func(epub_file: &str){
|
|||||||
|
|
||||||
let content = doc.get_current_str();
|
let content = doc.get_current_str();
|
||||||
let str_content = content.unwrap();
|
let str_content = content.unwrap();
|
||||||
html_module::main(str_content.0);
|
let text = html_module::main(str_content.0);
|
||||||
|
println!("{}", text);
|
||||||
|
|
||||||
let input_size = std::io::stdin().read_line(&mut next_or_last);
|
let input_size = std::io::stdin().read_line(&mut next_or_last);
|
||||||
let input_size_len = input_size.unwrap() - 1;
|
let input_size_len = input_size.unwrap() - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user