diff --git a/src/main.rs b/src/main.rs index 7f19f09..c17acb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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'>'];