From 4b4689ca0d086e11de52cbbf848fa0873acd7274 Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 27 Dec 2023 17:18:12 -0600 Subject: rountrips! --- src/lib.rs | 188 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 145 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 26ec5dd..f1010ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,12 +43,14 @@ impl Html { Tag { name: root_tag.name.to_owned(), body: None, + self_closing: root_tag.self_closing, children: vec![], } } else { Tag { name: root_tag.name.into(), body: Some(root_tag.body.to_owned()), + self_closing: root_tag.self_closing, children: vec![], } }; @@ -65,11 +67,14 @@ impl Html { }; } + println!("Looking for {}", root_tag.name); + loop { // Special case + + +

Hello, World!

+ +"#, + ) + } } #[cfg(test)] @@ -540,6 +649,7 @@ mod tag_test { let tag = Tag { name: "div".into(), body: Some("contenteditable".into()), + self_closing: false, children: vec![], }; assert!(tag.get_attribute("contenteditable").is_some()) @@ -550,26 +660,18 @@ mod tag_test { let tag = Tag { name: "script".into(), body: Some("src=\"script.js\"".into()), + self_closing: false, children: vec![], }; assert_eq!(tag.get_attribute("src"), Some("script.js")) } - #[test] - fn tag_finds_attribute_with_self_close() { - let tag = Tag { - name: "link".into(), - body: Some("href=\"style.css\" /".into()), - children: vec![], - }; - assert_eq!(tag.get_attribute("href"), Some("style.css")) - } - #[test] fn tag_finds_boolean_in_centre() { let tag = Tag { name: "div".into(), - body: Some("id=\"divy\" contenteditable style=\"display: none;\" /".into()), + body: Some("id=\"divy\" contenteditable style=\"display: none;\"".into()), + self_closing: false, children: vec![], }; assert!(tag.get_attribute("contenteditable").is_some()); -- cgit 1.4.1-3-g733a5