aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/heading_atx.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/heading_atx.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/heading_atx.rs')
-rw-r--r--src/construct/heading_atx.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/construct/heading_atx.rs b/src/construct/heading_atx.rs
index feb1e9d..bf3de23 100644
--- a/src/construct/heading_atx.rs
+++ b/src/construct/heading_atx.rs
@@ -193,8 +193,7 @@ fn data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
}
/// Resolve heading (atx).
-pub fn resolve(tokenizer: &mut Tokenizer) {
- let mut edit_map = EditMap::new();
+pub fn resolve(tokenizer: &mut Tokenizer, map: &mut EditMap) -> bool {
let mut index = 0;
let mut heading_start: Option<usize> = None;
let mut data_start: Option<usize> = None;
@@ -210,7 +209,7 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
// If `start` is some, `end` is too.
let end = data_end.unwrap();
- edit_map.add(
+ map.add(
start,
0,
vec![Event {
@@ -225,9 +224,9 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
);
// Remove everything between the start and the end.
- edit_map.add(start + 1, end - start - 1, vec![]);
+ map.add(start + 1, end - start - 1, vec![]);
- edit_map.add(
+ map.add(
end + 1,
0,
vec![Event {
@@ -258,5 +257,6 @@ pub fn resolve(tokenizer: &mut Tokenizer) {
index += 1;
}
- edit_map.consume(&mut tokenizer.events);
+ // This resolver improves events, but is not needed by other resolvers.
+ false
}