summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-01 15:29:58 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commiteea8c60fba5962d5575c8515b837fb6304f73c9d (patch)
tree09722aca9a6e494c1f63dc7cc0266886a185ebdf /src
parent03ca8c1f599828eb12e60e6012684bb4c09dbf89 (diff)
refactor: also use some_offset for start/end tags
Diffstat (limited to 'src')
-rw-r--r--src/machine.rs2
-rw-r--r--src/tokenizer.rs8
2 files changed, 4 insertions, 6 deletions
diff --git a/src/machine.rs b/src/machine.rs
index 84fb525..b23e5f2 100644
--- a/src/machine.rs
+++ b/src/machine.rs
@@ -46,6 +46,7 @@ where
Ok(ControlToken::Continue)
}
Some('<') => {
+ slf.some_offset = slf.reader.position() - 1;
slf.state = State::TagOpen;
Ok(ControlToken::Continue)
}
@@ -947,7 +948,6 @@ where
}
Some('d' | 'D') if slf.try_read_string("octype", false)? => {
slf.state = State::Doctype;
- slf.some_offset = slf.reader.position() - b"<!doctype".len();
Ok(ControlToken::Continue)
}
Some('[') if slf.try_read_string("CDATA[", true)? => Ok(ControlToken::CdataOpen),
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 89d743a..83c3965 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -49,7 +49,7 @@ pub struct Tokenizer<R: Reader, O, E: Emitter<O>> {
current_tag_name: String,
last_start_tag_name: String,
is_start_tag: bool,
- /// * Set to the start offset of `<!doctype` in [`InternalState::MarkupDeclarationOpen`].
+ /// * Set to the offset of `<` in [`InternalState::Data`].
/// * Set to the offset of `&` in [`InternalState::CharacterReference`].
pub(crate) some_offset: O,
/// This boolean flag exists so that the [`NaiveParser`](crate::NaiveParser) can work with any [`Emitter`]
@@ -218,16 +218,14 @@ impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> {
#[inline]
pub(crate) fn init_start_tag(&mut self) {
- self.emitter
- .init_start_tag(self.reader.position() - "<".len() - 1);
+ self.emitter.init_start_tag(self.some_offset);
self.current_tag_name.clear();
self.is_start_tag = true;
}
#[inline]
pub(crate) fn init_end_tag(&mut self) {
- self.emitter
- .init_end_tag(self.reader.position() - "</".len() - 1);
+ self.emitter.init_end_tag(self.some_offset);
self.current_tag_name.clear();
self.is_start_tag = false;
}