From 4892172b629590ac4362f7506c14e993fd1ddd2b Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 30 Nov 2021 15:34:57 +0100 Subject: prepare for introduction of public State enum --- src/lib.rs | 2 +- src/tokenizer.rs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index f3e0431..2125776 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ mod tokenizer; mod utils; #[cfg(feature = "integration-tests")] -pub use utils::State; +pub use utils::State as InternalState; pub use emitter::{DefaultEmitter, Doctype, Emitter, EndTag, StartTag, Token}; pub use error::Error; diff --git a/src/tokenizer.rs b/src/tokenizer.rs index ec3ae44..b09e030 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -1,5 +1,7 @@ use crate::machine; -use crate::utils::{control_pat, noncharacter_pat, surrogate_pat, ControlToken, State}; +use crate::utils::{ + control_pat, noncharacter_pat, surrogate_pat, ControlToken, State as InternalState, +}; use crate::{DefaultEmitter, Emitter, Error, Never, Readable, Reader}; // this is a stack that can hold 0 to 2 Ts @@ -31,13 +33,13 @@ impl Stack2 { /// A HTML tokenizer. See crate-level docs for basic usage. pub struct Tokenizer { eof: bool, - pub(crate) state: State, + pub(crate) state: InternalState, pub(crate) emitter: E, pub(crate) temporary_buffer: String, reader: R, to_reconsume: Stack2>, pub(crate) character_reference_code: u32, - pub(crate) return_state: Option, + pub(crate) return_state: Option, } impl Tokenizer { @@ -61,7 +63,7 @@ impl Tokenizer { pub fn new_with_emitter<'a, S: Readable<'a, Reader = R>>(input: S, emitter: E) -> Self { Tokenizer { eof: false, - state: State::Data, + state: InternalState::Data, emitter, temporary_buffer: String::new(), to_reconsume: Stack2::default(), @@ -75,7 +77,7 @@ impl Tokenizer { /// /// Only available with the `integration-tests` feature which is not public API. #[cfg(feature = "integration-tests")] - pub fn set_state(&mut self, state: State) { + pub fn set_internal_state(&mut self, state: InternalState) { self.state = state; } @@ -84,7 +86,7 @@ impl Tokenizer { /// /// This tokenizer never gets into that state naturally. pub fn set_plaintext_state(&mut self) { - self.state = State::PlainText; + self.state = InternalState::PlainText; } /// Test-internal function to override internal state. @@ -176,9 +178,9 @@ impl Tokenizer { matches!( self.return_state, Some( - State::AttributeValueDoubleQuoted - | State::AttributeValueSingleQuoted - | State::AttributeValueUnquoted + InternalState::AttributeValueDoubleQuoted + | InternalState::AttributeValueSingleQuoted + | InternalState::AttributeValueUnquoted ) ) } -- cgit v1.2.3