aboutsummaryrefslogtreecommitdiffstats
path: root/tests/link_reference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/link_reference.rs')
-rw-r--r--tests/link_reference.rs73
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(())
}