From 8ac6d02386955ad00a809cbaaf60f029b12ccdcc Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 17 Apr 2023 06:19:59 +0000 Subject: fix(to_html): messy markdown to html conversion --- src/gemini_to_html.rs | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index f4ab38b..593f9dd 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -21,25 +21,6 @@ use std::env::var; use germ::ast::Node; use gmi::url::Url; -fn to_html(text: &str) -> String { - 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 - } -} - fn link_from_host_href(url: &Url, href: &str) -> String { format!( "gemini://{}{}{}", @@ -69,7 +50,7 @@ pub fn gemini_to_html( for node in ast { match node { - Node::Text(text) => html.push_str(&format!("

{}

", to_html(text))), + Node::Text(text) => html.push_str(&format!("

{text}

")), Node::Link { to, text } => { let mut href = to.clone(); let mut surface = false; @@ -148,24 +129,26 @@ pub fn gemini_to_html( 3 => "h3", _ => "p", }, - to_html(text), + text, )); } Node::List(items) => html.push_str(&format!( "", items .iter() - .map(|i| format!("
  • {}
  • ", to_html(i))) + .map(|i| format!("
  • {i}
  • ")) .collect::>() .join("\n") )), Node::Blockquote(text) => { - html.push_str(&format!("
    {}
    ", to_html(text))); + html.push_str(&format!("
    {text}
    ")); } Node::PreformattedText { text, .. } => { html.push_str(&format!("
    {text}
    ")); } - Node::Whitespace => {} + Node::Whitespace => { + println!("i am white"); + } } } -- cgit v1.2.3