diff options
| author | Fuwn <[email protected]> | 2023-05-18 06:24:50 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-05-18 06:24:50 +0000 |
| commit | 56f53ddca0135e17708af585bfb50144d6836f55 (patch) | |
| tree | 1d5beea4c266a7d9bdd50fe4750540d618b0b160 /src/convert/html.rs | |
| parent | fix: improve macro hygiene (diff) | |
| download | germ-56f53ddca0135e17708af585bfb50144d6836f55.tar.xz germ-56f53ddca0135e17708af585bfb50144d6836f55.zip | |
fmt: update rustfmt.toml
Diffstat (limited to 'src/convert/html.rs')
| -rw-r--r-- | src/convert/html.rs | 31 |
1 files changed, 11 insertions, 20 deletions
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!("<p>{text}</p>")), - Node::Link { - to, - text, - } => { + Node::Link { to, text } => { html.push_str(&format!( "<a href=\"{}\">{}</a><br>", to, text.clone().unwrap_or_else(|| to.clone()) )); } - Node::Heading { - level, - text, - } => { + Node::Heading { level, text } => { html.push_str(&format!( "<{}>{}</{0}>", match level { @@ -51,20 +45,17 @@ pub fn convert(source: &[Node]) -> String { text )); } - Node::List(items) => - html.push_str(&format!( - "<ul>{}</ul>", - items - .iter() - .map(|i| format!("<li>{i}</li>")) - .collect::<Vec<String>>() - .join("\n") - )), + Node::List(items) => html.push_str(&format!( + "<ul>{}</ul>", + items + .iter() + .map(|i| format!("<li>{i}</li>")) + .collect::<Vec<String>>() + .join("\n") + )), Node::Blockquote(text) => html.push_str(&format!("<blockquote>{text}</blockquote>")), - Node::PreformattedText { - text, .. - } => { + Node::PreformattedText { text, .. } => { html.push_str(&format!("<pre>{text}</pre>")); } Node::Whitespace => {} |