diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-08 17:40:15 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-08 17:40:15 +0200 |
commit | 59c4ec0fb54c9263ac3a127d2b1c4fd7f0d490d6 (patch) | |
tree | d2ed946e29300d2d563a128071053cdfaa15d4cf /src/content/document.rs | |
parent | ac3cfc8253e3d3761c65b3c9db5c990f5b07f161 (diff) | |
download | markdown-rs-59c4ec0fb54c9263ac3a127d2b1c4fd7f0d490d6.tar.gz markdown-rs-59c4ec0fb54c9263ac3a127d2b1c4fd7f0d490d6.tar.bz2 markdown-rs-59c4ec0fb54c9263ac3a127d2b1c4fd7f0d490d6.zip |
Fix container bug due to attempts
Diffstat (limited to 'src/content/document.rs')
-rw-r--r-- | src/content/document.rs | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/src/content/document.rs b/src/content/document.rs index ad7ffc0..8ce1dc3 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -241,8 +241,44 @@ fn there_is_a_new_container( println!("there_is_a_new_container"); let size = info.continued; info = exit_containers(tokenizer, info, size, true); + + // Remove from the event stack. + // We’ll properly add exits at different points manually. + // To do: list. + let end = if name == "blockquote" { + block_quote_end + } else { + unreachable!("todo: cont {:?}", name) + }; + + println!("creating exit for `{:?}`", name); + + let token_types = end(); + + let mut index = 0; + while index < token_types.len() { + let token_type = &token_types[index]; + let mut stack_index = tokenizer.stack.len(); + println!("stack: {:?}", tokenizer.stack); + let mut found = false; + + while stack_index > 0 { + stack_index -= 1; + + if tokenizer.stack[stack_index] == *token_type { + tokenizer.stack.remove(stack_index); + found = true; + break; + } + } + + assert!(found, "expected to find container token to exit"); + index += 1; + } + println!("add to stack: {:?}", name); info.stack.push(name); + info.continued += 1; document_continued(tokenizer, code, info) } @@ -294,20 +330,6 @@ fn exit_containers( content_type: None, }); - let mut stack_index = tokenizer.stack.len(); - let mut found = false; - - while stack_index > 0 { - stack_index -= 1; - - if tokenizer.stack[stack_index] == *token_type { - tokenizer.stack.remove(stack_index); - found = true; - break; - } - } - - assert!(found, "expected to find container token to exit"); index += 1; } } |