diff options
author | Martin Fischer <martin@push-f.com> | 2023-09-01 15:54:34 +0200 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2023-09-03 23:00:05 +0200 |
commit | 592a3bb1fc8dacb159a6fd5168df6f69015a5184 (patch) | |
tree | d319a79f47433fe01c5e440033490065630d0d0b | |
parent | ac338b77b658f0a3a645c96110320f8a9ae7f0ee (diff) |
refactor: proxy init_doctype through Tokenizer
-rw-r--r-- | src/machine.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/machine.rs b/src/machine.rs index 082ab68..5910667 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -1159,7 +1159,7 @@ where } None => { slf.emit_error(Error::EofInDoctype); - slf.emitter.init_doctype(slf.doctype_offset); + slf.init_doctype(); slf.emitter.set_force_quirks(); slf.emitter.emit_current_doctype(slf.reader.position()); Ok(ControlToken::Eof) @@ -1175,14 +1175,14 @@ where Some(whitespace_pat!()) => Ok(ControlToken::Continue), Some('\0') => { slf.emit_error(Error::UnexpectedNullCharacter); - slf.emitter.init_doctype(slf.doctype_offset); + slf.init_doctype(); slf.emitter.push_doctype_name("\u{fffd}"); slf.state = State::DoctypeName; Ok(ControlToken::Continue) } Some('>') => { slf.emit_error(Error::MissingDoctypeName); - slf.emitter.init_doctype(slf.doctype_offset); + slf.init_doctype(); slf.emitter.set_force_quirks(); slf.state = State::Data; slf.emitter.emit_current_doctype(slf.reader.position()); @@ -1190,13 +1190,13 @@ where } None => { slf.emit_error(Error::EofInDoctype); - slf.emitter.init_doctype(slf.doctype_offset); + slf.init_doctype(); slf.emitter.set_force_quirks(); slf.emitter.emit_current_doctype(slf.reader.position()); Ok(ControlToken::Eof) } Some(x) => { - slf.emitter.init_doctype(slf.doctype_offset); + slf.init_doctype(); slf.emitter .push_doctype_name(ctostr!(x.to_ascii_lowercase())); slf.state = State::DoctypeName; @@ -1892,6 +1892,13 @@ where } } +impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> { + #[inline] + fn init_doctype(&mut self) { + self.emitter.init_doctype(self.doctype_offset); + } +} + #[inline] pub fn handle_cdata_open<O, R, E>(slf: &mut Tokenizer<R, O, E>, action: CdataAction) where |