aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/web.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs
index df13058..1be6f48 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -49,7 +49,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
)) else {
return error("The URL you provided is invalid.", &context);
};
- let mut contents = vec![format!("=> {url} {url}")];
+ let mut contents = vec![format!("=> {url} {url}\n")];
let website = if let Ok(website) = reqwest::get(url.clone()).await {
if let Ok(text) = website.text().await {
text
@@ -86,8 +86,22 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
};
}
+ if let Some(id) = queries.get("class") {
+ nodes = if let Some(element) =
+ dom.get_elements_by_class_name(id.as_str()).nth(0)
+ {
+ if let Some(children) = element.get(parser).unwrap().children() {
+ children.all(parser).iter().peekable()
+ } else {
+ nodes
+ }
+ } else {
+ nodes
+ };
+ }
+
while let Some(element) = nodes.next() {
- let mut text = String::new();
+ let text = String::new();
let () = element.as_tag().map_or((), |tag| {
match tag.name().as_utf8_str().to_string().as_str() {
@@ -141,7 +155,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
"h3" => {
contents.push(format!("\n### {}\n\n", tag.inner_text(parser)));
}
- "pre" | "code" => {
+ "pre" => {
contents.push(format!("```\n{}```\n", tag.inner_text(parser)));
}
"blockquote" => {
@@ -166,13 +180,13 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
"html" | "head" | "script" | "link" | "title" | "body" | "ul"
| "style" => {}
_ => {
- text = tag.inner_text(parser).to_string();
+ // text = tag.inner_text(parser).to_string();
- if !(text.contains("Proxy Information")
- || text.contains("Proxied content from"))
- {
- contents.push(format!("{text}\n\n"));
- }
+ // if !(text.contains("Proxy Information")
+ // || text.contains("Proxied content from"))
+ // {
+ // contents.push(format!("{text}\n\n"));
+ // }
}
}
});