Skip to content

Commit

Permalink
fix(html): selection and highlighting borders
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jul 27, 2024
1 parent 9a6eed2 commit 5e012fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "september"
version = "0.2.29"
version = "0.2.30"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "A simple and efficient Gemini-to-HTTP proxy."
Expand Down
21 changes: 6 additions & 15 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub fn from_gemini(
url: &Url,
configuration: &crate::response::configuration::Configuration,
) -> Option<(String, String)> {
const GEMINI_FRAGMENT: &str =
r#"<span class="gemini-fragment">=&#62; </span>"#;
let ast_tree = germ::ast::Ast::from_string(
response.content().as_ref().map_or_else(String::default, String::clone),
);
Expand Down Expand Up @@ -59,14 +61,7 @@ pub fn from_gemini(
.chars()
.rev()
.collect::<String>()
.replacen(
&r#"<span class="gemini-fragment">=&#62;</span> "#
.chars()
.rev()
.collect::<String>(),
"",
1,
)
.replacen(&GEMINI_FRAGMENT.chars().rev().collect::<String>(), "", 1)
.chars()
.rev()
.collect::<String>()
Expand Down Expand Up @@ -95,7 +90,7 @@ pub fn from_gemini(
} else if previous_link {
html = align_adjacent_links(&html);

html.push_str(" <span style=\"opacity: 50%;\">|</span> ");
html.push_str(r#" <span class="gemini-fragment">|</span> "#);

previous_link_count += 1;
} else if !previous_link && matches!(node, Node::Link { .. }) {
Expand Down Expand Up @@ -223,13 +218,9 @@ pub fn from_gemini(

html.push_str(&format!(
r#"{}<a href="{}">{}</a>"#,
if condense_links {
""
} else {
r#"<span class="gemini-fragment">=&#62;</span> "#
},
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 } => {
Expand Down

0 comments on commit 5e012fe

Please sign in to comment.