From 8710ded3c2cd9d95fd8d5c34e5d4f49c5eb16640 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 27 Jul 2024 23:40:04 +0000 Subject: fix(html): selection and highlighting borders --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/html.rs | 21 ++++++--------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f89c734..eae8375 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2143,7 +2143,7 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "september" -version = "0.2.29" +version = "0.2.30" dependencies = [ "actix-web", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 7224900..9a1fecb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.2.29" +version = "0.2.30" authors = ["Fuwn "] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." diff --git a/src/html.rs b/src/html.rs index 8efd7d9..299242c 100644 --- a/src/html.rs +++ b/src/html.rs @@ -21,6 +21,8 @@ pub fn from_gemini( url: &Url, configuration: &crate::response::configuration::Configuration, ) -> Option<(String, String)> { + const GEMINI_FRAGMENT: &str = + r#"=> "#; let ast_tree = germ::ast::Ast::from_string( response.content().as_ref().map_or_else(String::default, String::clone), ); @@ -59,14 +61,7 @@ pub fn from_gemini( .chars() .rev() .collect::() - .replacen( - &r#"=> "# - .chars() - .rev() - .collect::(), - "", - 1, - ) + .replacen(&GEMINI_FRAGMENT.chars().rev().collect::(), "", 1) .chars() .rev() .collect::() @@ -95,7 +90,7 @@ pub fn from_gemini( } else if previous_link { html = align_adjacent_links(&html); - html.push_str(" | "); + html.push_str(r#" | "#); previous_link_count += 1; } else if !previous_link && matches!(node, Node::Link { .. }) { @@ -223,13 +218,9 @@ pub fn from_gemini( html.push_str(&format!( r#"{}{}"#, - if condense_links { - "" - } else { - r#"=> "# - }, + if condense_links { "" } else { GEMINI_FRAGMENT }, href, - safe(text.as_ref().unwrap_or(to)), + safe(text.as_ref().unwrap_or(to)).trim(), )); } Node::Heading { level, text } => { -- cgit v1.2.3