From 4806864e5377a5fef937b3fa02542e620c547969 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 7 Jul 2022 17:21:38 +0200 Subject: Add basic support for block quotes --- tests/autolink.rs | 6 -- tests/block_quote.rs | 188 ++++++++++++++++++++++++++++++++++++++ tests/code_fenced.rs | 68 +++++++------- tests/code_indented.rs | 78 ++++++++-------- tests/definition.rs | 4 +- tests/heading_atx.rs | 11 +-- tests/heading_setext.rs | 28 +++--- tests/html_flow.rs | 108 +++++++++++----------- tests/misc_default_line_ending.rs | 93 +++++++++---------- tests/thematic_break.rs | 13 ++- 10 files changed, 394 insertions(+), 203 deletions(-) create mode 100644 tests/block_quote.rs (limited to 'tests') diff --git a/tests/autolink.rs b/tests/autolink.rs index 9c28834..7396c7a 100644 --- a/tests/autolink.rs +++ b/tests/autolink.rs @@ -9,12 +9,6 @@ const DANGER: &Options = &Options { #[test] fn autolink() { - assert_eq!( - micromark("```\n<\n >\n```"), - "
<\n >\n
", - "should support fenced code w/ grave accents" - ); - assert_eq!( micromark(""), "

http://foo.bar.baz

", diff --git a/tests/block_quote.rs b/tests/block_quote.rs new file mode 100644 index 0000000..908c724 --- /dev/null +++ b/tests/block_quote.rs @@ -0,0 +1,188 @@ +extern crate micromark; +use micromark::micromark; + +#[test] +fn block_quote() { + assert_eq!( + micromark("> # a\n> b\n> c"), + "
\n

a

\n

b\nc

\n
", + "should support block quotes" + ); + + assert_eq!( + micromark("># a\n>b\n> c"), + "
\n

a

\n

b\nc

\n
", + "should support block quotes w/o space" + ); + + assert_eq!( + micromark(" > # a\n > b\n > c"), + "
\n

a

\n

b\nc

\n
", + "should support prefixing block quotes w/ spaces" + ); + + assert_eq!( + micromark(" > # a\n > b\n > c"), + "
> # a\n> b\n> c\n
", + "should not support block quotes w/ 4 spaces" + ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> # a\n> b\nc"), + // "
\n

a

\n

b\nc

\n
", + // "should support lazy content lines" + // ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> a\nb\n> c"), + // "
\n

a\nb\nc

\n
", + // "should support lazy content lines inside block quotes" + // ); + + assert_eq!( + micromark("> a\n> ---"), + "
\n

a

\n
", + "should support setext headings underlines in block quotes" + ); + + // To do: block quote (lazy, setext underline) + // assert_eq!( + // micromark("> a\n---"), + // "
\n

a

\n
\n
", + // "should not support lazy setext headings underlines in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> - a\n> - b"), + // "
\n
    \n
  • a
  • \n
  • b
  • \n
\n
", + // "should support lists in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> - a\n- b"), + // "
\n
    \n
  • a
  • \n
\n
\n", + // "should not support lazy lists in block quotes" + // ); + + // To do: block quote (lazy, code (indented)). + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
b\n
", + // "should not support lazy indented code in block quotes" + // ); + + // To do: block quote (lazy, code (fenced)). + // assert_eq!( + // micromark("> ```\na\n```"), + // "
\n
\n
\n

a

\n
\n", + // "should not support lazy fenced code in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> a\n - b"), + // "
\n

a\n- b

\n
", + // "should not support lazy indented code (or lazy list) in block quotes" + // ); + + assert_eq!( + micromark(">"), + "
\n
", + "should support empty block quotes (1)" + ); + + assert_eq!( + micromark(">\n> \n> "), + "
\n
", + "should support empty block quotes (2)" + ); + + assert_eq!( + micromark(">\n> a\n> "), + "
\n

a

\n
", + "should support initial or final lazy empty block quote lines" + ); + + assert_eq!( + micromark("> a\n\n> b"), + "
\n

a

\n
\n
\n

b

\n
", + "should support adjacent block quotes" + ); + + assert_eq!( + micromark("> a\n> b"), + "
\n

a\nb

\n
", + "should support a paragraph in a block quote" + ); + + assert_eq!( + micromark("> a\n>\n> b"), + "
\n

a

\n

b

\n
", + "should support adjacent paragraphs in block quotes" + ); + + assert_eq!( + micromark("a\n> b"), + "

a

\n
\n

b

\n
", + "should support interrupting paragraphs w/ block quotes" + ); + + assert_eq!( + micromark("> a\n***\n> b"), + "
\n

