aboutsummaryrefslogtreecommitdiff
path: root/src/ast
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-05-18 06:24:50 +0000
committerFuwn <[email protected]>2023-05-18 06:24:50 +0000
commit56f53ddca0135e17708af585bfb50144d6836f55 (patch)
tree1d5beea4c266a7d9bdd50fe4750540d618b0b160 /src/ast
parentfix: improve macro hygiene (diff)
downloadgerm-56f53ddca0135e17708af585bfb50144d6836f55.tar.xz
germ-56f53ddca0135e17708af585bfb50144d6836f55.zip
fmt: update rustfmt.toml
Diffstat (limited to 'src/ast')
-rw-r--r--src/ast/container.rs76
1 files changed, 26 insertions, 50 deletions
diff --git a/src/ast/container.rs b/src/ast/container.rs
index acb8894..0e3337d 100644
--- a/src/ast/container.rs
+++ b/src/ast/container.rs
@@ -82,9 +82,7 @@ impl Ast {
));
}
- Self {
- inner: ast
- }
+ Self { inner: ast }
}
#[must_use]
@@ -94,45 +92,31 @@ impl Ast {
for node in &self.inner {
match node {
Node::Text(text) => gemtext.push_str(&format!("{text}\n")),
- Node::Link {
+ Node::Link { to, text } => gemtext.push_str(&format!(
+ "=> {}{}\n",
to,
- text,
- } =>
- gemtext.push_str(&format!(
- "=> {}{}\n",
- to,
- text
- .clone()
- .map_or_else(String::new, |text| format!(" {text}")),
- )),
- Node::Heading {
- level,
- text,
- } =>
- gemtext.push_str(&format!(
- "{} {}\n",
- match level {
- 1 => "#",
- 2 => "##",
- 3 => "###",
- _ => "",
- },
- text
- )),
- Node::List(items) =>
- gemtext.push_str(&format!(
- "{}\n",
- items
- .iter()
- .map(|i| format!("* {i}"))
- .collect::<Vec<String>>()
- .join("\n"),
- )),
+ text.clone().map_or_else(String::new, |text| format!(" {text}")),
+ )),
+ Node::Heading { level, text } => gemtext.push_str(&format!(
+ "{} {}\n",
+ match level {
+ 1 => "#",
+ 2 => "##",
+ 3 => "###",
+ _ => "",
+ },
+ text
+ )),
+ Node::List(items) => gemtext.push_str(&format!(
+ "{}\n",
+ items
+ .iter()
+ .map(|i| format!("* {i}"))
+ .collect::<Vec<String>>()
+ .join("\n"),
+ )),
Node::Blockquote(text) => gemtext.push_str(&format!("> {text}\n")),
- Node::PreformattedText {
- alt_text,
- text,
- } =>
+ Node::PreformattedText { alt_text, text } =>
gemtext.push_str(&format!(
"```{}\n{}```\n",
alt_text.clone().unwrap_or_default(),
@@ -190,11 +174,7 @@ impl Ast {
text: {
let rest = split.collect::<Vec<String>>().join(" ");
- if rest.is_empty() {
- None
- } else {
- Some(rest)
- }
+ if rest.is_empty() { None } else { Some(rest) }
},
});
@@ -263,11 +243,7 @@ impl Ast {
}
} else {
nodes.push(Node::PreformattedText {
- alt_text: if alt_text.is_empty() {
- None
- } else {
- Some(alt_text)
- },
+ alt_text: if alt_text.is_empty() { None } else { Some(alt_text) },
text: preformatted,
});