diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-30 15:34:57 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-12-05 02:39:51 +0100 |
commit | 4892172b629590ac4362f7506c14e993fd1ddd2b (patch) | |
tree | d121890b5e2fbd13289dca5c83ccda5a41d77fbf /src | |
parent | 710de8ae37c1199ce65430ceed00cbc1ed61d81a (diff) |
prepare for introduction of public State enum
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/tokenizer.rs | 20 |
2 files changed, 12 insertions, 10 deletions
@@ -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<T: Copy> Stack2<T> { /// A HTML tokenizer. See crate-level docs for basic usage. pub struct Tokenizer<R: Reader, E: Emitter = DefaultEmitter> { eof: bool, - pub(crate) state: State, + pub(crate) state: InternalState, pub(crate) emitter: E, pub(crate) temporary_buffer: String, reader: R, to_reconsume: Stack2<Option<char>>, pub(crate) character_reference_code: u32, - pub(crate) return_state: Option<State>, + pub(crate) return_state: Option<InternalState>, } impl<R: Reader> Tokenizer<R> { @@ -61,7 +63,7 @@ impl<R: Reader, E: Emitter> Tokenizer<R, E> { 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<R: Reader, E: Emitter> Tokenizer<R, E> { /// /// 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<R: Reader, E: Emitter> Tokenizer<R, E> { /// /// 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<R: Reader, E: Emitter> Tokenizer<R, E> { matches!( self.return_state, Some( - State::AttributeValueDoubleQuoted - | State::AttributeValueSingleQuoted - | State::AttributeValueUnquoted + InternalState::AttributeValueDoubleQuoted + | InternalState::AttributeValueSingleQuoted + | InternalState::AttributeValueUnquoted ) ) } |