aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-30 17:47:47 +0100
committerMartin Fischer <martin@push-f.com>2021-12-05 02:52:36 +0100
commitcb8c8b260dc95317b16efddd921e7de2cae57245 (patch)
tree960db1a71971e2f3b937712fe72e134f53ae0db1
parentbb24c73a06683c116eba3ad17aebdc87a5302529 (diff)
spans: start implementing SpanEmitter
-rw-r--r--src/spans.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/spans.rs b/src/spans.rs
index 1fc17c1..9d02940 100644
--- a/src/spans.rs
+++ b/src/spans.rs
@@ -143,8 +143,11 @@ impl<R: GetPos> Emitter<R> for SpanEmitter<R> {
self.current_characters.push_str(s);
}
- fn init_start_tag(&mut self, _reader: &R) {
- self.current_token = Some(Token::StartTag(Default::default()));
+ fn init_start_tag(&mut self, reader: &R) {
+ self.current_token = Some(Token::StartTag(StartTag {
+ name_span: reader.get_pos()..reader.get_pos(),
+ ..Default::default()
+ }));
}
fn init_end_tag(&mut self, _reader: &R) {
self.current_token = Some(Token::EndTag(Default::default()));
@@ -208,11 +211,21 @@ impl<R: GetPos> Emitter<R> for SpanEmitter<R> {
}
fn push_tag_name(&mut self, s: &str) {
match self.current_token {
- Some(Token::StartTag(StartTag { ref mut name, .. })) => {
+ Some(Token::StartTag(StartTag {
+ ref mut name,
+ ref mut name_span,
+ ..
+ })) => {
name.push_str(s);
+ name_span.end += s.len();
}
- Some(Token::EndTag(EndTag { ref mut name, .. })) => {
+ Some(Token::EndTag(EndTag {
+ ref mut name,
+ ref mut name_span,
+ ..
+ })) => {
name.push_str(s);
+ name_span.end += s.len();
}
_ => debug_assert!(false),
}