aboutsummaryrefslogtreecommitdiff
path: root/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/emitter.rs')
-rw-r--r--src/emitter.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index e441eb7..18b2539 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -5,6 +5,7 @@ use std::collections::VecDeque;
use std::marker::PhantomData;
use std::mem;
+use crate::spans::Position;
use crate::spans::Span;
use crate::Error;
@@ -183,7 +184,7 @@ impl<R, S> Default for DefaultEmitter<R, S> {
}
}
-impl<R, S: Span<R>> DefaultEmitter<R, S> {
+impl<R, S: Span> DefaultEmitter<R, S> {
fn emit_token(&mut self, token: Token<S>) {
self.flush_current_characters();
self.emitted_tokens.push_front(token);
@@ -229,7 +230,7 @@ impl<R, S: Span<R>> DefaultEmitter<R, S> {
}
}
-impl<R, S: Span<R>> Emitter<R> for DefaultEmitter<R, S> {
+impl<R: Position<S::Offset>, S: Span> Emitter<R> for DefaultEmitter<R, S> {
type Token = Token<S>;
fn emit_eof(&mut self) {
@@ -237,7 +238,7 @@ impl<R, S: Span<R>> Emitter<R> for DefaultEmitter<R, S> {
}
fn emit_error(&mut self, error: Error, reader: &R) {
- self.push_error(error, S::from_reader(reader));
+ self.push_error(error, S::new(reader.position(), reader.position()));
}
fn pop_token(&mut self) -> Option<Self::Token> {
@@ -250,7 +251,7 @@ impl<R, S: Span<R>> Emitter<R> for DefaultEmitter<R, S> {
fn init_start_tag(&mut self, reader: &R) {
self.current_token = Some(Token::StartTag(StartTag {
- name_span: S::from_reader(reader),
+ name_span: S::new(reader.position(), reader.position()),
self_closing: false,
name: String::new(),
attributes: Default::default(),
@@ -258,7 +259,7 @@ impl<R, S: Span<R>> Emitter<R> for DefaultEmitter<R, S> {
}
fn init_end_tag(&mut self, reader: &R) {
self.current_token = Some(Token::EndTag(EndTag {
- name_span: S::from_reader(reader),
+ name_span: S::new(reader.position(), reader.position()),
name: String::new(),
}));
self.seen_attributes.clear();
@@ -367,15 +368,17 @@ impl<R, S: Span<R>> Emitter<R> for DefaultEmitter<R, S> {
self.current_attribute = Some((
String::new(),
Attribute {
- name_span: S::from_reader(reader),
+ name_span: S::new(reader.position(), reader.position()),
value: String::new(),
value_span: S::default(),
},
));
}
fn init_attribute_value(&mut self, reader: &R, quoted: bool) {
- self.current_attribute.as_mut().unwrap().1.value_span =
- S::from_reader_with_offset(reader, quoted as usize);
+ self.current_attribute.as_mut().unwrap().1.value_span = S::new(
+ reader.position() + quoted as usize,
+ reader.position() + quoted as usize,
+ );
}
fn push_attribute_name(&mut self, s: &str) {