# Hard Line Breaks and Link Reference Definitions

**URL:** <https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755>\
**Category:** Spec\
**Created:** [January 20, 2021, 4:14am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755 "2021-01-20T04:14:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackdw](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/51bf81/32.png) [@jackdw](https://talk.commonmark.org/u/jackdw)\
**Post date:** [January 20, 2021, 4:14am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/1 "2021-01-20T04:14:02Z")

</div>

Just to be clear with anyone that is seeing me post “how about this Markdown” posts. I am writing a Markdown linter and getting around to most of my corner cases. While 99.5% of the scenarios that I come up with parse fine, the ones I ask about here are ones that I am trying to figure out the “right” thing to do.

So, going through and validating another round of tests, and came across this pair of tests.

```auto
[  
foo]: /uri

[  
foo]

```

(note the two space characters after the open and before the newline) which parses to:

```auto
<p><a href="/uri"><br />
foo</a></p>

```

However, if instead of the two spaces I use a single backslash:

```auto
[\
foo]: /uri

[\
foo]

```

I get:

```auto
<p>[<br />
foo]: /uri</p>
<p>[<br />
foo]</p>

```

Now, based on conversations in [this topic](https://talk.commonmark.org/t/block-quotes-laziness-and-link-reference-definitions/3751), I believe it would be correct to say that reference parser tries to handle this as the first part of a paragraph. It’s just a guess, but I would think that it has an issue with a single backslash and aborts the Link Reference Definition?

Curious as to what causes this behavior.

---

<div class="post-metadata">

**Author:** ![mity](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/mity/32/1040_2.png) [@mity](https://talk.commonmark.org/u/mity)\
**Post date:** [January 20, 2021, 8:13am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/2 "2021-01-20T08:13:40Z")

</div>

> [@jackdw](#):
>
> I get:

You get with what implementation? I cannot reproduce. (Tried with cmark and MD4C.)

> [@jackdw](#):
>
> I believe it would be correct to say that reference parser tries to handle this as the first part of a paragraph. It’s just a guess, but I would think that it has an issue with a single backslash and aborts the Link Reference Definition?

I don’t think so: Even if its first parsed as a paragraph, its beginning (in this case all of it) has to be tested whether it satisfies all the rules for the reference definition. I believe it does. Nothing forbids a backslash in the link. ref. def. label. So, it’s ripped from the paragraph and treated as a link ref. def. (before the rest of it is even passed to an inline processing).

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [January 21, 2021, 12:03am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/3 "2021-01-21T00:03:00Z")

</div>

This appears to be a bug in commonmark.js. cmark and  
the other implementations I tried got it right. You can  
submit a bug report on GitHub.

---

<div class="post-metadata">

**Author:** ![jackdw](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/51bf81/32.png) [@jackdw](https://talk.commonmark.org/u/jackdw)\
**Post date:** [January 21, 2021, 5:56am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/4 "2021-01-21T05:56:36Z")

</div>

Sorry about that… posted later in the evening and forgot to include references.

[BabelMark](https://johnmacfarlane.net/babelmark2/?text=%5B%5C%0Afoo%5D%3A+%2Furi%0A%0A%5B%5C%0Afoo%5D) is what I was using to verify the behavior.

I do see MD4C 0.2.7 (both modes) giving:

```auto
<p><a href="/uri"><br>
foo</a></p>

```

which backs up what you see. I see the following parsers returning the information that I quoted:

- commonmark.js 0.29.2
- cheapskate 0.1.0.5
- league/commonmark 1.5.7
- markdig 0.22.0.0

Sorry about that! Let me know if you need any more information.

---

<div class="post-metadata">

**Author:** ![jackdw](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/51bf81/32.png) [@jackdw](https://talk.commonmark.org/u/jackdw)\
**Post date:** [January 22, 2021, 5:45am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/5 "2021-01-22T05:45:06Z")

</div>

@jgm based on the answers I am getting from BabelMark, which projects should I file a bug report to?

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [January 22, 2021, 6:09pm UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/6 "2021-01-22T18:09:51Z")

</div>

> @jgm based on the answers I am getting from BabelMark, which projects should I file a bug report to?

As I said before, commonmark.js. Some of the others you mentioned aren’t even trying to target commonmark (e.g. cheapskate, which is also unmaintained).

---

<div class="post-metadata">

**Author:** ![jackdw](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/51bf81/32.png) [@jackdw](https://talk.commonmark.org/u/jackdw)\
**Post date:** [February 1, 2021, 2:24am UTC](https://talk.commonmark.org/t/hard-line-breaks-and-link-reference-definitions/3755/7 "2021-02-01T02:24:31Z")

</div>

Really busy couple of weeks, but just added as  
[issue 211](https://github.com/commonmark/commonmark.js/issues/211)
