aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-29 12:25:32 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-29 12:25:32 +0200
commit7bf7e86db9db89da11f80d2199bcd5ca7988efba (patch)
tree24e13a4ed3bb7178907676cbbf2dbd2756c4f047
parent5d5e94567e7a87a3cefdda410e3bd9e36e26eca5 (diff)
downloadmarkdown-rs-7bf7e86db9db89da11f80d2199bcd5ca7988efba.tar.gz
markdown-rs-7bf7e86db9db89da11f80d2199bcd5ca7988efba.tar.bz2
markdown-rs-7bf7e86db9db89da11f80d2199bcd5ca7988efba.zip
Refactor to always resolve edit maps
This will probably catch some confusing bugs, such as ad1b3e6.
-rw-r--r--src/construct/gfm_table.rs1
-rw-r--r--src/construct/heading_atx.rs1
-rw-r--r--src/construct/heading_setext.rs3
-rw-r--r--src/construct/label_end.rs1
-rw-r--r--src/construct/list_item.rs1
-rw-r--r--src/construct/partial_data.rs3
-rw-r--r--src/construct/partial_whitespace.rs4
-rw-r--r--src/construct/text.rs1
8 files changed, 7 insertions, 8 deletions
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<Subresult> {
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<Subresult> {
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<Subresult> {
- 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<Subresult> {
}
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<Subresult> {
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<Subresult> {
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<Subresult> {
- 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<Subresult> {
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<Subresult> {
resolve_gfm_autolink_literal(tokenizer);
}
+ tokenizer.map.consume(&mut tokenizer.events);
None
}