Sublists work now

This commit is contained in:
deadvey 2025-01-09 00:47:29 +00:00
parent 8e860b89e7
commit b72d43b250

View File

@ -60,16 +60,20 @@ fn parse_markdown(page_content: String) -> (String, Vec<String>) {
// Block quotes
let block_quotes_regex = Regex::new(r"^>(.*)").unwrap();
parsed_line = block_quotes_regex.replace_all(&parsed_line, |caps: &regex::Captures| {
format!(" | {}", &caps[1].on_black())
format!(" | {}", &caps[1])
}).to_string();
// Ordered list
let ordered_list_regex = Regex::new(r"^([0-9]+)\.(.*)").unwrap();
parsed_line = ordered_list_regex.replace_all(&parsed_line, " $1. $2").to_string();
let ordered_list_regex = Regex::new(r"^([ \t]+|^)([0-9]+)\. (.*)").unwrap();
parsed_line = ordered_list_regex.replace_all(&parsed_line, |caps: &regex::Captures| {
format!("{} {}. {}", &caps[1], &caps[2], &caps[3])
}).to_string();
// Unordered list
let unordered_list_regex = Regex::new(r"^(-|\+|\*).(.*)").unwrap();
parsed_line = unordered_list_regex.replace_all(&parsed_line, " • $2").to_string();
// Unordered list ([ ]+|^)- (.*)
let unordered_list_regex = Regex::new(r"^([ \t]+|^)(-|\+|\*).(.*)").unwrap();
parsed_line = unordered_list_regex.replace_all(&parsed_line, |caps: &regex::Captures| {
format!("{}{}", &caps[1], &caps[3])
}).to_string();
// Inline code
let inline_code_regex = Regex::new(r"`(.*?)`").unwrap();