diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 13:32:32 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 13:32:32 +0200 |
commit | 645fb2b02b1563bd98c07515bdc2d6d8478ba74e (patch) | |
tree | 239bf35cc5ba6560d1f19344c24ec8a1aebe882f /tests/frontmatter.rs | |
parent | 02ac7c7a69fc7949912a266f3cfc40f7c219278e (diff) | |
download | markdown-rs-645fb2b02b1563bd98c07515bdc2d6d8478ba74e.tar.gz markdown-rs-645fb2b02b1563bd98c07515bdc2d6d8478ba74e.tar.bz2 markdown-rs-645fb2b02b1563bd98c07515bdc2d6d8478ba74e.zip |
Add a bunch more tests for frontmatter
Diffstat (limited to '')
-rw-r--r-- | tests/frontmatter.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/frontmatter.rs b/tests/frontmatter.rs index 267b694..b1380b6 100644 --- a/tests/frontmatter.rs +++ b/tests/frontmatter.rs @@ -45,12 +45,60 @@ fn frontmatter() -> Result<(), String> { ); assert_eq!( + to_html_with_options("--\n---", &frontmatter)?, + "<h2>--</h2>", + "should not support 2 markers in an opening fence" + ); + + assert_eq!( + to_html_with_options("----\n---", &frontmatter)?, + "<hr />\n<hr />", + "should not support 4 markers in an opening fence" + ); + + assert_eq!( + to_html_with_options("---\n--", &frontmatter)?, + "<hr />\n<p>--</p>", + "should not support 2 markers in a closing fence" + ); + + assert_eq!( + to_html_with_options("---\n----", &frontmatter)?, + "<hr />\n<hr />", + "should not support 4 markers in a closing fence" + ); + + assert_eq!( to_html_with_options("---\n---\n## Neptune", &frontmatter)?, "<h2>Neptune</h2>", "should support content after frontmatter" ); assert_eq!( + to_html_with_options("--- \t\n---", &frontmatter)?, + "", + "should support spaces and tabs after opening fence" + ); + + assert_eq!( + to_html_with_options("---\n---\t ", &frontmatter)?, + "", + "should support spaces and tabs after closing fence" + ); + + assert_eq!( + to_html_with_options("--- a\n---", &frontmatter)?, + "<h2>--- a</h2>", + "should not support content after opening fence" + ); + + assert_eq!( + to_html_with_options("---\n--- b", &frontmatter)?, + "<hr />\n<p>--- b</p>", + "should not support content after closing fence" + ); + + assert_eq!( to_html_with_options("## Neptune\n---\n---", &frontmatter)?, "<h2>Neptune</h2>\n<hr />\n<hr />", "should not support frontmatter after content" @@ -75,6 +123,12 @@ fn frontmatter() -> Result<(), String> { ); assert_eq!( + to_html_with_options("---\na\n\nb\n \t\nc\n---", &frontmatter)?, + "", + "should support blank lines in frontmatter" + ); + + assert_eq!( to_mdast("---\na: b\n---", &frontmatter.parse)?, Node::Root(Root { children: vec![Node::Yaml(Yaml { |