fix(annotate): remove surrounding whitespace
This commit removes the surrounding whitespace form the MD table PR titles. This fixes an issue where italizised and struckout titles were incorrectly formatted as a result of the extra white space. Co-authored-by: Frederick Fogerty <frederick.fogerty@gmail.com>
This commit is contained in:
parent
515548c455
commit
8963b6f4d5
|
@ -27,13 +27,17 @@ fn safe_replace(body: &str, table: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove title prefixes from markdown table
|
||||
*/
|
||||
fn remove_title_prefixes(row: String, prefix: &str) -> String {
|
||||
let prefix = String::from(prefix);
|
||||
let prefix_1 = &prefix[0..2];
|
||||
let prefix_2 = &prefix[2..4];
|
||||
let regex_str = format!(r"{}[^\]]+{}\s*", prefix_1, prefix_2);
|
||||
// Regex removes the prefix from the title and removes surrounding whitespace
|
||||
let regex_str = format!(r"\s*{}[^\]]+{}\s*", prefix_1, prefix_2);
|
||||
let regex = Regex::new(®ex_str).unwrap();
|
||||
return regex.replace_all(&row, "").into_owned();
|
||||
return regex.replace_all(&row, "").trim().to_string().to_owned();
|
||||
}
|
||||
|
||||
pub async fn persist(
|
||||
|
|
Loading…
Reference in New Issue