From 7bf7e86db9db89da11f80d2199bcd5ca7988efba Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 29 Oct 2022 12:25:32 +0200 Subject: Refactor to always resolve edit maps This will probably catch some confusing bugs, such as ad1b3e6. --- src/construct/gfm_table.rs | 1 + src/construct/heading_atx.rs | 1 + src/construct/heading_setext.rs | 3 --- src/construct/label_end.rs | 1 - src/construct/list_item.rs | 1 + src/construct/partial_data.rs | 3 +-- src/construct/partial_whitespace.rs | 4 ++-- src/construct/text.rs | 1 + 8 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/construct/gfm_table.rs b/src/construct/gfm_table.rs index 3f88073..9edf5fd 100644 --- a/src/construct/gfm_table.rs +++ b/src/construct/gfm_table.rs @@ -883,6 +883,7 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { flush_table_end(tokenizer, last_table_end, last_table_has_body); } + tokenizer.map.consume(&mut tokenizer.events); None } diff --git a/src/construct/heading_atx.rs b/src/construct/heading_atx.rs index ca100c8..05b7c86 100644 --- a/src/construct/heading_atx.rs +++ b/src/construct/heading_atx.rs @@ -280,5 +280,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { index += 1; } + tokenizer.map.consume(&mut tokenizer.events); None } diff --git a/src/construct/heading_setext.rs b/src/construct/heading_setext.rs index 73b89c6..6e0ec08 100644 --- a/src/construct/heading_setext.rs +++ b/src/construct/heading_setext.rs @@ -185,8 +185,6 @@ pub fn after(tokenizer: &mut Tokenizer) -> State { /// Resolve heading (setext). pub fn resolve(tokenizer: &mut Tokenizer) -> Option { - tokenizer.map.consume(&mut tokenizer.events); - let mut enter = skip::to(&tokenizer.events, 0, &[Name::HeadingSetextUnderline]); while enter < tokenizer.events.len() { @@ -280,6 +278,5 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { } tokenizer.map.consume(&mut tokenizer.events); - None } diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs index d48f0c5..f47920c 100644 --- a/src/construct/label_end.rs +++ b/src/construct/label_end.rs @@ -669,7 +669,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { mark_as_data(tokenizer, &starts); tokenizer.map.consume(&mut tokenizer.events); - None } diff --git a/src/construct/list_item.rs b/src/construct/list_item.rs index ff22d3b..341abd9 100644 --- a/src/construct/list_item.rs +++ b/src/construct/list_item.rs @@ -469,5 +469,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { index += 1; } + tokenizer.map.consume(&mut tokenizer.events); None } diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs index fcd142d..600fea6 100644 --- a/src/construct/partial_data.rs +++ b/src/construct/partial_data.rs @@ -74,8 +74,6 @@ pub fn inside(tokenizer: &mut Tokenizer) -> State { /// Merge adjacent data events. pub fn resolve(tokenizer: &mut Tokenizer) -> Option { - tokenizer.map.consume(&mut tokenizer.events); - let mut index = 0; // Loop through events and merge adjacent data events. @@ -107,5 +105,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { index += 1; } + tokenizer.map.consume(&mut tokenizer.events); None } diff --git a/src/construct/partial_whitespace.rs b/src/construct/partial_whitespace.rs index 8e58838..276c24e 100644 --- a/src/construct/partial_whitespace.rs +++ b/src/construct/partial_whitespace.rs @@ -67,8 +67,6 @@ use alloc::vec; /// Resolve whitespace. pub fn resolve_whitespace(tokenizer: &mut Tokenizer, hard_break: bool, trim_whole: bool) { - tokenizer.map.consume(&mut tokenizer.events); - let mut index = 0; while index < tokenizer.events.len() { @@ -86,6 +84,8 @@ pub fn resolve_whitespace(tokenizer: &mut Tokenizer, hard_break: bool, trim_whol index += 1; } + + tokenizer.map.consume(&mut tokenizer.events); } /// Trim a [`Data`][Name::Data] event. diff --git a/src/construct/text.rs b/src/construct/text.rs index 0ea0913..fcb898c 100644 --- a/src/construct/text.rs +++ b/src/construct/text.rs @@ -259,5 +259,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) -> Option { resolve_gfm_autolink_literal(tokenizer); } + tokenizer.map.consume(&mut tokenizer.events); None } -- cgit