- let display = if text.is_empty() { url } else { text };
- format!("<p class=\"a\"><a href=\"{url}\">{display}</a></p>")
+ 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!("<p class=\"a\"><a href=\"{processed_url}\">{display}</a></p>")