X-Git-Url: https://git.r.bdr.sh/rbdr/gema_texto/blobdiff_plain/8beb2bfa1af988442550c9e6999d924dd14b5236..HEAD:/src/html_renderer.rs diff --git a/src/html_renderer.rs b/src/html_renderer.rs index e513533..61d2d73 100644 --- a/src/html_renderer.rs +++ b/src/html_renderer.rs @@ -1,4 +1,5 @@ use crate::gemini_parser::GeminiLine; +use std::path::Path; /// Renders HTML from a vector of `GeminiLine` elements. /// @@ -99,8 +100,23 @@ fn line_content(line: &GeminiLine) -> String { match line { GeminiLine::Text(content, false) => format!("
{content}
"), GeminiLine::Link(url, text) => { - let display = if text.is_empty() { url } else { text }; - format!("") + let path = Path::new(url); + let processed_url = if !url.starts_with("gemini:") + && path + .extension() + .map_or(false, |ext| ext.eq_ignore_ascii_case("gmi")) + { + url.replace(".gmi", ".html") + } else { + url.to_string() + }; + + let display = if text.is_empty() { + &processed_url + } else { + text + }; + format!("") } GeminiLine::Heading(level, content) => format!("