mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 21:25:28 +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
|
self.pattern
|
||||||
.replace(
|
.replace(
|
||||||
"{content}",
|
"{content}",
|
||||||
&if self.pattern.contains("{tags}") {
|
&if matches!(self.format, Format::Gemtext) || self.pattern.contains("{tags}") {
|
||||||
content.replace("#", "")
|
content.replace('#', "")
|
||||||
} else {
|
} else {
|
||||||
content
|
content
|
||||||
},
|
},
|
||||||
|
|
@ -60,7 +60,22 @@ impl Template {
|
||||||
.replace(
|
.replace(
|
||||||
"{tags}",
|
"{tags}",
|
||||||
&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(),
|
.unwrap_or_default(),
|
||||||
)
|
)
|
||||||
.replace("{link}", &format!("\n\n=> {link}"))
|
.replace("{link}", &format!("\n\n=> {link}"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue