From 848b70d0cf67ccbc4634b4f28ada285d6691eecd Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 27 Dec 2023 15:13:52 -0600 Subject: actually special-case script/style? I thought this was the last commit, honestly? --- src/lib.rs | 102 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 81 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 31e8a17..36a9075 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,16 +60,36 @@ impl Html { let mut children = vec![]; loop { - match Self::is_tag(rest.unwrap()) { - Some(( - ParsedTag { - closing: true, - name, - self_closing: false, - .. - }, - remaining, - )) if name == root_tag.name => { + // Special case "; + let special = Html::special_parse(basic, "script"); + assert_eq!(special.unwrap().0, "words words\n"); + assert!(special.unwrap().1.is_empty()); + } + + #[test] + fn special_parse_correctly_ignore_non_start() { + let nonstart = "first_line\nlet end = '';\n"; + let special = Html::special_parse(nonstart, "script"); + assert!(special.is_none()); + } + + #[test] + fn special_parse_correctly_handles_leading_whitespace() { + let white = "words words\n \t\t"; + let special = Html::special_parse(white, "script"); + assert_eq!(special.unwrap().0, "words words\n \t\t"); + } + #[test] fn parse_node_parses_comment() { let cmt = ""; -- cgit 1.4.1-3-g733a5