diff options
-rw-r--r-- | src/content/document.rs | 50 | ||||
-rw-r--r-- | tests/block_quote.rs | 2 | ||||
-rw-r--r-- | tests/code_indented.rs | 12 | ||||
-rw-r--r-- | tests/definition.rs | 11 |
4 files changed, 48 insertions, 27 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; } } diff --git a/tests/block_quote.rs b/tests/block_quote.rs index af9e9d9..5967f78 100644 --- a/tests/block_quote.rs +++ b/tests/block_quote.rs @@ -67,7 +67,7 @@ fn block_quote() { // "should not support lazy lists in block quotes" // ); - // To do: block quote (lazy, code (indented)). + // To do: block quote (lazy, code (indented), some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code>b\n</code></pre>", diff --git a/tests/code_indented.rs b/tests/code_indented.rs index ba1b483..f06cf4c 100644 --- a/tests/code_indented.rs +++ b/tests/code_indented.rs @@ -82,42 +82,42 @@ fn code_indented() { "should not support lazyness (1)" ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<p>a\nb</p>\n</blockquote>", // "should not support lazyness (2)" // ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<p>a\nb</p>\n</blockquote>", // "should not support lazyness (3)" // ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<p>a\nb</p>\n</blockquote>", // "should not support lazyness (4)" // ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code>b\n</code></pre>", // "should not support lazyness (5)" // ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code> b\n</code></pre>", // "should not support lazyness (6)" // ); - // To do: blockquote (lazy). + // To do: blockquote (lazy, some bug). // assert_eq!( // micromark("> a\n b"), // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code> b\n</code></pre>", diff --git a/tests/definition.rs b/tests/definition.rs index ffb3460..0686b6d 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -165,12 +165,11 @@ fn definition() { "should not support definitions in paragraphs" ); - // To do: block quote (some bug). - // assert_eq!( - // micromark("# [Foo]\n[foo]: /url\n> bar"), - // "<h1><a href=\"/url\">Foo</a></h1>\n<blockquote>\n<p>bar</p>\n</blockquote>", - // "should not support definitions in headings" - // ); + assert_eq!( + micromark("# [Foo]\n[foo]: /url\n> bar"), + "<h1><a href=\"/url\">Foo</a></h1>\n<blockquote>\n<p>bar</p>\n</blockquote>", + "should not support definitions in headings" + ); assert_eq!( micromark("[foo]: /url\nbar\n===\n[foo]"), |