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/frontmatter.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'tests/frontmatter.rs') diff --git a/tests/frontmatter.rs b/tests/frontmatter.rs index 012eb9a..6195a5a 100644 --- a/tests/frontmatter.rs +++ b/tests/frontmatter.rs @@ -3,7 +3,7 @@ use micromark::{micromark, micromark_with_options, Constructs, Options}; use pretty_assertions::assert_eq; #[test] -fn frontmatter() { +fn frontmatter() -> Result<(), String> { let frontmatter = Options { constructs: Constructs { frontmatter: true, @@ -19,50 +19,52 @@ fn frontmatter() { ); assert_eq!( - micromark_with_options("---\ntitle: Jupyter\n---", &frontmatter), + micromark_with_options("---\ntitle: Jupyter\n---", &frontmatter)?, "", "should support frontmatter (yaml)" ); assert_eq!( - micromark_with_options("+++\ntitle = \"Jupyter\"\n+++", &frontmatter), + micromark_with_options("+++\ntitle = \"Jupyter\"\n+++", &frontmatter)?, "", "should support frontmatter (toml)" ); assert_eq!( - micromark_with_options("---\n---", &frontmatter), + micromark_with_options("---\n---", &frontmatter)?, "", "should support empty frontmatter" ); assert_eq!( - micromark_with_options("---\n---\n## Neptune", &frontmatter), + micromark_with_options("---\n---\n## Neptune", &frontmatter)?, "

Neptune

", "should support content after frontmatter" ); assert_eq!( - micromark_with_options("## Neptune\n---\n---", &frontmatter), + micromark_with_options("## Neptune\n---\n---", &frontmatter)?, "

Neptune

\n
\n
", "should not support frontmatter after content" ); assert_eq!( - micromark_with_options("> ---\n> ---\n> ## Neptune", &frontmatter), + micromark_with_options("> ---\n> ---\n> ## Neptune", &frontmatter)?, "
\n
\n
\n

Neptune

\n
", "should not support frontmatter in a container" ); assert_eq!( - micromark_with_options("---", &frontmatter), + micromark_with_options("---", &frontmatter)?, "
", "should not support just an opening fence" ); assert_eq!( - micromark_with_options("---\ntitle: Neptune", &frontmatter), + micromark_with_options("---\ntitle: Neptune", &frontmatter)?, "
\n

title: Neptune

", "should not support a missing closing fence" ); + + Ok(()) } -- cgit