diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-09-26 16:12:25 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-09-26 16:12:25 +0200 |
commit | a0c84c505d733be2e987a333a34244c1befb56cb (patch) | |
tree | 0545a747b6f2f627a71bd31949ad622bbc56c176 /tests/link_reference.rs | |
parent | 9cb9e37c33173c16cbafd345f43e43b5a550537d (diff) | |
download | markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.gz markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.tar.bz2 markdown-rs-a0c84c505d733be2e987a333a34244c1befb56cb.zip |
Add support for compiling to mdast
See: <https://github.com/syntax-tree/mdast>.
Diffstat (limited to 'tests/link_reference.rs')
-rw-r--r-- | tests/link_reference.rs | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/tests/link_reference.rs b/tests/link_reference.rs index 9c853f7..d1d6785 100644 --- a/tests/link_reference.rs +++ b/tests/link_reference.rs @@ -1,5 +1,8 @@ extern crate micromark; -use micromark::{micromark, micromark_with_options, Constructs, Options}; +use micromark::{ + mdast::{Definition, LinkReference, Node, Paragraph, Position, ReferenceKind, Root, Text}, + micromark, micromark_to_mdast, micromark_with_options, Constructs, Options, +}; use pretty_assertions::assert_eq; #[test] @@ -414,5 +417,73 @@ fn link_reference() -> Result<(), String> { "should support turning off label end" ); + assert_eq!( + micromark_to_mdast("[x]: y\n\na [x] b [x][] c [d][x] e.", &Options::default())?, + Node::Root(Root { + children: vec![ + Node::Definition(Definition { + identifier: "x".to_string(), + label: Some("x".to_string()), + url: "y".to_string(), + title: None, + position: Some(Position::new(1, 1, 0, 1, 7, 6)) + }), + Node::Paragraph(Paragraph { + children: vec![ + Node::Text(Text { + value: "a ".to_string(), + position: Some(Position::new(3, 1, 8, 3, 3, 10)) + }), + Node::LinkReference(LinkReference { + reference_kind: ReferenceKind::Shortcut, + identifier: "x".to_string(), + label: Some("x".to_string()), + children: vec![Node::Text(Text { + value: "x".to_string(), + position: Some(Position::new(3, 4, 11, 3, 5, 12)) + }),], + position: Some(Position::new(3, 3, 10, 3, 6, 13)) + }), + Node::Text(Text { + value: " b ".to_string(), + position: Some(Position::new(3, 6, 13, 3, 9, 16)) + }), + Node::LinkReference(LinkReference { + reference_kind: ReferenceKind::Collapsed, + identifier: "x".to_string(), + label: Some("x".to_string()), + children: vec![Node::Text(Text { + value: "x".to_string(), + position: Some(Position::new(3, 10, 17, 3, 11, 18)) + }),], + position: Some(Position::new(3, 9, 16, 3, 14, 21)) + }), + Node::Text(Text { + value: " c ".to_string(), + position: Some(Position::new(3, 14, 21, 3, 17, 24)) + }), + Node::LinkReference(LinkReference { + reference_kind: ReferenceKind::Full, + identifier: "x".to_string(), + label: Some("x".to_string()), + children: vec![Node::Text(Text { + value: "d".to_string(), + position: Some(Position::new(3, 18, 25, 3, 19, 26)) + }),], + position: Some(Position::new(3, 17, 24, 3, 23, 30)) + }), + Node::Text(Text { + value: " e.".to_string(), + position: Some(Position::new(3, 23, 30, 3, 26, 33)) + }), + ], + position: Some(Position::new(3, 1, 8, 3, 26, 33)) + }), + ], + position: Some(Position::new(1, 1, 0, 3, 26, 33)) + }), + "should support link (reference) as `LinkReference`s in mdast" + ); + Ok(()) } |