diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mdx_jsx_text.rs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/mdx_jsx_text.rs b/tests/mdx_jsx_text.rs index ea3502f..0a27bb2 100644 --- a/tests/mdx_jsx_text.rs +++ b/tests/mdx_jsx_text.rs @@ -251,6 +251,97 @@ fn mdx_jsx_text_core() -> Result<(), String> { ); assert_eq!( + micromark_to_mdast("<a b=' & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸' />.", &mdx)?, + Node::Root(Root { + children: vec![Node::Paragraph(Paragraph { + children: vec![ + Node::MdxJsxTextElement(MdxJsxTextElement { + name: Some("a".to_string()), + attributes: vec![ + AttributeContent::Property(MdxJsxAttribute { + name: "b".to_string(), + value: Some(AttributeValue::Literal("\u{a0} & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸".into())), + }), + ], + children: vec![], + position: Some(Position::new(1, 1, 0, 1, 120, 119)) + }), + Node::Text(Text { + value: ".".to_string(), + position: Some(Position::new(1, 120, 119, 1, 121, 120)) + }) + ], + position: Some(Position::new(1, 1, 0, 1, 121, 120)) + })], + position: Some(Position::new(1, 1, 0, 1, 121, 120)) + }), + "should support character references (HTML 4, named) in JSX attribute values" + ); + + assert_eq!( + micromark_to_mdast( + "<a b='# Ӓ Ϡ �' c='" ആ ಫ' />.", + &mdx + )?, + Node::Root(Root { + children: vec![Node::Paragraph(Paragraph { + children: vec![ + Node::MdxJsxTextElement(MdxJsxTextElement { + name: Some("a".to_string()), + attributes: vec![ + AttributeContent::Property(MdxJsxAttribute { + name: "b".to_string(), + value: Some(AttributeValue::Literal("# Ӓ Ϡ �".into())), + }), + AttributeContent::Property(MdxJsxAttribute { + name: "c".to_string(), + value: Some(AttributeValue::Literal("\" ആ ಫ".into())), + }), + ], + children: vec![], + position: Some(Position::new(1, 1, 0, 1, 63, 62)) + }), + Node::Text(Text { + value: ".".to_string(), + position: Some(Position::new(1, 63, 62, 1, 64, 63)) + }) + ], + position: Some(Position::new(1, 1, 0, 1, 64, 63)) + })], + position: Some(Position::new(1, 1, 0, 1, 64, 63)) + }), + "should support character references (numeric) in JSX attribute values" + ); + + assert_eq!( + micromark_to_mdast("<a b='  &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?;' />.", &mdx)?, + Node::Root(Root { + children: vec![Node::Paragraph(Paragraph { + children: vec![ + Node::MdxJsxTextElement(MdxJsxTextElement { + name: Some("a".to_string()), + attributes: vec![ + AttributeContent::Property(MdxJsxAttribute { + name: "b".to_string(), + value: Some(AttributeValue::Literal("  &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?;".into())), + }) + ], + children: vec![], + position: Some(Position::new(1, 1, 0, 1, 78, 77)) + }), + Node::Text(Text { + value: ".".to_string(), + position: Some(Position::new(1, 78, 77, 1, 79, 78)) + }) + ], + position: Some(Position::new(1, 1, 0, 1, 79, 78)) + })], + position: Some(Position::new(1, 1, 0, 1, 79, 78)) + }), + "should not support things that look like character references but aren’t" + ); + + assert_eq!( micromark_to_mdast("a </b> c", &mdx) .err() .unwrap(), |