]> OzVa Git service - gn-parser/commitdiff
Finished all current elementes
authorMax Value <greenwoodw50@gmail.com>
Wed, 7 May 2025 17:51:49 +0000 (18:51 +0100)
committerMax Value <greenwoodw50@gmail.com>
Wed, 7 May 2025 17:51:49 +0000 (18:51 +0100)
Added:
- Blockquote
- Contents
- Preformatted

schema.gn
src/parser.rs

index c91201ab0b5913cdc570088f043fe7dba8615b67..6128703c7a646750965757bbab9df0fe3f89ec60 100644 (file)
--- 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
 
index 349ec9cceefd73c7f448bc4688b8b4d47fc8a9d5..2944eb5edaad9813b957189dcbbecd24c3c079fd 100644 (file)
@@ -47,34 +47,22 @@ pub fn parse_body (string: String, metadata: Metadata, reference_list: Option<Re
                                        document.push(Box::new(Heading{text: line[1..].to_string(), level: 1}))
                                },
 
-                               // match all unordered list patterns
-                               ('-', ..) => {
+                               // match all list patterns
+                               ('-', ..) | ('.', ..) => {
+                                       let matching = &line[..1];
                                        let mut items: Vec<Item> = 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<Item> = 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