diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-06 11:43:26 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-06 11:43:26 +0200 |
commit | b75d7976cfe8db43783b930c1f4774f2ad4936f5 (patch) | |
tree | d8c38c5bc6d1427b408d0b6b53aeb33f39e8d704 /tests | |
parent | c12c31e1b2d55fa407217c0e14c51c8693f919ae (diff) | |
download | markdown-rs-b75d7976cfe8db43783b930c1f4774f2ad4936f5.tar.gz markdown-rs-b75d7976cfe8db43783b930c1f4774f2ad4936f5.tar.bz2 markdown-rs-b75d7976cfe8db43783b930c1f4774f2ad4936f5.zip |
Add support for HTML 4 character references in JSX attributes
Diffstat (limited to '')
-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(), |