From b13c3e6b0dbf46d7fa1828a3104bcaef7db31a8f Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 4 Feb 2023 05:02:03 +0000 Subject: feat: markdown to html --- src/gemini_to_html.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index 72574a4..ea09336 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -20,6 +20,7 @@ use std::env::var; use germ::ast::Node; use gmi::url::Url; +use markly::to_html; fn link_from_host_href(url: &Url, href: &str) -> String { format!( @@ -50,7 +51,7 @@ pub fn gemini_to_html( for node in ast { match node { - Node::Text(text) => html.push_str(&format!("

{text}

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

{}

", to_html(text))), Node::Link { to, text } => { let mut href = to.clone(); let mut surface = false; @@ -111,7 +112,7 @@ pub fn gemini_to_html( html.push_str(&format!( "

{}

\n", href, - text.clone().unwrap_or_default() + to_html(&text.clone().unwrap_or_default()) )); } Node::Heading { level, text } => { @@ -127,19 +128,19 @@ pub fn gemini_to_html( 3 => "h3", _ => "p", }, - text + to_html(text) )); } Node::List(items) => html.push_str(&format!( "", items .iter() - .map(|i| format!("
  • {i}
  • ")) + .map(|i| format!("
  • {}
  • ", to_html(i))) .collect::>() .join("\n") )), Node::Blockquote(text) => { - html.push_str(&format!("
    {text}
    ")); + html.push_str(&format!("
    {}
    ", to_html(text))); } Node::PreformattedText { text, .. } => { html.push_str(&format!("
    {text}
    ")); -- cgit v1.2.3