parse #tags as links (resolve #8)

This commit is contained in:
Tomáš Mládek 2021-10-04 20:37:46 +02:00
parent 976610d06f
commit 2605ae1fbe

View file

@ -502,7 +502,7 @@ fn preprocess_markdown(string: String) -> String {
let finder = LinkFinder::new();
let result = double_brackets
.replace_all(string.as_str(), |caps: &Captures| {
.replace_all(&string, |caps: &Captures| {
format!(
"[{}]({})",
&caps[1],
@ -511,6 +511,17 @@ fn preprocess_markdown(string: String) -> String {
})
.to_string();
let tags = Regex::new(r"#([\w]+)").unwrap();
let result = tags
.replace_all(&result, |caps: &Captures| {
format!(
"[{}]({})",
&caps[0],
utf8_percent_encode(&caps[1], percent_encoding::NON_ALPHANUMERIC)
)
})
.to_string();
let result_vec = Vec::from(result.as_str());
let start_delims = vec![b'(', b'<'];
let end_delims = vec![b')', b'>'];