diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-18 10:44:06 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-18 10:46:14 +0200 |
commit | 32f9f35d89e41072543186969b995ac9aa020f98 (patch) | |
tree | b506e056ed810e6a11570c350316b12f500344da | |
parent | 3aa10425c95bbe79050c3166702e38758fbe646e (diff) | |
download | markdown-rs-32f9f35d89e41072543186969b995ac9aa020f98.tar.gz markdown-rs-32f9f35d89e41072543186969b995ac9aa020f98.tar.bz2 markdown-rs-32f9f35d89e41072543186969b995ac9aa020f98.zip |
Fix final bug with laziness
-rw-r--r-- | src/content/document.rs | 9 | ||||
-rw-r--r-- | tests/commonmark.rs | 294 |
2 files changed, 143 insertions, 160 deletions
diff --git a/src/content/document.rs b/src/content/document.rs index 704cfea..7656db7 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -393,14 +393,7 @@ fn flow_end( .token_type == Token::Paragraph; - if tokenizer.lazy - && info.paragraph_before - && paragraph - && !(matches!( - tokenizer.previous, - Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') - ) && matches!(code, Code::None)) - { + if tokenizer.lazy && info.paragraph_before && paragraph { info.continued = info.stack.len(); } diff --git a/tests/commonmark.rs b/tests/commonmark.rs index 1734004..503acca 100644 --- a/tests/commonmark.rs +++ b/tests/commonmark.rs @@ -999,20 +999,19 @@ of dashes"/> r###"Setext headings (91)"### ); -// To do: lazy setext underline bug. -// assert_eq!( -// micromark_with_options(r###"> foo -// bar -// === -// "###, DANGER), -// r###"<blockquote> -// <p>foo -// bar -// ===</p> -// </blockquote> -// "###, -// r###"Setext headings (92)"### -// ); + assert_eq!( + micromark_with_options(r###"> foo +bar +=== +"###, DANGER), + r###"<blockquote> +<p>foo +bar +===</p> +</blockquote> +"###, + r###"Setext headings (92)"### +); assert_eq!( micromark_with_options(r###"- Foo @@ -2797,20 +2796,19 @@ baz</p> r###"Block quotes (230)"### ); - // To do: some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> # Foo - // > bar - // baz - // "###, DANGER), - // r###"<blockquote> - // <h1>Foo</h1> - // <p>bar - // baz</p> - // </blockquote> - // "###, - // r###"Block quotes (231)"### - // ); + assert_eq!( + micromark_with_options(r###"> # Foo +> bar +baz +"###, DANGER), + r###"<blockquote> +<h1>Foo</h1> +<p>bar +baz</p> +</blockquote> +"###, + r###"Block quotes (231)"### +); assert_eq!( micromark_with_options(r###"> bar @@ -2882,18 +2880,17 @@ foo r###"Block quotes (236)"### ); - // To do: some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> foo - // - bar - // "###, DANGER), - // r###"<blockquote> - // <p>foo - // - bar</p> - // </blockquote> - // "###, - // r###"Block quotes (237)"### - // ); + assert_eq!( + micromark_with_options(r###"> foo + - bar +"###, DANGER), + r###"<blockquote> +<p>foo +- bar</p> +</blockquote> +"###, + r###"Block quotes (237)"### +); assert_eq!( micromark_with_options(r###"> @@ -2995,18 +2992,17 @@ bar</p> r###"Block quotes (245)"### ); - // To do: some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> bar - // baz - // "###, DANGER), - // r###"<blockquote> - // <p>bar - // baz</p> - // </blockquote> - // "###, - // r###"Block quotes (246)"### - // ); + assert_eq!( + micromark_with_options(r###"> bar +baz +"###, DANGER), + r###"<blockquote> +<p>bar +baz</p> +</blockquote> +"###, + r###"Block quotes (246)"### +); assert_eq!( micromark_with_options(r###"> bar @@ -3034,41 +3030,39 @@ baz r###"Block quotes (248)"### ); - // To do: some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> > > foo - // bar - // "###, DANGER), - // r###"<blockquote> - // <blockquote> - // <blockquote> - // <p>foo - // bar</p> - // </blockquote> - // </blockquote> - // </blockquote> - // "###, - // r###"Block quotes (249)"### - // ); + assert_eq!( + micromark_with_options(r###"> > > foo +bar +"###, DANGER), + r###"<blockquote> +<blockquote> +<blockquote> +<p>foo +bar</p> +</blockquote> +</blockquote> +</blockquote> +"###, + r###"Block quotes (249)"### +); - // To do: some lazy bug. - // assert_eq!( - // micromark_with_options(r###">>> foo - // > bar - // >>baz - // "###, DANGER), - // r###"<blockquote> - // <blockquote> - // <blockquote> - // <p>foo - // bar - // baz</p> - // </blockquote> - // </blockquote> - // </blockquote> - // "###, - // r###"Block quotes (250)"### - // ); + assert_eq!( + micromark_with_options(r###">>> foo +> bar +>>baz +"###, DANGER), + r###"<blockquote> +<blockquote> +<blockquote> +<p>foo +bar +baz</p> +</blockquote> +</blockquote> +</blockquote> +"###, + r###"Block quotes (250)"### +); assert_eq!( micromark_with_options(r###"> code @@ -3696,56 +3690,53 @@ with two lines.</p> r###"List items (289)"### ); - // To do: Some lazy bug. - // assert_eq!( - // micromark_with_options(r###" 1. A paragraph - // with two lines. - // "###, DANGER), - // r###"<ol> - // <li>A paragraph - // with two lines.</li> - // </ol> - // "###, - // r###"List items (290)"### - // ); + assert_eq!( + micromark_with_options(r###" 1. A paragraph + with two lines. +"###, DANGER), + r###"<ol> +<li>A paragraph +with two lines.</li> +</ol> +"###, + r###"List items (290)"### +); - // To do: Some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> 1. > Blockquote - // continued here. - // "###, DANGER), - // r###"<blockquote> - // <ol> - // <li> - // <blockquote> - // <p>Blockquote - // continued here.</p> - // </blockquote> - // </li> - // </ol> - // </blockquote> - // "###, - // r###"List items (291)"### - // ); + assert_eq!( + micromark_with_options(r###"> 1. > Blockquote +continued here. +"###, DANGER), + r###"<blockquote> +<ol> +<li> +<blockquote> +<p>Blockquote +continued here.</p> +</blockquote> +</li> +</ol> +</blockquote> +"###, + r###"List items (291)"### +); - // To do: Some lazy bug. - // assert_eq!( - // micromark_with_options(r###"> 1. > Blockquote - // > continued here. - // "###, DANGER), - // r###"<blockquote> - // <ol> - // <li> - // <blockquote> - // <p>Blockquote - // continued here.</p> - // </blockquote> - // </li> - // </ol> - // </blockquote> - // "###, - // r###"List items (292)"### - // ); + assert_eq!( + micromark_with_options(r###"> 1. > Blockquote +> continued here. +"###, DANGER), + r###"<blockquote> +<ol> +<li> +<blockquote> +<p>Blockquote +continued here.</p> +</blockquote> +</li> +</ol> +</blockquote> +"###, + r###"List items (292)"### +); assert_eq!( micromark_with_options(r###"- foo @@ -4077,24 +4068,23 @@ baz</li> r###"Lists (310)"### ); - // To do: Some interruption bug. - // assert_eq!( - // micromark_with_options(r###"- a - // - b - // - c - // - d - // - e - // "###, DANGER), - // r###"<ul> - // <li>a</li> - // <li>b</li> - // <li>c</li> - // <li>d - // - e</li> - // </ul> - // "###, - // r###"Lists (311)"### - // ); + assert_eq!( + micromark_with_options(r###"- a + - b + - c + - d + - e +"###, DANGER), + r###"<ul> +<li>a</li> +<li>b</li> +<li>c</li> +<li>d +- e</li> +</ul> +"###, + r###"Lists (311)"### +); assert_eq!( micromark_with_options(r###"1. a |