aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 11:43:26 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-06 11:43:26 +0200
commitb75d7976cfe8db43783b930c1f4774f2ad4936f5 (patch)
treed8c38c5bc6d1427b408d0b6b53aeb33f39e8d704 /tests
parentc12c31e1b2d55fa407217c0e14c51c8693f919ae (diff)
downloadmarkdown-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.rs91
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='&nbsp; &amp; &copy; &AElig; &Dcaron; &frac34; &HilbertSpace; &DifferentialD; &ClockwiseContourIntegral; &ngE;' />.", &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} & © Æ &Dcaron; ¾ &HilbertSpace; &DifferentialD; &ClockwiseContourIntegral; &ngE;".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='&#35; &#1234; &#992; &#0;' c='&#X22; &#XD06; &#xcab;' />.",
+ &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='&nbsp &x; &#; &#x; &#987654321; &#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("&nbsp &x; &#; &#x; &#987654321; &#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(),