From e8f99816521ed4b553b87265d13b7d5e95842997 Mon Sep 17 00:00:00 2001 From: Max Value Date: Wed, 7 May 2025 18:51:49 +0100 Subject: [PATCH] Finished all current elementes Added: - Blockquote - Contents - Preformatted --- schema.gn | 11 +++++------ src/parser.rs | 24 ++++++------------------ 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/schema.gn b/schema.gn index c91201a..6128703 100644 --- a/schema.gn +++ b/schema.gn @@ -13,7 +13,6 @@ author: Goodnight Publishing - Headings are unchanged from vanilla markdown (6 levels). - Paragraphs are unchanged from vanilla markdown. -- Ordered lists are unchanged from vanilla markdown. - URLs and email addresses are unchanged from vanilla markdown. - Images are unchanged from vanilla markdown. - Inline code with the backtick character is unchanged from vanilla markdown. @@ -26,12 +25,12 @@ author: Goodnight Publishing - Bold styling will work only with a single asterisk character. - Italic styling will work only with a single underscore character. - Unordered lists will work only with the hyphen character. +- Ordered lists will work only with the period character. -1. Ordered -2. Lists -3. Are -4. As -5. Written +. Test +. Of +. Ordered +. List ### Macros diff --git a/src/parser.rs b/src/parser.rs index 349ec9c..2944eb5 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -47,34 +47,22 @@ pub fn parse_body (string: String, metadata: Metadata, reference_list: Option { + // match all list patterns + ('-', ..) | ('.', ..) => { + let matching = &line[..1]; let mut items: Vec = vec![Item{text: line[1..].to_string()}]; - while lines.peek() != None && lines.peek() != Some(&"") && &lines.peek().unwrap()[..1] == "-" { - items.push(Item{text: lines.next().unwrap()[1..].to_string()}); - } - document.push(Box::new(List{items, ordered: false})) - } - - // match all ordered list patterns (matches up to 999. ...) - ('1'..='9', '.', ..) | ('1'..='9', '1'..='9', '.', ..) | ('1'..='9', '1'..='9', '1'..='9', '.', ..) => { - let mut items: Vec = vec![Item{text: line.split_once(".").unwrap().1.to_string()}]; while match lines.peek() { Some(string) => { if string == &"" {false} else { - let re = Regex::new(r"\d*.").unwrap(); - re.is_match_at(string, 0) + &string[..1] == matching } }, None => false } { - match lines.next().unwrap().split_once(".") { - Some((_, text)) => {items.push(Item{text: text.to_string()});}, - None => () - } + items.push(Item{text: lines.next().unwrap()[1..].to_string()}); } - document.push(Box::new(List{items, ordered: true})) + document.push(Box::new(List{items, ordered: matching == "."})) } // match all insert sequences like the title -- 2.39.2