aboutsummaryrefslogtreecommitdiffstats
path: root/tests/link_resource.rs
diff options
context:
space:
mode:
authorLibravatar Fedor Sheremetyev <sheremetyev@gmail.com>2023-07-10 10:09:58 +0100
committerLibravatar GitHub <noreply@github.com>2023-07-10 11:09:58 +0200
commitddbeb9c9d87b6e938eac09bc0ee4f354c4a552f2 (patch)
tree368dce508a0b6afd3989ddd946f5e2b8cbb87f17 /tests/link_resource.rs
parent24d78c3420980f3e56fc420f8efc7e601b144ee7 (diff)
downloadmarkdown-rs-ddbeb9c9d87b6e938eac09bc0ee4f354c4a552f2.tar.gz
markdown-rs-ddbeb9c9d87b6e938eac09bc0ee4f354c4a552f2.tar.bz2
markdown-rs-ddbeb9c9d87b6e938eac09bc0ee4f354c4a552f2.zip
Fix parsing of nested links
Enter event for `LabelText` should be inserted before existing events at the index in order to have correct nesting. Otherwise nested elements could have Enter event first and that would result in incorrect nesting in the tree when converting to AST. Closes GH-73. Closes GH-50.
Diffstat (limited to '')
-rw-r--r--tests/link_resource.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/link_resource.rs b/tests/link_resource.rs
index 673b19b..a93eb8d 100644
--- a/tests/link_resource.rs
+++ b/tests/link_resource.rs
@@ -1,5 +1,5 @@
use markdown::{
- mdast::{Link, Node, Paragraph, Root, Text},
+ mdast::{Image, Link, Node, Paragraph, Root, Text},
to_html, to_html_with_options, to_mdast,
unist::Position,
CompileOptions, Options,
@@ -511,5 +511,27 @@ fn link_resource() -> Result<(), String> {
"should support link (resource) as `Link`s in mdast"
);
+ assert_eq!(
+ to_mdast("[![name](image)](url)", &Default::default())?,
+ Node::Root(Root {
+ children: vec![Node::Paragraph(Paragraph {
+ children: vec![Node::Link(Link {
+ children: vec![Node::Image(Image {
+ alt: "name".into(),
+ url: "image".into(),
+ title: None,
+ position: Some(Position::new(1, 2, 1, 1, 16, 15)),
+ }),],
+ url: "url".into(),
+ title: None,
+ position: Some(Position::new(1, 1, 0, 1, 22, 21)),
+ }),],
+ position: Some(Position::new(1, 1, 0, 1, 22, 21)),
+ }),],
+ position: Some(Position::new(1, 1, 0, 1, 22, 21))
+ }),
+ "should support nested links in mdast"
+ );
+
Ok(())
}