diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-09-07 15:53:06 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-09-07 15:53:06 +0200 |
commit | 1d92666865b35341e076efbefddf6e73b5e1542e (patch) | |
tree | 11c05985ec7679f73473e7ea2c769465698e2f08 /src/subtokenize.rs | |
parent | e6018e52ee6ad9a8f8a0672b75bf515faf74af1f (diff) | |
download | markdown-rs-1d92666865b35341e076efbefddf6e73b5e1542e.tar.gz markdown-rs-1d92666865b35341e076efbefddf6e73b5e1542e.tar.bz2 markdown-rs-1d92666865b35341e076efbefddf6e73b5e1542e.zip |
Add support for recoverable syntax errors
Diffstat (limited to '')
-rw-r--r-- | src/subtokenize.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/subtokenize.rs b/src/subtokenize.rs index 7fcc481..12f91cf 100644 --- a/src/subtokenize.rs +++ b/src/subtokenize.rs @@ -22,7 +22,7 @@ use crate::parser::ParseState; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; use crate::util::{edit_map::EditMap, skip}; -use alloc::{vec, vec::Vec}; +use alloc::{string::String, vec, vec::Vec}; /// Link two [`Event`][]s. /// @@ -69,7 +69,7 @@ pub fn link_to(events: &mut [Event], previous: usize, next: usize) { /// Parse linked events. /// /// Supposed to be called repeatedly, returns `true` when done. -pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { +pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> Result<bool, String> { let mut map = EditMap::new(); let mut done = true; let mut index = 0; @@ -143,7 +143,7 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { link_index = link_curr.next; } - tokenizer.flush(state, true); + tokenizer.flush(state, true)?; divide_events(&mut map, events, index, &mut tokenizer.events); @@ -156,7 +156,7 @@ pub fn subtokenize(events: &mut Vec<Event>, parse_state: &ParseState) -> bool { map.consume(events); - done + Ok(done) } /// Divide `child_events` over links in `events`, the first of which is at |