Function try_parse_document

pub fn try_parse_document<'a>(arena: &'a Arena<'a>, md: &str, options: &Options<'_>, should_cancel: &dyn Fn() -> bool) -> Result<Node<'a>, ParseCancelled>

Like parse_document, but returns ParseCancelled once should_cancel returns true. It's called every 256 steps, where a step is a line, an inline or a node.

# use std::time::{Duration, Instant};
# use comrak::{Arena, Options, try_parse_document};
let arena = Arena::new();
let deadline = Instant::now() + Duration::from_secs(1);
let past_deadline = || Instant::now() >= deadline;
let root = try_parse_document(&arena, "Hello, *world*!", &Options::default(), &past_deadline);
assert!(root.is_ok());