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/gfm_strikethrough.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'tests/gfm_strikethrough.rs') diff --git a/tests/gfm_strikethrough.rs b/tests/gfm_strikethrough.rs index f39be07..b8c3e1f 100644 --- a/tests/gfm_strikethrough.rs +++ b/tests/gfm_strikethrough.rs @@ -3,7 +3,7 @@ use micromark::{micromark, micromark_with_options, Constructs, Options}; use pretty_assertions::assert_eq; #[test] -fn gfm_strikethrough() { +fn gfm_strikethrough() -> Result<(), String> { let gfm = Options { constructs: Constructs::gfm(), ..Options::default() @@ -16,49 +16,49 @@ fn gfm_strikethrough() { ); assert_eq!( - micromark_with_options("a ~b~", &gfm), + micromark_with_options("a ~b~", &gfm)?, "

a b

", "should support strikethrough w/ one tilde" ); assert_eq!( - micromark_with_options("a ~~b~~", &gfm), + micromark_with_options("a ~~b~~", &gfm)?, "

a b

", "should support strikethrough w/ two tildes" ); assert_eq!( - micromark_with_options("a ~~~b~~~", &gfm), + micromark_with_options("a ~~~b~~~", &gfm)?, "

a ~~~b~~~

", "should not support strikethrough w/ three tildes" ); assert_eq!( - micromark_with_options("a \\~~~b~~ c", &gfm), + micromark_with_options("a \\~~~b~~ c", &gfm)?, "

a ~b c

", "should support strikethrough after an escaped tilde" ); assert_eq!( - micromark_with_options("a ~~b ~~c~~ d~~ e", &gfm), + micromark_with_options("a ~~b ~~c~~ d~~ e", &gfm)?, "

a b c d e

", "should support nested strikethrough" ); assert_eq!( - micromark_with_options("a ~-1~ b", &gfm), + micromark_with_options("a ~-1~ b", &gfm)?, "

a -1 b

", "should open if preceded by whitespace and followed by punctuation" ); assert_eq!( - micromark_with_options("a ~b.~ c", &gfm), + micromark_with_options("a ~b.~ c", &gfm)?, "

a b. c

", "should close if preceded by punctuation and followed by whitespace" ); assert_eq!( - micromark_with_options("~b.~.", &gfm), + micromark_with_options("~b.~.", &gfm)?, "

b..

", "should close if preceded and followed by punctuation" ); @@ -123,7 +123,7 @@ a ~~two b one~ c two~~ d a ~~two b two~~ c one~ d "###, &gfm - ), + )?, r###"

Balanced

a one b

a two b

@@ -192,7 +192,7 @@ a ~~twoLeft b ~~twoLeft c twoRight~~ d a ~~twoLeft b ~~twoLeft c ~~twoLeft d "###, &gfm - ), + )?, r###"

Flank

a oneRight~ b oneRight~ c oneRight~ d

a oneRight~ b oneRight~ c ~oneLeft d

@@ -309,7 +309,7 @@ t ~~**xxx**~~ zzz u ~**xxx**~ zzz "###, &gfm - ), + )?, r###"

Interlpay

Interleave with attention

a two emphasis two b

@@ -367,7 +367,7 @@ u ~**xxx**~ zzz gfm_strikethrough_single_tilde: false, ..Options::default() } - ), + )?, "

a ~b~ c d

", "should not support strikethrough w/ one tilde if `singleTilde: false`" ); @@ -380,8 +380,10 @@ u ~**xxx**~ zzz gfm_strikethrough_single_tilde: true, ..Options::default() } - ), + )?, "

a b c d

", "should support strikethrough w/ one tilde if `singleTilde: true`" ); + + Ok(()) } -- cgit