From 9892c726fb212a1af36737d5741ff8421ff20829 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 13 Aug 2023 19:35:43 +0200 Subject: break!: remove set_last_start_tag from Emitter --- integration_tests/tests/test_html5lib.rs | 4 +++- src/emitter.rs | 16 +++++----------- src/tokenizer.rs | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/integration_tests/tests/test_html5lib.rs b/integration_tests/tests/test_html5lib.rs index cf95bb6..8afa033 100644 --- a/integration_tests/tests/test_html5lib.rs +++ b/integration_tests/tests/test_html5lib.rs @@ -315,7 +315,9 @@ fn run_test_inner( ); println!("description: {}", test.description); tokenizer.set_internal_state(state); - tokenizer.set_last_start_tag(test.last_start_tag.as_ref().map(String::as_str)); + if let Some(last_start_tag) = &test.last_start_tag { + tokenizer.set_last_start_tag(last_start_tag); + } let mut actual_tokens = Vec::new(); let mut actual_errors = Vec::new(); diff --git a/src/emitter.rs b/src/emitter.rs index e872b1f..fba1f6a 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -36,12 +36,6 @@ pub trait Emitter { /// yields when used as an iterator. type Token; - /// Set the name of the _last start tag_. - /// - /// This is primarily for testing purposes. This is *not* supposed to override the tag name of - /// the current tag. - fn set_last_start_tag(&mut self, last_start_tag: Option<&str>); - /// The state machine has reached the end of the file. It will soon call `pop_token` for the /// last time. fn emit_eof(&mut self); @@ -252,16 +246,16 @@ impl> DefaultEmitter { // that exact self.emitted_tokens.push_front(Token::Error { error, span }); } -} - -impl> Emitter for DefaultEmitter { - type Token = Token; - fn set_last_start_tag(&mut self, last_start_tag: Option<&str>) { + pub(crate) fn set_last_start_tag(&mut self, last_start_tag: Option<&str>) { self.last_start_tag.clear(); self.last_start_tag .push_str(last_start_tag.unwrap_or_default()); } +} + +impl> Emitter for DefaultEmitter { + type Token = Token; fn emit_eof(&mut self) { self.flush_current_characters(); diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 6e928e9..44793a5 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -128,14 +128,6 @@ impl> Tokenizer { self.emitter.emit_error(error, &self.reader); } - /// Test-internal function to override internal state. - /// - /// Only available with the `integration-tests` feature which is not public API. - #[cfg(feature = "integration-tests")] - pub fn set_last_start_tag(&mut self, last_start_tag: Option<&str>) { - self.emitter.set_last_start_tag(last_start_tag); - } - #[inline] pub(crate) fn unread_char(&mut self, c: Option) { self.to_reconsume.push(c); @@ -306,3 +298,13 @@ impl, E: Emitter> DerefMut for InfallibleTokenizer, R: Reader> Tokenizer> { + /// Test-internal function to override internal state. + /// + /// Only available with the `integration-tests` feature which is not public API. + #[cfg(feature = "integration-tests")] + pub fn set_last_start_tag(&mut self, last_start_tag: &str) { + self.emitter.set_last_start_tag(Some(last_start_tag)); + } +} -- cgit v1.2.3