diff options
Diffstat (limited to '')
-rw-r--r-- | src/parser.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/parser.rs b/src/parser.rs index 3a7713a..c69eb38 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -49,16 +49,25 @@ pub fn parse<'a>(value: &'a str, options: &'a Options) -> Result<(Vec<Event>, &' (parse_state.bytes.len(), 0), State::Next(StateName::DocumentStart), ); - tokenizer.flush(state, true)?; - + let mut result = tokenizer.flush(state, true)?; let mut events = tokenizer.events; - let footnote = tokenizer.tokenize_state.gfm_footnote_definitions; - let normal = tokenizer.tokenize_state.definitions; - parse_state.gfm_footnote_definitions = footnote; - parse_state.definitions = normal; + 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); - while !(subtokenize(&mut events, &parse_state)?) {} + if result.done { + break; + } + } Ok((events, parse_state.bytes)) } |