Skip to content

Commit

Permalink
Fixes an error failing to parse if there is a newline after the attri…
Browse files Browse the repository at this point in the history
…bute.
  • Loading branch information
piyoppi committed Nov 19, 2024
1 parent 95d6025 commit 4b72543
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/element_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn parse<'a>(token: &'a tokenizer::Token) -> Option<Element<'a>> {
}
},
State::Name(start) => match current_char {
' ' => {
' ' | '\n' => {
pairs.push((&target[start..pos], None));
state = State::NameEnd;
}
Expand Down Expand Up @@ -263,5 +263,17 @@ mod tests {
],
})
);

let tokens = tokenizer::tokenize("<foo bar\n>", "<", ">");
assert_eq!(
parse(&tokens[0]),
Some(Element {
name: "foo",
attrs: vec![Attribute {
name: "bar",
value: None
}],
})
);
}
}

0 comments on commit 4b72543

Please sign in to comment.