diff options
| -rw-r--r-- | content/blogs/technology/C++.gmi | 3 | ||||
| -rw-r--r-- | src/modules/web.rs | 32 |
2 files changed, 26 insertions, 9 deletions
diff --git a/content/blogs/technology/C++.gmi b/content/blogs/technology/C++.gmi new file mode 100644 index 0000000..17606ed --- /dev/null +++ b/content/blogs/technology/C++.gmi @@ -0,0 +1,3 @@ +# C++ + +=> /web/www.neilhenning.dev/posts/yourownconstantfolder/?class=post-content Your Own Constant Folder in C/C++
\ No newline at end of file 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")); + // } } } }); |