aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/paragraph.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-20 18:00:52 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-20 18:00:52 +0200
commit75c2109c6051009b220436bd823970a374f4f9fd (patch)
treec8123e6e4a0a71e2daec77d76c0dc4485bad2240 /src/construct/paragraph.rs
parent86801cdb3b114b30a14d4b8c01c8fb70b2bcee82 (diff)
downloadmarkdown-rs-75c2109c6051009b220436bd823970a374f4f9fd.tar.gz
markdown-rs-75c2109c6051009b220436bd823970a374f4f9fd.tar.bz2
markdown-rs-75c2109c6051009b220436bd823970a374f4f9fd.zip
Refactor to share edit map
Diffstat (limited to 'src/construct/paragraph.rs')
-rw-r--r--src/construct/paragraph.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/construct/paragraph.rs b/src/construct/paragraph.rs
index 1b186e3..134a4b5 100644
--- a/src/construct/paragraph.rs
+++ b/src/construct/paragraph.rs
@@ -80,8 +80,7 @@ fn inside(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// Merge “`Paragraph`”s, which currently span a single line, into actual
/// `Paragraph`s that span multiple lines.
-pub fn resolve(tokenizer: &mut Tokenizer) {
- let mut edit_map = EditMap::new();
+pub fn resolve(tokenizer: &mut Tokenizer, map: &mut EditMap) -> bool {
let len = tokenizer.events.len();
let mut index = 0;
@@ -105,10 +104,10 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
&& tokenizer.events[enter_next_index].token_type == Token::Paragraph
{
// Remove Exit:Paragraph, Enter:LineEnding, Exit:LineEnding, Enter:Paragraph.
- edit_map.add(exit_index, 3, vec![]);
+ map.add(exit_index, 3, vec![]);
// Remove Enter:Paragraph.
- edit_map.add(enter_next_index, 1, vec![]);
+ map.add(enter_next_index, 1, vec![]);
// Add Exit:LineEnding position info to Exit:Data.
let line_ending_exit = &tokenizer.events[exit_index + 2];
@@ -142,5 +141,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
index += 1;
}
- edit_map.consume(&mut tokenizer.events);
+ // This resolver is needed by setext headings.
+ true
}