aboutsummaryrefslogtreecommitdiff
path: root/src/convert/markdown.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-06-02 04:04:27 +0000
committerFuwn <[email protected]>2022-06-02 04:04:27 +0000
commit96c139a26a94cf0fd4d531df3c07156b3b531568 (patch)
treeed2f288d32a8a69947f3a67bfa437021015e5f05 /src/convert/markdown.rs
parentdocs(cargo): bump version to 0.2.3 (diff)
downloadgerm-96c139a26a94cf0fd4d531df3c07156b3b531568.tar.xz
germ-96c139a26a94cf0fd4d531df3c07156b3b531568.zip
feat(germ): ast struct
Diffstat (limited to 'src/convert/markdown.rs')
-rw-r--r--src/convert/markdown.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/convert/markdown.rs b/src/convert/markdown.rs
index b400002..c368973 100644
--- a/src/convert/markdown.rs
+++ b/src/convert/markdown.rs
@@ -18,7 +18,7 @@
use crate::ast::Node;
-pub fn convert(source: Vec<Node>) -> String {
+pub fn convert(source: &[Node]) -> String {
let mut markdown = String::new();
// Since we have an AST tree of the Gemtext, it is very easy to convert from
@@ -30,7 +30,7 @@ pub fn convert(source: Vec<Node>) -> String {
to,
text,
} =>
- markdown.push_str(&*text.map_or_else(
+ markdown.push_str(&*text.clone().map_or_else(
|| format!("<{}>\n", to),
|text| format!("[{}]({})\n", text, to),
)),
@@ -53,7 +53,7 @@ pub fn convert(source: Vec<Node>) -> String {
markdown.push_str(&format!(
"{}\n",
items
- .into_iter()
+ .iter()
.map(|i| format!("- {}", i))
.collect::<Vec<String>>()
.join("\n"),
@@ -65,7 +65,7 @@ pub fn convert(source: Vec<Node>) -> String {
} => {
markdown.push_str(&format!(
"```{}\n{}```\n",
- alt_text.unwrap_or_else(|| "".to_string()),
+ alt_text.clone().unwrap_or_else(|| "".to_string()),
text
));
}