From 81b8dafded273cd93d7b64b0eaa24c3ded10b734 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 2 Jun 2022 04:13:59 +0000 Subject: deps(germ): bump and use new-style ast --- Cargo.toml | 2 +- src/gemini_to_html.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dbc4391..a5f26af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ opt-level = 3 [dependencies] # Gemini gmi = "0.2.1" -germ = { version = "0.2.2", features = ["ast"] } +germ = { version = "0.2.4", features = ["ast"] } # HTTP actix-web = "4.0.1" diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index 8adfd52..7e0d6e2 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -41,7 +41,9 @@ pub fn gemini_to_html( url: &Url, is_proxy: bool, ) -> (String, String) { - let ast = germ::ast::build(&String::from_utf8_lossy(&response.data)); + let ast_tree = + germ::ast::Ast::from_string(&String::from_utf8_lossy(&response.data)); + let ast = ast_tree.inner(); let mut html = String::new(); let mut title = "".to_string(); @@ -104,14 +106,14 @@ pub fn gemini_to_html( html.push_str(&format!( "

{}

\n", href, - text.unwrap_or_else(|| "".to_string()) + text.clone().unwrap_or_else(|| "".to_string()) )); } Node::Heading { level, text, } => { - if title.is_empty() && level == 1 { + if title.is_empty() && *level == 1 { title = text.clone(); } @@ -130,7 +132,7 @@ pub fn gemini_to_html( html.push_str(&format!( "", items - .into_iter() + .iter() .map(|i| format!("
  • {}
  • ", i)) .collect::>() .join("\n") -- cgit v1.2.3