diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 19:02:21 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-13 19:02:21 +0200 |
commit | c790a943ab4cbb5eefa8704f017eb3cf070bf860 (patch) | |
tree | 8276c742d88b26743ba5ea16fa22d61c5d8509c7 /tests | |
parent | 468a028690b380793bcec4bd73d36b3b72158a57 (diff) | |
download | markdown-rs-c790a943ab4cbb5eefa8704f017eb3cf070bf860.tar.gz markdown-rs-c790a943ab4cbb5eefa8704f017eb3cf070bf860.tar.bz2 markdown-rs-c790a943ab4cbb5eefa8704f017eb3cf070bf860.zip |
Add test for mdx and indented code
Diffstat (limited to '')
-rw-r--r-- | tests/mdx_expression_flow.rs | 19 | ||||
-rw-r--r-- | tests/mdx_jsx_flow.rs | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/mdx_expression_flow.rs b/tests/mdx_expression_flow.rs index b181ef7..edb4f71 100644 --- a/tests/mdx_expression_flow.rs +++ b/tests/mdx_expression_flow.rs @@ -31,6 +31,25 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> { "should support an empty expression" ); + // Note: in MDX, indented code is turned off: + assert_eq!( + to_html_with_options( + " {}", + &Options { + parse: ParseOptions { + constructs: Constructs { + mdx_expression_flow: true, + ..Constructs::default() + }, + ..ParseOptions::default() + }, + ..Options::default() + } + )?, + "<pre><code>{}\n</code></pre>", + "should prefer indented code over expressions if it’s enabled" + ); + assert_eq!( to_html_with_options("{a", &mdx).err().unwrap(), "1:3: Unexpected end of file in expression, expected a corresponding closing brace for `{`", diff --git a/tests/mdx_jsx_flow.rs b/tests/mdx_jsx_flow.rs index 031d1fd..b2fdf30 100644 --- a/tests/mdx_jsx_flow.rs +++ b/tests/mdx_jsx_flow.rs @@ -23,6 +23,25 @@ fn mdx_jsx_flow_agnostic() -> Result<(), String> { "should support a self-closing element" ); + // Note: in MDX, indented code is turned off: + assert_eq!( + to_html_with_options( + " <a />", + &Options { + parse: ParseOptions { + constructs: Constructs { + mdx_jsx_flow: true, + ..Constructs::default() + }, + ..ParseOptions::default() + }, + ..Options::default() + } + )?, + "<pre><code><a />\n</code></pre>", + "should prefer indented code over jsx if it’s enabled" + ); + assert_eq!( to_html_with_options("<a></a>", &mdx)?, "", |