aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-14 09:35:42 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-14 09:35:42 +0200
commit930630506c6d42250b5fe6b883ac65b2e9ba668b (patch)
tree8eacad920edcd9db6e303ec6c4be67b1d3aae96b
parent6263c957b09eb559d68ce4251bdc94426a3b1b0c (diff)
downloadmarkdown-rs-930630506c6d42250b5fe6b883ac65b2e9ba668b.tar.gz
markdown-rs-930630506c6d42250b5fe6b883ac65b2e9ba668b.tar.bz2
markdown-rs-930630506c6d42250b5fe6b883ac65b2e9ba668b.zip
Add some more tests on mdx and indented code
Diffstat (limited to '')
-rw-r--r--src/lib.rs6
-rw-r--r--tests/mdx_expression_flow.rs18
-rw-r--r--tests/mdx_jsx_flow.rs20
3 files changed, 44 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bc235c3..3e3407a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -493,6 +493,9 @@ pub struct Constructs {
/// ^^^^^^^^^^^^^
/// ```
///
+ /// > πŸ‘‰ **Note**: You *must* pass `html_flow: false` to use this,
+ /// > as it’s preferred when on over `mdx_jsx_flow`.
+ ///
/// > πŸ‘‰ **Note**: You *can* pass
/// > [`mdx_expression_parse`][MdxExpressionParse] in [`ParseOptions`][]
/// > too, to parse expressions in JSX according to a certain grammar
@@ -507,6 +510,9 @@ pub struct Constructs {
/// ^^^^^^^^^^^^^
/// ```
///
+ /// > πŸ‘‰ **Note**: You *must* pass `html_text: false` to use this,
+ /// > as it’s preferred when on over `mdx_jsx_text`.
+ ///
/// > πŸ‘‰ **Note**: You *can* pass
/// > [`mdx_expression_parse`][MdxExpressionParse] in [`ParseOptions`][]
/// > too, to parse expressions in JSX according to a certain grammar
diff --git a/tests/mdx_expression_flow.rs b/tests/mdx_expression_flow.rs
index edb4f71..fe07743 100644
--- a/tests/mdx_expression_flow.rs
+++ b/tests/mdx_expression_flow.rs
@@ -51,6 +51,24 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> {
);
assert_eq!(
+ to_html_with_options(
+ " {}",
+ &Options {
+ parse: ParseOptions {
+ constructs: Constructs {
+ mdx_expression_flow: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
+ },
+ ..Options::default()
+ }
+ )?,
+ "",
+ "should support indented expressions if indented code is 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 `{`",
"should crash if no closing brace is found (1)"
diff --git a/tests/mdx_jsx_flow.rs b/tests/mdx_jsx_flow.rs
index 85abcd3..337b4cd 100644
--- a/tests/mdx_jsx_flow.rs
+++ b/tests/mdx_jsx_flow.rs
@@ -30,6 +30,7 @@ fn mdx_jsx_flow_agnostic() -> Result<(), String> {
&Options {
parse: ParseOptions {
constructs: Constructs {
+ html_flow: false,
mdx_jsx_flow: true,
..Constructs::default()
},
@@ -43,6 +44,25 @@ fn mdx_jsx_flow_agnostic() -> Result<(), String> {
);
assert_eq!(
+ to_html_with_options(
+ " <a />",
+ &Options {
+ parse: ParseOptions {
+ constructs: Constructs {
+ html_flow: false,
+ mdx_jsx_flow: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
+ },
+ ..Options::default()
+ }
+ )?,
+ "",
+ "should support indented jsx if indented code is enabled"
+ );
+
+ assert_eq!(
to_html_with_options("<a></a>", &mdx)?,
"",
"should support a closed element"