diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gemini_to_html.rs | 15 |
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!( |