aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-03-12 07:27:23 +0000
committerFuwn <[email protected]>2023-03-12 07:27:23 +0000
commit9f3cd3f0874116b7a373411a6bc4bd3cefa6fe93 (patch)
tree335d49eff07c6c6ee479bfafe510b0ab3f0d00d3 /src
parentfeat(cargo): bump to 0.2.3 (diff)
downloadseptember-9f3cd3f0874116b7a373411a6bc4bd3cefa6fe93.tar.xz
september-9f3cd3f0874116b7a373411a6bc4bd3cefa6fe93.zip
fix(to_html): normalize raw p tag
Diffstat (limited to 'src')
-rw-r--r--src/gemini_to_html.rs15
1 files changed, 13 insertions, 2 deletions
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("</p>") || html.ends_with("</p>\n"))
+ && html.starts_with("<p>")
+ {
+ html
+ .trim_start_matches("<p>")
+ .trim_end_matches("</p>")
+ .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!(