filter gemtext special chars

This commit is contained in:
postscriptum 2025-07-04 16:01:53 +03:00
parent 25186136bc
commit 70e4c0d20f

View file

@ -29,8 +29,8 @@ impl Template {
self.pattern
.replace(
"{content}",
&if self.pattern.contains("{tags}") {
content.replace("#", "")
&if matches!(self.format, Format::Gemtext) || self.pattern.contains("{tags}") {
content.replace('#', "")
} else {
content
},
@ -60,7 +60,22 @@ impl Template {
.replace(
"{tags}",
&tags
.map(|t| format!("\n\n{}", t.join(", ")))
.map(|t| {
format!(
"\n\n{}",
// trim gemtext special chars
if matches!(self.format, Format::Gemtext) {
let mut b = Vec::with_capacity(t.len());
for this in t {
b.push(this.replace('#', ""))
}
b
} else {
t
}
.join(", ")
)
})
.unwrap_or_default(),
)
.replace("{link}", &format!("\n\n=> {link}"))