fixup! parser: impl link references
This commit is contained in:
parent
6c5fcbf57d
commit
ecf49100f4
2 changed files with 43 additions and 1 deletions
|
@ -730,6 +730,10 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn block_link_definition() {
|
fn block_link_definition() {
|
||||||
test_block!("[tag]: url\n", Block::Leaf(LinkDefinition), "tag", 1);
|
test_block!("[tag]: url\n", Block::Leaf(LinkDefinition), "tag", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn block_link_definition_multiline() {
|
||||||
test_block!(
|
test_block!(
|
||||||
concat!(
|
concat!(
|
||||||
"[tag]: uuu\n",
|
"[tag]: uuu\n",
|
||||||
|
|
40
src/lib.rs
40
src/lib.rs
|
@ -285,7 +285,7 @@ impl<'s> Parser<'s> {
|
||||||
{
|
{
|
||||||
let tag = e.span.of(src);
|
let tag = e.span.of(src);
|
||||||
// TODO borrow url string if single inline
|
// 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);
|
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]
|
#[test]
|
||||||
fn attr_block() {
|
fn attr_block() {
|
||||||
test_parse!(
|
test_parse!(
|
||||||
|
|
Loading…
Reference in a new issue