aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/emitter.rs8
-rw-r--r--src/tokenizer.rs8
3 files changed, 10 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 474460f..28431e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,7 +23,7 @@
* `emit_error` now takes a span instead of an offset.
* Several provided offsets have been changed to be more sensible.
- Affected are: `set_self_closing`
+ Affected are: `set_self_closing`, `init_start_tag`, `init_end_tag`, `emit_current_tag`
* token types
diff --git a/src/emitter.rs b/src/emitter.rs
index 9334121..ff6e863 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -275,7 +275,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
fn init_start_tag(&mut self, offset: O) {
self.current_token = Some(Token::StartTag(StartTag {
- span: offset - b"<".len()..offset - b"<".len(),
+ span: offset..O::default(),
self_closing: false,
name: String::new(),
attributes: Default::default(),
@@ -283,7 +283,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
}
fn init_end_tag(&mut self, offset: O) {
self.current_token = Some(Token::EndTag(EndTag {
- span: offset - b"</".len()..offset - b"</".len(),
+ span: offset..O::default(),
name: String::new(),
}));
self.seen_attributes.clear();
@@ -305,10 +305,10 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
self.push_error(Error::EndTagWithAttributes, span);
}
self.seen_attributes.clear();
- tag.span.end = offset + b">".len();
+ tag.span.end = offset;
}
Token::StartTag(tag) => {
- tag.span.end = offset + b">".len();
+ tag.span.end = offset;
}
_ => debug_assert!(false),
}
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index cecc0f6..89d743a 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -218,14 +218,16 @@ 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() - 1);
+ self.emitter
+ .init_start_tag(self.reader.position() - "<".len() - 1);
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() - 1);
+ self.emitter
+ .init_end_tag(self.reader.position() - "</".len() - 1);
self.current_tag_name.clear();
self.is_start_tag = false;
}
@@ -238,7 +240,7 @@ impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> {
#[inline]
pub(crate) fn emit_current_tag(&mut self) {
- self.emitter.emit_current_tag(self.reader.position() - 1);
+ self.emitter.emit_current_tag(self.reader.position());
if self.is_start_tag {
if self.naively_switch_state {
self.state = naive_next_state(&self.current_tag_name).into();