fixup! parser: impl link references

This commit is contained in:
Noah Hellman 2023-01-17 18:05:34 +01:00
parent 6c5fcbf57d
commit ecf49100f4
2 changed files with 43 additions and 1 deletions

View file

@ -730,6 +730,10 @@ mod test {
#[test]
fn block_link_definition() {
test_block!("[tag]: url\n", Block::Leaf(LinkDefinition), "tag", 1);
}
#[test]
fn block_link_definition_multiline() {
test_block!(
concat!(
"[tag]: uuu\n",

View file

@ -285,7 +285,7 @@ impl<'s> Parser<'s> {
{
let tag = e.span.of(src);
// TODO borrow url string if single inline
let url = tree.inlines().map(|sp| sp.of(src)).collect();
let url = tree.inlines().map(|sp| sp.of(src).trim()).collect();
defs.insert(tag, url);
}
}
@ -691,6 +691,44 @@ mod test {
);
}
#[test]
fn link_reference_multiline() {
test_parse!(
concat!(
"[text][tag]\n",
"\n",
"[tag]: u\n",
" rl\n", //
),
Start(Paragraph, Attributes::new()),
Start(
Link("url".into(), LinkType::Span(SpanLinkType::Reference)),
Attributes::new()
),
Str("text".into()),
End(Link("url".into(), LinkType::Span(SpanLinkType::Reference))),
End(Paragraph),
Atom(Blankline),
);
test_parse!(
concat!(
"[text][tag]\n",
"\n",
"[tag]:\n",
" url\n", //
),
Start(Paragraph, Attributes::new()),
Start(
Link("url".into(), LinkType::Span(SpanLinkType::Reference)),
Attributes::new()
),
Str("text".into()),
End(Link("url".into(), LinkType::Span(SpanLinkType::Reference))),
End(Paragraph),
Atom(Blankline),
);
}
#[test]
fn attr_block() {
test_parse!(