parse #tags as links (resolve #8)
This commit is contained in:
parent
976610d06f
commit
2605ae1fbe
1 changed files with 12 additions and 1 deletions
13
src/main.rs
13
src/main.rs
|
@ -502,7 +502,7 @@ fn preprocess_markdown(string: String) -> String {
|
||||||
let finder = LinkFinder::new();
|
let finder = LinkFinder::new();
|
||||||
|
|
||||||
let result = double_brackets
|
let result = double_brackets
|
||||||
.replace_all(string.as_str(), |caps: &Captures| {
|
.replace_all(&string, |caps: &Captures| {
|
||||||
format!(
|
format!(
|
||||||
"[{}]({})",
|
"[{}]({})",
|
||||||
&caps[1],
|
&caps[1],
|
||||||
|
@ -511,6 +511,17 @@ fn preprocess_markdown(string: String) -> String {
|
||||||
})
|
})
|
||||||
.to_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 result_vec = Vec::from(result.as_str());
|
||||||
let start_delims = vec![b'(', b'<'];
|
let start_delims = vec![b'(', b'<'];
|
||||||
let end_delims = vec![b')', b'>'];
|
let end_delims = vec![b')', b'>'];
|
||||||
|
|
Loading…
Reference in a new issue