diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-07 17:21:38 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-07 17:36:35 +0200 |
commit | 4806864e5377a5fef937b3fa02542e620c547969 (patch) | |
tree | c91ae2bbd1dc2037f425efd24d62d05e706e3e60 /tests/block_quote.rs | |
parent | c2b4402223e53498078fc33dd55aabc0a48cdb56 (diff) | |
download | markdown-rs-4806864e5377a5fef937b3fa02542e620c547969.tar.gz markdown-rs-4806864e5377a5fef937b3fa02542e620c547969.tar.bz2 markdown-rs-4806864e5377a5fef937b3fa02542e620c547969.zip |
Add basic support for block quotes
Diffstat (limited to 'tests/block_quote.rs')
-rw-r--r-- | tests/block_quote.rs | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/tests/block_quote.rs b/tests/block_quote.rs new file mode 100644 index 0000000..908c724 --- /dev/null +++ b/tests/block_quote.rs @@ -0,0 +1,188 @@ +extern crate micromark; +use micromark::micromark; + +#[test] +fn block_quote() { + assert_eq!( + micromark("> # a\n> b\n> c"), + "<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>", + "should support block quotes" + ); + + assert_eq!( + micromark("># a\n>b\n> c"), + "<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>", + "should support block quotes w/o space" + ); + + assert_eq!( + micromark(" > # a\n > b\n > c"), + "<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>", + "should support prefixing block quotes w/ spaces" + ); + + assert_eq!( + micromark(" > # a\n > b\n > c"), + "<pre><code>> # a\n> b\n> c\n</code></pre>", + "should not support block quotes w/ 4 spaces" + ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> # a\n> b\nc"), + // "<blockquote>\n<h1>a</h1>\n<p>b\nc</p>\n</blockquote>", + // "should support lazy content lines" + // ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> a\nb\n> c"), + // "<blockquote>\n<p>a\nb\nc</p>\n</blockquote>", + // "should support lazy content lines inside block quotes" + // ); + + assert_eq!( + micromark("> a\n> ---"), + "<blockquote>\n<h2>a</h2>\n</blockquote>", + "should support setext headings underlines in block quotes" + ); + + // To do: block quote (lazy, setext underline) + // assert_eq!( + // micromark("> a\n---"), + // "<blockquote>\n<p>a</p>\n</blockquote>\n<hr />", + // "should not support lazy setext headings underlines in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> - a\n> - b"), + // "<blockquote>\n<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n</blockquote>", + // "should support lists in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> - a\n- b"), + // "<blockquote>\n<ul>\n<li>a</li>\n</ul>\n</blockquote>\n<ul>\n<li>b</li>\n</ul>", + // "should not support lazy lists in block quotes" + // ); + + // To do: block quote (lazy, code (indented)). + // assert_eq!( + // micromark("> a\n b"), + // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<pre><code>b\n</code></pre>", + // "should not support lazy indented code in block quotes" + // ); + + // To do: block quote (lazy, code (fenced)). + // assert_eq!( + // micromark("> ```\na\n```"), + // "<blockquote>\n<pre><code></code></pre>\n</blockquote>\n<p>a</p>\n<pre><code></code></pre>\n", + // "should not support lazy fenced code in block quotes" + // ); + + // To do: list. + // assert_eq!( + // micromark("> a\n - b"), + // "<blockquote>\n<p>a\n- b</p>\n</blockquote>", + // "should not support lazy indented code (or lazy list) in block quotes" + // ); + + assert_eq!( + micromark(">"), + "<blockquote>\n</blockquote>", + "should support empty block quotes (1)" + ); + + assert_eq!( + micromark(">\n> \n> "), + "<blockquote>\n</blockquote>", + "should support empty block quotes (2)" + ); + + assert_eq!( + micromark(">\n> a\n> "), + "<blockquote>\n<p>a</p>\n</blockquote>", + "should support initial or final lazy empty block quote lines" + ); + + assert_eq!( + micromark("> a\n\n> b"), + "<blockquote>\n<p>a</p>\n</blockquote>\n<blockquote>\n<p>b</p>\n</blockquote>", + "should support adjacent block quotes" + ); + + assert_eq!( + micromark("> a\n> b"), + "<blockquote>\n<p>a\nb</p>\n</blockquote>", + "should support a paragraph in a block quote" + ); + + assert_eq!( + micromark("> a\n>\n> b"), + "<blockquote>\n<p>a</p>\n<p>b</p>\n</blockquote>", + "should support adjacent paragraphs in block quotes" + ); + + assert_eq!( + micromark("a\n> b"), + "<p>a</p>\n<blockquote>\n<p>b</p>\n</blockquote>", + "should support interrupting paragraphs w/ block quotes" + ); + + assert_eq!( + micromark("> a\n***\n> b"), + "<blockquote>\n<p>a</p>\n</blockquote>\n<hr />\n<blockquote>\n<p>b</p>\n</blockquote>", + "should support interrupting block quotes w/ thematic breaks" + ); + + // To do: block quote (lazy). + // assert_eq!( + // micromark("> a\nb"), + // "<blockquote>\n<p>a\nb</p>\n</blockquote>", + // "should not support interrupting block quotes w/ paragraphs" + // ); + + assert_eq!( + micromark("> a\n\nb"), + "<blockquote>\n<p>a</p>\n</blockquote>\n<p>b</p>", + "should support interrupting block quotes w/ blank lines" + ); + + assert_eq!( + micromark("> a\n>\nb"), + "<blockquote>\n<p>a</p>\n</blockquote>\n<p>b</p>", + "should not support interrupting a blank line in a block quotes w/ paragraphs" + ); + + // To do: block quote (multi, lazy). + // assert_eq!( + // micromark("> > > a\nb"), + // "<blockquote>\n<blockquote>\n<blockquote>\n<p>a\nb</p>\n</blockquote>\n</blockquote>\n</blockquote>", + // "should not support interrupting many block quotes w/ paragraphs (1)" + // ); + + // To do: block quote (multi, lazy). + // assert_eq!( + // micromark(">>> a\n> b\n>>c"), + // "<blockquote>\n<blockquote>\n<blockquote>\n<p>a\nb\nc</p>\n</blockquote>\n</blockquote>\n</blockquote>", + // "should not support interrupting many block quotes w/ paragraphs (2)" + // ); + + // To do: block quote (some bug). + // assert_eq!( + // micromark("> a\n\n> b"), + // "<blockquote>\n<pre><code>a\n</code></pre>\n</blockquote>\n<blockquote>\n<p>b</p>\n</blockquote>", + // "should support 5 spaces for indented code, not 4" + // ); + + // To do: turning things off. + // assert_eq!( + // micromark("> # a\n> b\n> c", { + // extensions: [{disable: {null: ["blockQuote"]}}] + // }), + // "<p>> # a\n> b\n> c</p>", + // "should support turning off block quotes" + // ); +} |