a

\n
\n
\n
\n

b

\n
", + "should support interrupting block quotes w/ thematic breaks" + ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> a\nb"), + // "
\n

a\nb

\n
", + // "should not support interrupting block quotes w/ paragraphs" + // ); + + assert_eq!( + micromark("> a\n\nb"), + "
\n

a

\n
\n

b

", + "should support interrupting block quotes w/ blank lines" + ); + + assert_eq!( + micromark("> a\n>\nb"), + "
\n

a

\n
\n

b

", + "should not support interrupting a blank line in a block quotes w/ paragraphs" + ); + + // To do: block quote (multi, lazy). + // assert_eq!( + // micromark("> > > a\nb"), + // "
\n
\n
\n

a\nb

\n
\n
\n
", + // "should not support interrupting many block quotes w/ paragraphs (1)" + // ); + + // To do: block quote (multi, lazy). + // assert_eq!( + // micromark(">>> a\n> b\n>>c"), + // "
\n
\n
\n

a\nb\nc

\n
\n
\n
", + // "should not support interrupting many block quotes w/ paragraphs (2)" + // ); + + // To do: block quote (some bug). + // assert_eq!( + // micromark("> a\n\n> b"), + // "
\n
a\n
\n
\n
\n

b

\n
", + // "should support 5 spaces for indented code, not 4" + // ); + + // To do: turning things off. + // assert_eq!( + // micromark("> # a\n> b\n> c", { + // extensions: [{disable: {null: ["blockQuote"]}}] + // }), + // "

> # a\n> b\n> c

", + // "should support turning off block quotes" + // ); +} diff --git a/tests/code_fenced.rs b/tests/code_fenced.rs index b7d8307..d970c94 100644 --- a/tests/code_fenced.rs +++ b/tests/code_fenced.rs @@ -3,17 +3,19 @@ use micromark::micromark; #[test] fn code_fenced() { - assert_eq!( - micromark("```\n<\n >\n```"), - "
<\n >\n
", - "should support fenced code w/ grave accents" - ); + // To do: concrete constructs (code fenced). + // assert_eq!( + // micromark("```\n<\n >\n```"), + // "
<\n >\n
", + // "should support fenced code w/ grave accents" + // ); - assert_eq!( - micromark("~~~\n<\n >\n~~~"), - "
<\n >\n
", - "should support fenced code w/ tildes" - ); + // To do: concrete constructs (code fenced). + // assert_eq!( + // micromark("~~~\n<\n >\n~~~"), + // "
<\n >\n
", + // "should support fenced code w/ tildes" + // ); assert_eq!( micromark("``\nfoo\n``"), @@ -57,7 +59,7 @@ fn code_fenced() { "should support an eof somewhere in content" ); - // To do: blockquote. + // To do: blockquote (some bug). // assert_eq!( // micromark("> ```\n> aaa\n\nbbb"), // "
\n
aaa\n
\n
\n

bbb

", @@ -227,29 +229,31 @@ fn code_fenced() { "should not support a closing sequence w/ too much indent, regardless of opening sequence (1)" ); - // To do: blockquote. - // assert_eq!( - // micromark("> ```\n>\n>\n>\n\na"), - // "
\n
\n\n\n
\n
\n

a

", - // "should not support a closing sequence w/ too much indent, regardless of opening sequence (2)" + // To do: blockquote (some bug). + // assert_eq!( + // micromark("> ```\n>\n>\n>\n\na"), + // "
\n
\n\n\n
\n
\n

a

", + // "should not support a closing sequence w/ too much indent, regardless of opening sequence (2)" + // ); + + // To do: blockquote (some bug). + // assert_eq!( + // micromark("> ```a\nb"), + // "
\n
\n
\n

b

", + // "should not support lazyness (1)" // ); - // assert_eq!( - // micromark("> ```a\nb"), - // "
\n
\n
\n

b

", - // "should not support lazyness (1)" - // ); - - // assert_eq!( - // micromark("> a\n```b"), - // "
\n

a

