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? --- readme.md | 6 ++-- src/lib.rs | 102 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 85 insertions(+), 23 deletions(-) diff --git a/readme.md b/readme.md index 89585a8..725a71a 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,6 @@ opinionated, standards non-compliant HTML parser meant to consume handwritten HTML. -- all tags must close -- no > in tags except at the end (not even in attributes) \ No newline at end of file +- all tags must close *(even `
`, ``, ``)* +- no > in tags except at the end (not even in attributes) +- inline `"; + 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