aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.toml6
-rw-r--r--src/convert/markdown.rs7
-rw-r--r--src/meta.rs12
-rw-r--r--tests/convert.rs17
-rw-r--r--tests/meta.rs6
5 files changed, 25 insertions, 23 deletions
diff --git a/Makefile.toml b/Makefile.toml
index fbeb052..6cc0251 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -23,8 +23,10 @@ command = "cargo"
# -------------
[tasks.checkf]
dependencies = ["fmt", "check"]
-workspace = false
[tasks.checkfc]
dependencies = ["fmt", "check", "clippy"]
-workspace = false
+
+[tasks.example]
+args = ["run", "--example", "${@}", "--all-features"]
+command = "cargo"
diff --git a/src/convert/markdown.rs b/src/convert/markdown.rs
index 9bc0e6c..b400002 100644
--- a/src/convert/markdown.rs
+++ b/src/convert/markdown.rs
@@ -50,13 +50,14 @@ pub fn convert(source: Vec<Node>) -> String {
));
}
Node::List(items) =>
- markdown.push_str(&format!("{}\n",
+ markdown.push_str(&format!(
+ "{}\n",
items
.into_iter()
.map(|i| format!("- {}", i))
.collect::<Vec<String>>()
- .join("\n"),),
- ),
+ .join("\n"),
+ )),
Node::Blockquote(text) => markdown.push_str(&format!("> {}\n", text)),
Node::PreformattedText {
alt_text,
diff --git a/src/meta.rs b/src/meta.rs
index 45c90f1..9ff2712 100644
--- a/src/meta.rs
+++ b/src/meta.rs
@@ -23,9 +23,9 @@ use std::collections::HashMap;
#[derive(Debug)]
pub struct Meta {
/// The mime type of a Gemini response
- pub mime: String,
+ mime: String,
/// The parameters of a Gemini response
- pub parameters: HashMap<String, String>,
+ parameters: HashMap<String, String>,
}
impl Meta {
#[must_use]
@@ -50,4 +50,12 @@ impl Meta {
parameters,
}
}
+
+ #[must_use]
+ pub fn mime(&self) -> &str { &self.mime }
+
+ #[must_use]
+ pub const fn parameters(&self) -> &HashMap<String, String> {
+ &self.parameters
+ }
}
diff --git a/tests/convert.rs b/tests/convert.rs
index 5ad16ca..40f337d 100644
--- a/tests/convert.rs
+++ b/tests/convert.rs
@@ -18,14 +18,11 @@
#[cfg(test)]
mod test {
- use germ::convert::{Target, from_string};
+ use germ::convert::{from_string, Target};
#[test]
fn convert_from_string_to_html_single_line() {
- assert_eq!(
- from_string("hi", &Target::HTML),
- "<p>hi</p>",
- );
+ assert_eq!(from_string("hi", &Target::HTML), "<p>hi</p>",);
}
#[test]
@@ -46,18 +43,12 @@ mod test {
#[test]
fn convert_from_string_to_markdown_single_line() {
- assert_eq!(
- from_string("hi", &Target::Markdown),
- "hi\n",
- );
+ assert_eq!(from_string("hi", &Target::Markdown), "hi\n",);
}
#[test]
fn convert_from_string_to_markdown_multi_line() {
- assert_eq!(
- from_string("hi\n# hi", &Target::Markdown),
- "hi\n# hi\n",
- );
+ assert_eq!(from_string("hi\n# hi", &Target::Markdown), "hi\n# hi\n",);
}
#[test]
diff --git a/tests/meta.rs b/tests/meta.rs
index 511b991..4233aab 100644
--- a/tests/meta.rs
+++ b/tests/meta.rs
@@ -23,7 +23,7 @@ mod test {
#[test]
fn meta_to_map_mime() {
assert_eq!(
- Meta::from_string("text/gemini; hi=2; hi2=string=2").mime,
+ Meta::from_string("text/gemini; hi=2; hi2=string=2").mime(),
"text/gemini",
);
}
@@ -32,7 +32,7 @@ mod test {
fn meta_to_map_with_parameters() {
assert_eq!(
Meta::from_string("text/gemini; hi=2; hi2=string=2")
- .parameters
+ .parameters()
.get("hi2"),
Some(&"string=2".to_string()),
);
@@ -42,7 +42,7 @@ mod test {
fn meta_to_map_length() {
assert_eq!(
Meta::from_string("text/gemini; hi=2; hi2=string=2")
- .parameters
+ .parameters()
.len(),
2,
);