aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer/machine.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tokenizer/machine.rs')
-rw-r--r--src/tokenizer/machine.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/tokenizer/machine.rs b/src/tokenizer/machine.rs
index 28b101d..b6291b5 100644
--- a/src/tokenizer/machine.rs
+++ b/src/tokenizer/machine.rs
@@ -1799,17 +1799,13 @@ where
}
}
State::NamedCharacterReference => {
- let first_char = slf.read_char()?;
+ let first_char = slf.read_char()?.unwrap(); // unwrap cannot panic since we just unread the char
- let char_ref = match first_char {
- Some(x) => try_read_character_reference(x, |x| slf.try_read_string(x, true))?
- .map(|char_ref| (x, char_ref)),
+ let char_ref =
+ try_read_character_reference(first_char, |x| slf.try_read_string(x, true))?;
- None => None,
- };
-
- if let Some((x, char_ref)) = char_ref {
- slf.temporary_buffer.push(x);
+ if let Some(char_ref) = char_ref {
+ slf.temporary_buffer.push(first_char);
slf.temporary_buffer.push_str(char_ref.name);
let char_ref_name_last_character = char_ref.name.chars().last();
@@ -1835,7 +1831,7 @@ where
Ok(ControlToken::Continue)
}
} else {
- slf.unread_char(first_char);
+ slf.unread_char(Some(first_char));
slf.flush_code_points_consumed_as_character_reference();
slf.state = State::AmbiguousAmpersand;
Ok(ControlToken::Continue)