aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 18:14:23 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-13 18:14:23 +0200
commit2f21280db96e9c8086e123f756f5cad27cbfa0bf (patch)
tree6d3a9f55a0d441984393d612b4bd5f43ffcfbc76 /src/parser.rs
parent5c7605629d70cc613cb3bee6ac419e7ee4d9cf7f (diff)
downloadmarkdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.tar.gz
markdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.tar.bz2
markdown-rs-2f21280db96e9c8086e123f756f5cad27cbfa0bf.zip
Refactor some code to improve coverage
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/parser.rs b/src/parser.rs
index a7962d0..4e8d859 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -47,15 +47,13 @@ pub fn parse<'a>(
gfm_footnote_definitions: vec![],
};
- let mut tokenizer = Tokenizer::new(
- Point {
- line: 1,
- column: 1,
- index: 0,
- vs: 0,
- },
- &parse_state,
- );
+ let start = Point {
+ line: 1,
+ column: 1,
+ index: 0,
+ vs: 0,
+ };
+ let mut tokenizer = Tokenizer::new(start, &parse_state);
let state = tokenizer.push(
(0, 0),
@@ -65,21 +63,17 @@ pub fn parse<'a>(
let mut result = tokenizer.flush(state, true)?;
let mut events = tokenizer.events;
- parse_state
- .gfm_footnote_definitions
- .append(&mut result.gfm_footnote_definitions);
- parse_state.definitions.append(&mut result.definitions);
-
loop {
- let mut result = subtokenize(&mut events, &parse_state, &None)?;
- parse_state
- .gfm_footnote_definitions
- .append(&mut result.gfm_footnote_definitions);
- parse_state.definitions.append(&mut result.definitions);
+ let fn_defs = &mut parse_state.gfm_footnote_definitions;
+ let defs = &mut parse_state.definitions;
+ fn_defs.append(&mut result.gfm_footnote_definitions);
+ defs.append(&mut result.definitions);
if result.done {
break;
}
+
+ result = subtokenize(&mut events, &parse_state, &None)?;
}
Ok((events, parse_state))