From 2011d2ea4d6ec9d1bd7409c22e4258aceaaa3afe Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 12 Sep 2022 13:50:48 +0200 Subject: Fix whitespace in GFM footnote definition identifiers * Fix a crash on line endings in footnote definitions * Fix to match spaces and tabs in identifiers to `cmark-gfm` * Fix order of one attribute --- src/construct/document.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/construct/document.rs') diff --git a/src/construct/document.rs b/src/construct/document.rs index 57c5f3a..45a961d 100644 --- a/src/construct/document.rs +++ b/src/construct/document.rs @@ -567,11 +567,20 @@ fn resolve(tokenizer: &mut Tokenizer) { child.map.consume(&mut child.events); + let mut flow_index = skip::to(&tokenizer.events, 0, &[Name::Data]); + while flow_index < tokenizer.events.len() + // To do: use `!is_some_and()` when that’s stable. + && (tokenizer.events[flow_index].link.is_none() + || tokenizer.events[flow_index].link.as_ref().unwrap().content != Content::Flow) + { + flow_index = skip::to(&tokenizer.events, flow_index + 1, &[Name::Data]); + } + // Now, add all child events into our parent document tokenizer. divide_events( &mut tokenizer.map, &tokenizer.events, - skip::to(&tokenizer.events, 0, &[Name::Data]), + flow_index, &mut child.events, ); -- cgit