mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 13:15:27 +00:00
filter gemtext special chars
This commit is contained in:
parent
25186136bc
commit
70e4c0d20f
1 changed files with 18 additions and 3 deletions
|
|
@ -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}"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue