``` [basic _link_][a_b_] [a_b_]: url .

basic link

``` ``` ![basic _image_][a_b_] [a_b_]: url .

basic image

``` ``` [link][] [link]: url .

link

``` ``` [link][] [link]: url .

link

``` The URL can be split over multiple lines: ``` [link][] [link]: url andurl .

link

``` ``` [link](url andurl) .

link

``` ``` [link][] [link]: [link2]: url .

link

``` ``` [link][] [link][link2] [link2]: url2 [link]: url .

link link

``` ``` [link][a and b] [a and b]: url .

link

``` If the reference isn't found, we get an empty link. ``` [link][a and b] .

link

``` Reference definitions can't have line breaks in the key: ``` [link][a and b] [a and b]: url .

link

[a and b]: url

``` No case normalization is done on reference definitions: ``` [Link][] [link]: /url .

Link

``` Attributes on reference definitions get transferred to the link: ``` {title=foo} [ref]: /url [ref][] .

ref

``` Attributes on the link override those on references: ``` {title=foo} [ref]: /url [ref][]{title=bar} .

ref

``` ``` [link _and_ link][] [link _and_ link]: url .

link and link

``` ``` ![basic _image_](url) .

basic image

``` ``` [![image](img.jpg)](url) .

image

``` ``` [unclosed](hello *a b* .

[unclosed](hello a b

``` Note that soft breaks are ignored, so long URLs can be split over multiple lines: ``` [closed](hello *a b*) .

closed

``` Here the strong takes precedence over the link because it starts first: ``` *[closed](hello*) .

[closed](hello)

``` Avoid this with a backslash escape: ``` *[closed](hello\*) .

*closed

``` Link in link? ``` [[foo](bar)](baz) .

foo

``` Link in image? ``` ![[link](url)](img) .

link

``` Image in link? ``` [![image](img)](url) .

image

``` Autolinks: ``` .

http://example.com/foo me@example.com

``` 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) .

x_y

``` ``` [x_y](x_ .

[x_y](x_

``` ``` [x_y]{.bar_} .

x_y

```