\n
\n
\n", - // "should not support lazyness (2)" - // ); - - // assert_eq!( - // micromark("> ```a\n```"), - // "
\n
\n
\n
\n", - // "should not support lazyness (3)" + assert_eq!( + micromark("> a\n```b"), + "
\n

a

\n
\n
\n", + "should not support lazyness (2)" + ); + + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> ```a\n```"), + // "
\n
\n
\n
\n", + // "should not support lazyness (3)" // ); // To do: turning things off. diff --git a/tests/code_indented.rs b/tests/code_indented.rs index 773e3d4..d7cf181 100644 --- a/tests/code_indented.rs +++ b/tests/code_indented.rs @@ -76,48 +76,54 @@ fn code_indented() { "should support trailing whitespace" ); - // To do: blockquote. - // assert_eq!( - // micromark("> a\nb"), - // "
\n
a\n
\n
\n

b

", - // "should not support lazyness (1)" - // ); + // To do: blockquote (some bug). + // assert_eq!( + // micromark("> a\nb"), + // "
\n
a\n
\n
\n

b

", + // "should not support lazyness (1)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n

a\nb

\n
", - // "should not support lazyness (2)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (2)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n

a\nb

\n
", - // "should not support lazyness (3)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (3)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n

a\nb

\n
", - // "should not support lazyness (4)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (4)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n
a\n
\n
\n
b\n
", - // "should not support lazyness (5)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
b\n
", + // "should not support lazyness (5)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n
a\n
\n
\n
 b\n
", - // "should not support lazyness (6)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
 b\n
", + // "should not support lazyness (6)" + // ); - // assert_eq!( - // micromark("> a\n b"), - // "
\n
a\n
\n
\n
  b\n
", - // "should not support lazyness (7)" - // ); + // To do: blockquote (lazy). + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
  b\n
", + // "should not support lazyness (7)" + // ); // To do: turning things off. // assert_eq!( diff --git a/tests/definition.rs b/tests/definition.rs index df99f74..ca8b97c 100644 --- a/tests/definition.rs +++ b/tests/definition.rs @@ -165,7 +165,7 @@ fn definition() { "should not support definitions in paragraphs" ); - // To do: block quote. + // To do: block quote (some bug). // assert_eq!( // micromark("# [Foo]\n[foo]: /url\n> bar"), // "

Foo

\n
\n

bar

\n
", @@ -192,7 +192,7 @@ fn definition() { "should support definitions after definitions" ); - // To do: block quote. + // To do: block quote (some bug). // assert_eq!( // micromark("> [foo]: /url\n\n[foo]"), // "
\n
\n

foo

", diff --git a/tests/heading_atx.rs b/tests/heading_atx.rs index c9aa803..b7c87fe 100644 --- a/tests/heading_atx.rs +++ b/tests/heading_atx.rs @@ -182,12 +182,11 @@ fn heading_atx() { "should support empty atx headings" ); - // To do: block quote. - // assert_eq!( - // micromark("> #\na"), - // "
\n

\n
\n

a

", - // "should not support lazyness (1)" - // ); + assert_eq!( + micromark("> #\na"), + "
\n

\n
\n

a

", + "should not support lazyness (1)" + ); // assert_eq!( // micromark("> a\n#"), diff --git a/tests/heading_setext.rs b/tests/heading_setext.rs index 3c8b892..a42b8e5 100644 --- a/tests/heading_setext.rs +++ b/tests/heading_setext.rs @@ -129,14 +129,13 @@ fn heading_setext() { "should precede over inline constructs (2)" ); - // To do: block quote. - // assert_eq!( - // micromark("> Foo\n---"), - // "
\n

Foo

\n
\n
", - // "should not allow underline to be lazy (1)" - // ); + assert_eq!( + micromark("> Foo\n---"), + "
\n

Foo

\n
\n
", + "should not allow underline to be lazy (1)" + ); - // To do: block quote. + // To do: block quote (lazy). // assert_eq!( // micromark("> foo\nbar\n==="), // "
\n

foo\nbar\n===

\n
", @@ -187,12 +186,11 @@ fn heading_setext() { "should prefer other constructs over setext headings (3)" ); - // To do: block quote. - // assert_eq!( - // micromark("> foo\n-----"), - // "
\n

foo

\n
\n
", - // "should prefer other constructs over setext headings (4)" - // ); + assert_eq!( + micromark("> foo\n-----"), + "
\n

foo

\n
\n
", + "should prefer other constructs over setext headings (4)" + ); assert_eq!( micromark("\\> foo\n------"), @@ -249,14 +247,14 @@ fn heading_setext() { "should prefer a setext heading over an interrupting list" ); - // To do: block quote. + // To do: block quote (lazy). // assert_eq!( // micromark("> ===\na"), // "
\n

===\na

\n
", // "should not support lazyness (1)" // ); - // To do: block quote. + // To do: block quote (lazy). // assert_eq!( // micromark("> a\n==="), // "
\n

a\n===

\n
", diff --git a/tests/html_flow.rs b/tests/html_flow.rs index 348da8d..e53b47e 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -171,18 +171,18 @@ p {color:blue;} "should support blank lines in raw" ); - // To do: block quote. + // To do: block quote (lazy). // assert_eq!( // micromark_with_options(">