From 56f53ddca0135e17708af585bfb50144d6836f55 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 18 May 2023 06:24:50 +0000 Subject: fmt: update rustfmt.toml --- src/convert/html.rs | 31 +++++++++++-------------------- src/convert/markdown.rs | 39 ++++++++++++++------------------------- 2 files changed, 25 insertions(+), 45 deletions(-) (limited to 'src/convert') diff --git a/src/convert/html.rs b/src/convert/html.rs index 581cbab..a6b0426 100644 --- a/src/convert/html.rs +++ b/src/convert/html.rs @@ -26,20 +26,14 @@ pub fn convert(source: &[Node]) -> String { for node in source { match node { Node::Text(text) => html.push_str(&format!("

{text}

")), - Node::Link { - to, - text, - } => { + Node::Link { to, text } => { html.push_str(&format!( "{}
", to, text.clone().unwrap_or_else(|| to.clone()) )); } - Node::Heading { - level, - text, - } => { + Node::Heading { level, text } => { html.push_str(&format!( "<{}>{}", match level { @@ -51,20 +45,17 @@ pub fn convert(source: &[Node]) -> String { text )); } - Node::List(items) => - html.push_str(&format!( - "", - items - .iter() - .map(|i| format!("
  • {i}
  • ")) - .collect::>() - .join("\n") - )), + Node::List(items) => html.push_str(&format!( + "", + items + .iter() + .map(|i| format!("
  • {i}
  • ")) + .collect::>() + .join("\n") + )), Node::Blockquote(text) => html.push_str(&format!("
    {text}
    ")), - Node::PreformattedText { - text, .. - } => { + Node::PreformattedText { text, .. } => { html.push_str(&format!("
    {text}
    ")); } Node::Whitespace => {} diff --git a/src/convert/markdown.rs b/src/convert/markdown.rs index 3401940..71e54f2 100644 --- a/src/convert/markdown.rs +++ b/src/convert/markdown.rs @@ -26,18 +26,11 @@ pub fn convert(source: &[Node]) -> String { for node in source { match node { Node::Text(text) => markdown.push_str(&format!("{text}\n")), - Node::Link { - to, - text, - } => - markdown.push_str(&text.clone().map_or_else( - || format!("<{to}>\n"), - |text| format!("[{text}]({to})\n"), - )), - Node::Heading { - level, - text, - } => { + Node::Link { to, text } => markdown.push_str(&text.clone().map_or_else( + || format!("<{to}>\n"), + |text| format!("[{text}]({to})\n"), + )), + Node::Heading { level, text } => { markdown.push_str(&format!( "{} {}\n", match level { @@ -49,20 +42,16 @@ pub fn convert(source: &[Node]) -> String { text )); } - Node::List(items) => - markdown.push_str(&format!( - "{}\n", - items - .iter() - .map(|i| format!("- {i}")) - .collect::>() - .join("\n"), - )), + Node::List(items) => markdown.push_str(&format!( + "{}\n", + items + .iter() + .map(|i| format!("- {i}")) + .collect::>() + .join("\n"), + )), Node::Blockquote(text) => markdown.push_str(&format!("> {text}\n")), - Node::PreformattedText { - alt_text, - text, - } => { + Node::PreformattedText { alt_text, text } => { markdown.push_str(&format!( "```{}\n{}```\n", alt_text.clone().unwrap_or_default(), -- cgit v1.2.3