diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 18:00:52 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-20 18:00:52 +0200 |
commit | 75c2109c6051009b220436bd823970a374f4f9fd (patch) | |
tree | c8123e6e4a0a71e2daec77d76c0dc4485bad2240 /src/construct/paragraph.rs | |
parent | 86801cdb3b114b30a14d4b8c01c8fb70b2bcee82 (diff) | |
download | markdown-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.rs | 10 |
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 } |