From 1d92666865b35341e076efbefddf6e73b5e1542e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 7 Sep 2022 15:53:06 +0200 Subject: Add support for recoverable syntax errors --- tests/list.rs | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'tests/list.rs') diff --git a/tests/list.rs b/tests/list.rs index bbba7cd..4007251 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -3,7 +3,7 @@ use micromark::{micromark, micromark_with_options, Constructs, Options}; use pretty_assertions::assert_eq; #[test] -fn list() { +fn list() -> Result<(), String> { let danger = Options { allow_dangerous_html: true, ..Options::default() @@ -11,8 +11,7 @@ fn list() { assert_eq!( micromark( - "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote." - ), + "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote."), "

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
", "should support documents" ); @@ -205,40 +204,35 @@ fn list() { assert_eq!( micromark( - " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote." - ), + " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote."), "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
", "should support indenting w/ 1 space" ); assert_eq!( micromark( - " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote." - ), + " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote."), "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
", "should support indenting w/ 2 spaces" ); assert_eq!( micromark( - " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote." - ), + " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote."), "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
", "should support indenting w/ 3 spaces" ); assert_eq!( micromark( - " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote." - ), + " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote."), "
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
", "should not support indenting w/ 4 spaces" ); assert_eq!( micromark( - " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote." - ), + " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote."), "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
", "should support lazy lines" ); @@ -370,13 +364,13 @@ fn list() { ); assert_eq!( - micromark_with_options("- foo\n- bar\n\n\n\n- baz\n- bim", &danger), + micromark_with_options("- foo\n- bar\n\n\n\n- baz\n- bim", &danger)?, "\n\n", "should support HTML comments between lists" ); assert_eq!( - micromark_with_options("- foo\n\n notcode\n\n- foo\n\n\n\n code", &danger), + micromark_with_options("- foo\n\n notcode\n\n- foo\n\n\n\n code", &danger)?, "\n\n
code\n
", "should support HTML comments between lists and indented code" ); @@ -498,8 +492,7 @@ fn list() { assert_eq!( micromark( - "* a tight item that ends with an html element: `x`\n\nParagraph" - ), + "* a tight item that ends with an html element: `x`\n\nParagraph"), "\n

Paragraph

", "should ignore line endings after tight items ending in tags" ); @@ -565,7 +558,7 @@ fn list() { ); assert_eq!( - micromark_with_options("* a\n\n\n\n* b", &danger), + micromark_with_options("* a\n\n\n\n* b", &danger)?, "\n\n", "should support the common list breaking comment method" ); @@ -580,8 +573,10 @@ fn list() { }, ..Options::default() } - ), + )?, "

- one

\n

two

", "should support turning off lists" ); + + Ok(()) } -- cgit