aboutsummaryrefslogtreecommitdiffstats
path: root/tests/link_resource.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-09-26 16:12:25 +0200
commita0c84c505d733be2e987a333a34244c1befb56cb (patch)
tree0545a747b6f2f627a71bd31949ad622bbc56c176 /tests/link_resource.rs
parent9cb9e37c33173c16cbafd345f43e43b5a550537d (diff)
downloadmarkdown-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_resource.rs')
-rw-r--r--tests/link_resource.rs51
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/link_resource.rs b/tests/link_resource.rs
index 6bcbb8c..a296410 100644
--- a/tests/link_resource.rs
+++ b/tests/link_resource.rs
@@ -1,5 +1,8 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Options};
+use micromark::{
+ mdast::{Link, Node, Paragraph, Position, Root, Text},
+ micromark, micromark_to_mdast, micromark_with_options, Options,
+};
use pretty_assertions::assert_eq;
#[test]
@@ -458,5 +461,51 @@ fn link_resource() -> Result<(), String> {
"should support a single NUL character as a link resource"
);
+ assert_eq!(
+ micromark_to_mdast(
+ "a [alpha]() b [bravo](charlie 'delta') c.",
+ &Options::default()
+ )?,
+ Node::Root(Root {
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![
+ Node::Text(Text {
+ value: "a ".to_string(),
+ position: Some(Position::new(1, 1, 0, 1, 3, 2))
+ }),
+ Node::Link(Link {
+ url: String::new(),
+ title: None,
+ children: vec![Node::Text(Text {
+ value: "alpha".to_string(),
+ position: Some(Position::new(1, 4, 3, 1, 9, 8))
+ }),],
+ position: Some(Position::new(1, 3, 2, 1, 12, 11))
+ }),
+ Node::Text(Text {
+ value: " b ".to_string(),
+ position: Some(Position::new(1, 12, 11, 1, 15, 14))
+ }),
+ Node::Link(Link {
+ url: "charlie".to_string(),
+ title: Some("delta".to_string()),
+ children: vec![Node::Text(Text {
+ value: "bravo".to_string(),
+ position: Some(Position::new(1, 16, 15, 1, 21, 20))
+ }),],
+ position: Some(Position::new(1, 15, 14, 1, 39, 38))
+ }),
+ Node::Text(Text {
+ value: " c.".to_string(),
+ position: Some(Position::new(1, 39, 38, 1, 42, 41))
+ })
+ ],
+ position: Some(Position::new(1, 1, 0, 1, 42, 41))
+ })],
+ position: Some(Position::new(1, 1, 0, 1, 42, 41))
+ }),
+ "should support link (resource) as `Link`s in mdast"
+ );
+
Ok(())
}