tangled
alpha
login
or
join now
fuwn.net
/
germ
0
fork
atom
🦠 The Definitive Gemini Protocol Toolkit
gemini
gemini-protocol
gemtext
parser
zero-dependency
toolkit
ast
converter
html
markdown
cli
networking
0
fork
atom
overview
issues
pulls
pipelines
refactor(quick): optimise arguments
fuwn.net
2 years ago
ce929f2d
b52ad3f7
verified
This commit was signed with the committer's
known signature
.
fuwn.net
SSH Key Fingerprint:
SHA256:VPdFPyPbd6JkoMyWUdZ/kkTcIAt3sxjXD2XSAZ7FYC4=
+20
-10
1 changed file
expand all
collapse all
unified
split
crates
germ
src
quick.rs
+20
-10
crates/germ/src/quick.rs
···
23
23
}
24
24
25
25
#[must_use]
26
26
-
pub fn heading(text: &str, level: &HeadingLevel) -> String {
26
26
+
pub fn heading(
27
27
+
text: &(impl ToString + ?Sized),
28
28
+
level: &HeadingLevel,
29
29
+
) -> String {
27
30
format!(
28
31
"{} {}",
29
32
match level {
···
31
34
HeadingLevel::Two => "##",
32
35
HeadingLevel::Three => "###",
33
36
},
34
34
-
text
37
37
+
text.to_string()
35
38
)
36
39
}
37
40
38
41
#[must_use]
39
39
-
pub fn list_item(text: &str) -> String { format!("* {text}") }
42
42
+
pub fn list_item(text: &(impl ToString + ?Sized)) -> String {
43
43
+
format!("* {}", text.to_string())
44
44
+
}
40
45
41
46
#[must_use]
42
42
-
pub fn list_items(items: &[&str]) -> String {
47
47
+
pub fn list_items(items: &[&(impl ToString + ?Sized)]) -> String {
43
48
items
44
49
.iter()
45
45
-
.map(|item| list_item(item))
50
50
+
.map(|item| list_item(&item.to_string()))
46
51
.collect::<Vec<_>>()
47
52
.join("\n")
48
53
}
49
54
50
55
#[must_use]
51
51
-
pub fn link(text: &str, location: Option<&str>) -> String {
56
56
+
pub fn link(text: &(impl ToString + ?Sized), location: Option<&str>) -> String {
52
57
format!(
53
58
"=> {}{}",
54
54
-
text,
59
59
+
text.to_string(),
55
60
location.map_or_else(String::new, |l| format!(" {l}"))
56
61
)
57
62
}
58
63
59
64
#[must_use]
60
60
-
pub fn block_quote(text: &str) -> String { format!("> {text}") }
65
65
+
pub fn block_quote(text: &(impl ToString + ?Sized)) -> String {
66
66
+
format!("> {}", text.to_string())
67
67
+
}
61
68
62
69
#[must_use]
63
63
-
pub fn preformatted_text(text: &str, alt_text: Option<&str>) -> String {
64
64
-
format!("```{}\n{}\n```", alt_text.unwrap_or(""), text)
70
70
+
pub fn preformatted_text(
71
71
+
text: &(impl ToString + ?Sized),
72
72
+
alt_text: Option<&str>,
73
73
+
) -> String {
74
74
+
format!("```{}\n{}\n```", alt_text.unwrap_or(""), text.to_string())
65
75
}