mirror of
https://github.com/YGGverse/flarumdown.git
synced 2026-03-31 08:45:28 +00:00
match fmt len
This commit is contained in:
parent
0426d306bc
commit
51273e61ff
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -260,15 +260,15 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_format(data: &str, uploads: &mut HashSet<PathBuf>) -> String {
|
fn pre_format(data: &str, uploads: &mut HashSet<PathBuf>) -> String {
|
||||||
|
const R: &str = r#"(?s)<UPL-IMAGE-PREVIEW\s+alt="([^"]*)"\s+.*?url="([^"]*)"\s+[^>]*>[^<]*</UPL-IMAGE-PREVIEW>"#;
|
||||||
html_escape::decode_html_entities(&strip_tags::strip_tags(
|
html_escape::decode_html_entities(&strip_tags::strip_tags(
|
||||||
&Regex::new(r#"(?s)<UPL-IMAGE-PREVIEW\s+alt="([^"]*)"\s+.*?url="([^"]*)"\s+[^>]*>[^<]*</UPL-IMAGE-PREVIEW>"#)
|
&Regex::new(R).unwrap().replace_all(data, |c: &Captures| {
|
||||||
.unwrap()
|
let rel = c[2].trim_start_matches("/").trim_start_matches("d/");
|
||||||
.replace_all(data, |c: &Captures| {
|
|
||||||
let rel = c[2]
|
|
||||||
.trim_start_matches("/")
|
|
||||||
.trim_start_matches("d/");
|
|
||||||
uploads.insert(rel.into());
|
uploads.insert(rel.into());
|
||||||
format!("", c.get(1).map(|s|s.as_str()).unwrap_or_default())
|
format!(
|
||||||
|
"",
|
||||||
|
c.get(1).map(|s| s.as_str()).unwrap_or_default()
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
.into()
|
.into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue