aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/partial_data.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-15 11:05:22 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-15 11:05:22 +0200
commit3a4de4b3a89e7171f8e3e0b6bf02fcd2d5c5f748 (patch)
tree6aec470579ec3021b158ff7aa1e784ecacedb1ad /src/construct/partial_data.rs
parent30dccab8678bd134e084afdafbf3e14d047f0965 (diff)
downloadmarkdown-rs-3a4de4b3a89e7171f8e3e0b6bf02fcd2d5c5f748.tar.gz
markdown-rs-3a4de4b3a89e7171f8e3e0b6bf02fcd2d5c5f748.tar.bz2
markdown-rs-3a4de4b3a89e7171f8e3e0b6bf02fcd2d5c5f748.zip
Refactor paragraph, data resolvers
Diffstat (limited to 'src/construct/partial_data.rs')
-rw-r--r--src/construct/partial_data.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/construct/partial_data.rs b/src/construct/partial_data.rs
index 8c8ecbb..86e48c7 100644
--- a/src/construct/partial_data.rs
+++ b/src/construct/partial_data.rs
@@ -81,27 +81,24 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
let event = &tokenizer.events[index];
if event.kind == Kind::Enter && event.name == Name::Data {
- let exit_index = index + 1;
- let mut exit_far_index = exit_index;
+ // Move to exit.
+ index += 1;
- // Find multiple `data` events.
- while exit_far_index + 1 < tokenizer.events.len()
- && tokenizer.events[exit_far_index + 1].name == Name::Data
+ let mut exit_index = index;
+
+ // Find the farthest `data` event exit event.
+ while exit_index + 1 < tokenizer.events.len()
+ && tokenizer.events[exit_index + 1].name == Name::Data
{
- exit_far_index += 2;
+ exit_index += 2;
}
- if exit_far_index > exit_index {
- tokenizer
- .map
- .add(exit_index, exit_far_index - exit_index, vec![]);
-
+ if exit_index > index {
+ tokenizer.map.add(index, exit_index - index, vec![]);
// Change positional info.
- let exit_far = &tokenizer.events[exit_far_index];
- tokenizer.events[exit_index].point = exit_far.point.clone();
- index = exit_far_index;
-
- continue;
+ tokenizer.events[index].point = tokenizer.events[exit_index].point.clone();
+ // Move to the end.
+ index = exit_index;
}
}