diff --git a/src/element_parser.rs b/src/element_parser.rs index 413ccb0..893bb5b 100644 --- a/src/element_parser.rs +++ b/src/element_parser.rs @@ -47,7 +47,7 @@ pub fn parse<'a>(token: &'a tokenizer::Token) -> Option> { } }, State::Name(start) => match current_char { - ' ' => { + ' ' | '\n' => { pairs.push((&target[start..pos], None)); state = State::NameEnd; } @@ -263,5 +263,17 @@ mod tests { ], }) ); + + let tokens = tokenizer::tokenize("", "<", ">"); + assert_eq!( + parse(&tokens[0]), + Some(Element { + name: "foo", + attrs: vec![Attribute { + name: "bar", + value: None + }], + }) + ); } }