aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/label_end.rs2
-rw-r--r--tests/link_resource.rs24
2 files changed, 24 insertions, 2 deletions
diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs
index c7cca66..8898b88 100644
--- a/src/construct/label_end.rs
+++ b/src/construct/label_end.rs
@@ -752,7 +752,7 @@ fn inject_labels(tokenizer: &mut Tokenizer, labels: &[Label]) {
// Though: if this was what looked like a footnote, but didn’t match,
// it’s a link instead, and we need to inject the `^`.
if label.start.1 != label.end.0 || !caret.is_empty() {
- tokenizer.map.add(
+ tokenizer.map.add_before(
label.start.1 + 1,
0,
vec![Event {
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(())
}