From 4c06c8554c35887f8f5147783953b2b7e7c2327f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 8 Jun 2022 15:52:16 +0200 Subject: . --- tests/code_indented.rs | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/code_indented.rs (limited to 'tests/code_indented.rs') diff --git a/tests/code_indented.rs b/tests/code_indented.rs new file mode 100644 index 0000000..f5926c0 --- /dev/null +++ b/tests/code_indented.rs @@ -0,0 +1,196 @@ +extern crate micromark; +use micromark::micromark; + +#[test] +fn code_indented() { + assert_eq!( + micromark(" a simple\n indented code block"), + "
a simple\n  indented code block\n
", + "should support indented code" + ); + + // To do: list. + // assert_eq!( + // micromark(" - foo\n\n bar"), + // "", + // "should prefer list item content over indented code (1)" + // ); + + // assert_eq!( + // micromark("1. foo\n\n - bar"), + // "
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
", + // "should prefer list item content over indented code (2)" + // ); + + assert_eq!( + micromark(" \n *hi*\n\n - one"), + "
<a/>\n*hi*\n\n- one\n
", + "should support blank lines in indented code (1)" + ); + + assert_eq!( + micromark(" chunk1\n\n chunk2\n \n \n \n chunk3"), + "
chunk1\n\nchunk2\n\n\n\nchunk3\n
", + "should support blank lines in indented code (2)" + ); + + assert_eq!( + micromark(" chunk1\n \n chunk2"), + "
chunk1\n  \n  chunk2\n
", + "should support blank lines in indented code (3)" + ); + + // To do: paragraphs. + // assert_eq!( + // micromark("Foo\n bar"), + // "

Foo\nbar

", + // "should not support interrupting paragraphs" + // ); + + // To do: paragraphs. + // assert_eq!( + // micromark(" foo\nbar"), + // "
foo\n
\n

bar

", + // "should support paragraphs directly after indented code" + // ); + + // To do: setext. + // assert_eq!( + // micromark("# Heading\n foo\nHeading\n------\n foo\n----"), + // "

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
", + // "should mix w/ other content" + // ); + + assert_eq!( + micromark(" foo\n bar"), + "
    foo\nbar\n
", + "should support extra whitespace on the first line" + ); + + assert_eq!( + micromark("\n \n foo\n "), + "
foo\n
", + "should not support initial blank lines" + ); + + assert_eq!( + micromark(" foo "), + "
foo  \n
", + "should support trailing whitespace" + ); + + // To do: blockquote. + // assert_eq!( + // micromark("> a\nb"), + // "
\n
a\n
\n
\n

b

", + // "should not support lazyness (1)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (2)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (3)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n

a\nb

\n
", + // "should not support lazyness (4)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
b\n
", + // "should not support lazyness (5)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
 b\n
", + // "should not support lazyness (6)" + // ); + + // assert_eq!( + // micromark("> a\n b"), + // "
\n
a\n
\n
\n
  b\n
", + // "should not support lazyness (7)" + // ); + + // To do: extensions. + // assert_eq!( + // micromark(" a", {extensions: [{disable: {null: ["codeIndented"]}}]}), + // "

a

", + // "should support turning off code (indented, 1)" + // ); + + // assert_eq!( + // micromark("> a\n b", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "
\n

a\nb

\n
", + // "should support turning off code (indented, 2)" + // ); + + // assert_eq!( + // micromark("- a\n b", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "", + // "should support turning off code (indented, 3)" + // ); + + // assert_eq!( + // micromark("- a\n - b", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "", + // "should support turning off code (indented, 4)" + // ); + + // assert_eq!( + // micromark("- a\n - b", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "", + // "should support turning off code (indented, 5)" + // ); + + // assert_eq!( + // micromark("```\na\n ```", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "
a\n
", + // "should support turning off code (indented, 6)" + // ); + + // assert_eq!( + // micromark("a ", { + // allowDangerousHtml: true, + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "

a

", + // "should support turning off code (indented, 7)" + // ); + + // assert_eq!( + // micromark("- Foo\n---", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "\n
", + // "should support turning off code (indented, 8)" + // ); + + // assert_eq!( + // micromark("- Foo\n ---", { + // extensions: [{disable: {null: ["codeIndented"]}}] + // }), + // "", + // "should support turning off code (indented, 9)" + // ); +} -- cgit