diff options
| author | 2022-10-13 10:40:01 +0200 | |
|---|---|---|
| committer | 2022-10-13 10:40:01 +0200 | |
| commit | ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a (patch) | |
| tree | 2da4be3be22c2324c48cb17133b3f4b26b9139d2 /tests/html_flow.rs | |
| parent | 861af95c119721e814460fa7dc32bd3d74b38484 (diff) | |
| download | markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.tar.gz markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.tar.bz2 markdown-rs-ec2d1bfb4232178fb3a6cba36f138bc6efbbf34a.zip | |
Rename crate to `markdown`
Diffstat (limited to '')
| -rw-r--r-- | tests/html_flow.rs | 306 |
1 files changed, 153 insertions, 153 deletions
diff --git a/tests/html_flow.rs b/tests/html_flow.rs index adeebf6..546cb13 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -1,7 +1,7 @@ -extern crate micromark; -use micromark::{ +extern crate markdown; +use markdown::{ mdast::{Html, Node, Root}, - micromark, micromark_to_mdast, micromark_with_options, + to_html, to_html_with_options, to_mdast, unist::Position, CompileOptions, Constructs, Options, ParseOptions, }; @@ -19,19 +19,19 @@ fn html_flow() -> Result<(), String> { }; assert_eq!( - micromark("<!-- asd -->"), + to_html("<!-- asd -->"), "<!-- asd -->", "should support a heading w/ rank 1" ); assert_eq!( - micromark_with_options("<!-- asd -->", &danger)?, + to_html_with_options("<!-- asd -->", &danger)?, "<!-- asd -->", "should support a heading w/ rank 1" ); assert_eq!( - micromark_with_options( + to_html_with_options( "<x>", &Options { parse: ParseOptions { @@ -49,7 +49,7 @@ fn html_flow() -> Result<(), String> { ); assert_eq!( - micromark_to_mdast("<div>\nstuff\n</div>", &ParseOptions::default())?, + to_mdast("<div>\nstuff\n</div>", &ParseOptions::default())?, Node::Root(Root { children: vec![Node::Html(Html { value: "<div>\nstuff\n</div>".into(), @@ -75,7 +75,7 @@ fn html_flow_1_raw() -> Result<(), String> { }; assert_eq!( - micromark_with_options( + to_html_with_options( "<pre language=\"haskell\"><code> import Text.HTML.TagSoup @@ -96,7 +96,7 @@ main = print $ parseTags tags ); assert_eq!( - micromark_with_options( + to_html_with_options( "<script type=\"text/javascript\"> // JavaScript example @@ -115,7 +115,7 @@ document.getElementById(\"demo\").innerHTML = \"Hello JavaScript!\"; ); assert_eq!( - micromark_with_options( + to_html_with_options( "<style type=\"text/css\"> h1 {color:red;} @@ -136,92 +136,92 @@ p {color:blue;} ); assert_eq!( - micromark_with_options("<style\n type=\"text/css\">\n\nfoo", &danger)?, + to_html_with_options("<style\n type=\"text/css\">\n\nfoo", &danger)?, "<style\n type=\"text/css\">\n\nfoo", "should support raw tags w/o ending" ); assert_eq!( - micromark_with_options("<style>p{color:red;}</style>\n*foo*", &danger)?, + to_html_with_options("<style>p{color:red;}</style>\n*foo*", &danger)?, "<style>p{color:red;}</style>\n<p><em>foo</em></p>", "should support raw tags w/ start and end on a single line" ); assert_eq!( - micromark_with_options("<script>\nfoo\n</script>1. *bar*", &danger)?, + to_html_with_options("<script>\nfoo\n</script>1. *bar*", &danger)?, "<script>\nfoo\n</script>1. *bar*", "should support raw tags w/ more data on ending line" ); assert_eq!( - micromark_with_options("<script", &danger)?, + to_html_with_options("<script", &danger)?, "<script", "should support an eof directly after a raw tag name" ); assert_eq!( - micromark_with_options("</script\nmore", &danger)?, + to_html_with_options("</script\nmore", &danger)?, "<p></script\nmore</p>", "should not support a raw closing tag" ); assert_eq!( - micromark_with_options("<script/", &danger)?, + to_html_with_options("<script/", &danger)?, "<p><script/</p>", "should not support an eof after a self-closing slash" ); assert_eq!( - micromark_with_options("<script/\n*asd*", &danger)?, + to_html_with_options("<script/\n*asd*", &danger)?, "<p><script/\n<em>asd</em></p>", "should not support a line ending after a self-closing slash" ); assert_eq!( - micromark_with_options("<script/>", &danger)?, + to_html_with_options("<script/>", &danger)?, "<script/>", "should support an eof after a self-closing tag" ); assert_eq!( - micromark_with_options("<script/>\na", &danger)?, + to_html_with_options("<script/>\na", &danger)?, "<script/>\na", "should support a line ending after a self-closing tag" ); assert_eq!( - micromark_with_options("<script/>a", &danger)?, + to_html_with_options("<script/>a", &danger)?, "<p><script/>a</p>", "should not support other characters after a self-closing tag" ); assert_eq!( - micromark_with_options("<script>a", &danger)?, + to_html_with_options("<script>a", &danger)?, "<script>a", "should support other characters after a raw opening tag" ); // Extra. assert_eq!( - micromark_with_options("Foo\n<script", &danger)?, + to_html_with_options("Foo\n<script", &danger)?, "<p>Foo</p>\n<script", "should support interrupting paragraphs w/ raw tags" ); assert_eq!( - micromark_with_options("<script>\n \n \n</script>", &danger)?, + to_html_with_options("<script>\n \n \n</script>", &danger)?, "<script>\n \n \n</script>", "should support blank lines in raw" ); assert_eq!( - micromark_with_options("> <script>\na", &danger)?, + to_html_with_options("> <script>\na", &danger)?, "<blockquote>\n<script>\n</blockquote>\n<p>a</p>", "should not support lazyness (1)" ); assert_eq!( - micromark_with_options("> a\n<script>", &danger)?, + to_html_with_options("> a\n<script>", &danger)?, "<blockquote>\n<p>a</p>\n</blockquote>\n<script>", "should not support lazyness (2)" ); @@ -241,96 +241,96 @@ fn html_flow_2_comment() -> Result<(), String> { }; assert_eq!( - micromark_with_options("<!-- Foo\n\nbar\n baz -->\nokay", &danger)?, + to_html_with_options("<!-- Foo\n\nbar\n baz -->\nokay", &danger)?, "<!-- Foo\n\nbar\n baz -->\n<p>okay</p>", "should support comments (type 2)" ); assert_eq!( - micromark_with_options("<!-- foo -->*bar*\n*baz*", &danger)?, + to_html_with_options("<!-- foo -->*bar*\n*baz*", &danger)?, "<!-- foo -->*bar*\n<p><em>baz</em></p>", "should support comments w/ start and end on a single line" ); assert_eq!( - micromark_with_options("<!-asd-->", &danger)?, + to_html_with_options("<!-asd-->", &danger)?, "<p><!-asd--></p>", "should not support a single dash to start comments" ); assert_eq!( - micromark_with_options("<!-->", &danger)?, + to_html_with_options("<!-->", &danger)?, "<!-->", "should support comments where the start dashes are the end dashes (1)" ); assert_eq!( - micromark_with_options("<!--->", &danger)?, + to_html_with_options("<!--->", &danger)?, "<!--->", "should support comments where the start dashes are the end dashes (2)" ); assert_eq!( - micromark_with_options("<!---->", &danger)?, + to_html_with_options("<!---->", &danger)?, "<!---->", "should support empty comments" ); // If the `\"` is encoded, we’re in text. If it remains, we’re in HTML. assert_eq!( - micromark_with_options("<!--\n->\n\"", &danger)?, + to_html_with_options("<!--\n->\n\"", &danger)?, "<!--\n->\n\"", "should not end a comment at one dash (`->`)" ); assert_eq!( - micromark_with_options("<!--\n-->\n\"", &danger)?, + to_html_with_options("<!--\n-->\n\"", &danger)?, "<!--\n-->\n<p>"</p>", "should end a comment at two dashes (`-->`)" ); assert_eq!( - micromark_with_options("<!--\n--->\n\"", &danger)?, + to_html_with_options("<!--\n--->\n\"", &danger)?, "<!--\n--->\n<p>"</p>", "should end a comment at three dashes (`--->`)" ); assert_eq!( - micromark_with_options("<!--\n---->\n\"", &danger)?, + to_html_with_options("<!--\n---->\n\"", &danger)?, "<!--\n---->\n<p>"</p>", "should end a comment at four dashes (`---->`)" ); assert_eq!( - micromark_with_options(" <!-- foo -->", &danger)?, + to_html_with_options(" <!-- foo -->", &danger)?, " <!-- foo -->", "should support comments w/ indent" ); assert_eq!( - micromark_with_options(" <!-- foo -->", &danger)?, + to_html_with_options(" <!-- foo -->", &danger)?, "<pre><code><!-- foo -->\n</code></pre>", "should not support comments w/ a 4 character indent" ); // Extra. assert_eq!( - micromark_with_options("Foo\n<!--", &danger)?, + to_html_with_options("Foo\n<!--", &danger)?, "<p>Foo</p>\n<!--", "should support interrupting paragraphs w/ comments" ); assert_eq!( - micromark_with_options("<!--\n \n \n-->", &danger)?, + to_html_with_options("<!--\n \n \n-->", &danger)?, "<!--\n \n \n-->", "should support blank lines in comments" ); assert_eq!( - micromark_with_options("> <!--\na", &danger)?, + to_html_with_options("> <!--\na", &danger)?, "<blockquote>\n<!--\n</blockquote>\n<p>a</p>", "should not support lazyness (1)" ); assert_eq!( - micromark_with_options("> a\n<!--", &danger)?, + to_html_with_options("> a\n<!--", &danger)?, "<blockquote>\n<p>a</p>\n</blockquote>\n<!--", "should not support lazyness (2)" ); @@ -350,44 +350,44 @@ fn html_flow_3_instruction() -> Result<(), String> { }; assert_eq!( - micromark_with_options("<?php\n\n echo \">\";\n\n?>\nokay", &danger)?, + to_html_with_options("<?php\n\n echo \">\";\n\n?>\nokay", &danger)?, "<?php\n\n echo \">\";\n\n?>\n<p>okay</p>", "should support instructions (type 3)" ); assert_eq!( - micromark_with_options("<?>", &danger)?, + to_html_with_options("<?>", &danger)?, "<?>", "should support empty instructions where the `?` is part of both the start and the end" ); assert_eq!( - micromark_with_options("<??>", &danger)?, + to_html_with_options("<??>", &danger)?, "<??>", "should support empty instructions" ); // Extra. assert_eq!( - micromark_with_options("Foo\n<?", &danger)?, + to_html_with_options("Foo\n<?", &danger)?, "<p>Foo</p>\n<?", "should support interrupting paragraphs w/ instructions" ); assert_eq!( - micromark_with_options("<?\n \n \n?>", &danger)?, + to_html_with_options("<?\n \n \n?>", &danger)?, "<?\n \n \n?>", "should support blank lines in instructions" ); assert_eq!( - micromark_with_options("> <?\na", &danger)?, + to_html_with_options("> <?\na", &danger)?, "<blockquote>\n<?\n</blockquote>\n<p>a</p>", "should not support lazyness (1)" ); assert_eq!( - micromark_with_options("> a\n<?", &danger)?, + to_html_with_options("> a\n<?", &danger)?, "<blockquote>\n<p>a</p>\n</blockquote>\n<?", "should not support lazyness (2)" ); @@ -407,32 +407,32 @@ fn html_flow_4_declaration() -> Result<(), String> { }; assert_eq!( - micromark_with_options("<!DOCTYPE html>", &danger)?, + to_html_with_options("<!DOCTYPE html>", &danger)?, "<!DOCTYPE html>", "should support declarations (type 4)" ); assert_eq!( - micromark_with_options("<!123>", &danger)?, + to_html_with_options("<!123>", &danger)?, "<p><!123></p>", "should not support declarations that start w/o an alpha" ); assert_eq!( - micromark_with_options("<!>", &danger)?, + to_html_with_options("<!>", &danger)?, "<p><!></p>", "should not support declarations w/o an identifier" ); assert_eq!( - micromark_with_options("<!a>", &danger)?, + to_html_with_options("<!a>", &danger)?, "<!a>", "should support declarations w/o a single alpha as identifier" ); // Extra. assert_eq!( - micromark_with_options("Foo\n<!d", &danger)?, + to_html_with_options("Foo\n<!d", &danger)?, "<p>Foo</p>\n<!d", "should support interrupting paragraphs w/ declarations" ); @@ -440,19 +440,19 @@ fn html_flow_4_declaration() -> Result<(), String> { // Note about the lower letter: // <https://github.com/commonmark/commonmark-spec/pull/621> assert_eq!( - micromark_with_options("<!a\n \n \n>", &danger)?, + to_html_with_options("<!a\n \n \n>", &danger)?, "<!a\n \n \n>", "should support blank lines in declarations" ); assert_eq!( - micromark_with_options("> <!a\nb", &danger)?, + to_html_with_options("> <!a\nb", &danger)?, "<blockquote>\n<!a\n</blockquote>\n<p>b</p>", "should not support lazyness (1)" ); assert_eq!( - micromark_with_options("> a\n<!b", &danger)?, + to_html_with_options("> a\n<!b", &danger)?, "<blockquote>\n<p>a</p>\n</blockquote>\n<!b", "should not support lazyness (2)" ); @@ -472,7 +472,7 @@ fn html_flow_5_cdata() -> Result<(), String> { }; assert_eq!( - micromark_with_options( + to_html_with_options( "<![CDATA[\nfunction matchwo(a,b)\n{\n if (a < b && a < 0) then {\n return 1;\n\n } else {\n\n return 0;\n }\n}\n]]>\nokay", &danger )?, @@ -481,26 +481,26 @@ fn html_flow_5_cdata() -> Result<(), String> { ); assert_eq!( - micromark_with_options("<![CDATA[]]>", &danger)?, + to_html_with_options("<![CDATA[]]>", &danger)?, "<![CDATA[]]>", "should support empty cdata" ); assert_eq!( - micromark_with_options("<![CDATA]]>", &danger)?, + to_html_with_options("<![CDATA]]>", &danger)?, "<p><![CDATA]]></p>", "should not support cdata w/ a missing `[`" ); assert_eq!( - micromark_with_options("<![CDATA[]]]>", &danger)?, + to_html_with_options("<![CDATA[]]]>", &danger)?, "<![CDATA[]]]>", "should support cdata w/ a single `]` as content" ); // Extra. assert_eq!( - micromark_with_options("Foo\n<![CDATA[", &danger)?, + to_html_with_options("Foo\n<![CDATA[", &danger)?, "<p>Foo</p>\n<![CDATA[", "should support interrupting paragraphs w/ cdata" ); @@ -508,25 +508,25 @@ fn html_flow_5_cdata() -> Result<(), String> { // Note: cmjs parses this differently. // See: <https://github.com/commonmark/commonmark.js/issues/193> assert_eq!( - micromark_with_options("<![cdata[]]>", &danger)?, + to_html_with_options("<![cdata[]]>", &danger)?, "<p><![cdata[]]></p>", "should not support lowercase cdata" ); assert_eq!( - micromark_with_options("<![CDATA[\n \n \n]]>", &danger)?, + to_html_with_options("<![CDATA[\n \n \n]]>", &danger)?, "<![CDATA[\n \n \n]]>", "should support blank lines in cdata" ); assert_eq!( - micromark_with_options("> <