djot-0.1.4: test/links_and_images.test
```
[basic _link_][a_b_]
[a_b_]: url
.
<p><a href="url">basic <em>link</em></a></p>
```
```
![basic _image_][a_b_]
[a_b_]: url
.
<p><img alt="basic image" src="url"></p>
```
```
[link][]
[link]: url
.
<p><a href="url">link</a></p>
```
```
[link][]
[link]:
url
.
<p><a href="url">link</a></p>
```
The URL can be split over multiple lines:
```
[link][]
[link]:
url
andurl
.
<p><a href="urlandurl">link</a></p>
```
```
[link](url
andurl)
.
<p><a href="urlandurl">link</a></p>
```
```
[link][]
[link]:
[link2]: url
.
<p><a href="">link</a></p>
```
```
[link][]
[link][link2]
[link2]:
url2
[link]:
url
.
<p><a href="url">link</a>
<a href="url2">link</a></p>
```
```
[link][a and
b]
[a and b]: url
.
<p><a href="url">link</a></p>
```
If the reference isn't found, we get an empty link.
```
[link][a and
b]
.
<p><a>link</a></p>
```
Reference definitions can't have line breaks in the key:
```
[link][a and
b]
[a and
b]: url
.
<p><a>link</a></p>
<p>[a and
b]: url</p>
```
No case normalization is done on reference definitions:
```
[Link][]
[link]: /url
.
<p><a>Link</a></p>
```
Attributes on reference definitions get transferred to
the link:
```
{title=foo}
[ref]: /url
[ref][]
.
<p><a href="/url" title="foo">ref</a></p>
```
Attributes on the link override those on references:
```
{title=foo}
[ref]: /url
[ref][]{title=bar}
.
<p><a href="/url" title="bar">ref</a></p>
```
```
[link _and_ link][]
[link and link]: url
.
<p><a href="url">link <em>and</em> link</a></p>
```
```

.
<p><img alt="basic image" src="url"></p>
```
```
[](url)
.
<p><a href="url"><img alt="image" src="img.jpg"></a></p>
```
```
[unclosed](hello *a
b*
.
<p>[unclosed](hello <strong>a
b</strong></p>
```
Note that soft breaks are ignored, so long URLs
can be split over multiple lines:
```
[closed](hello *a
b*)
.
<p><a href="hello *ab*">closed</a></p>
```
Here the link takes precedence because the star inside the
destination is protected from closing emphasis:
```
*[closed](hello*)
.
<p>*<a href="hello*">closed</a></p>
```
This also works with a backslash escape:
```
*[closed](hello\*)
.
<p>*<a href="hello*">closed</a></p>
```
Underscores in link destinations don't interfere with emphasis:
```
_[link](http://example.com?foo_bar=1), more text_
.
<p><em><a href="http://example.com?foo_bar=1">link</a>, more text</em></p>
```
```
_hello [link](a_b) world_
.
<p><em>hello <a href="a_b">link</a> world</em></p>
```
Link in link?
```
[[foo](bar)](baz)
.
<p><a href="baz"><a href="bar">foo</a></a></p>
```
Link in image?
```
](img)
.
<p><img alt="link" src="img"></p>
```
Image in link?
```
[](url)
.
<p><a href="url"><img alt="image" src="img"></a></p>
```
Autolinks:
```
<http://example.com/foo>
<me@example.com>
.
<p><a href="http://example.com/foo">http://example.com/foo</a>
<a href="mailto:me@example.com">me@example.com</a></p>
```
Openers inside `[..](` or `[..][` or `[..]{` can't match
outside them, even if the construction doesn't turn out to be
a link or span or image.
```
[x_y](x_y)
.
<p><a href="x_y">x_y</a></p>
```
```
[x_y](x_
.
<p>[x_y](x_</p>
```
```
[x_y]{.bar_}
.
<p><span class="bar_">x_y</span></p>
```