From b41f28cb00cc38ed97ba08f681c5a6b77ebdbd70 Mon Sep 17 00:00:00 2001
From: Fuwn
Date: Sun, 12 Mar 2023 07:27:23 +0000
Subject: fix(to_html): normalize raw p tag
---
src/gemini_to_html.rs | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs
index 1a81c28..f4ab38b 100644
--- a/src/gemini_to_html.rs
+++ b/src/gemini_to_html.rs
@@ -22,10 +22,21 @@ use germ::ast::Node;
use gmi::url::Url;
fn to_html(text: &str) -> String {
- if text.contains('$') {
+ let html = if text.contains('$') {
text.to_string()
} else {
markly::to_html(text)
+ };
+
+ if (html.ends_with("
") || html.ends_with("\n"))
+ && html.starts_with("")
+ {
+ html
+ .trim_start_matches("
")
+ .trim_end_matches("
")
+ .to_string()
+ } else {
+ html
}
}
@@ -137,7 +148,7 @@ pub fn gemini_to_html(
3 => "h3",
_ => "p",
},
- to_html(text)
+ to_html(text),
));
}
Node::List(items) => html.push_str(&format!(
--
cgit v1.2.3