Link reference definitions woes

The specification talks a bit what can or cannot come before a link reference definition, but less about what can come after.

For example I fail to understand this rendering:

[foo]: /ha 

which is (and consistently with cmark and md2html):


I would have expected an indented code block to be rendered. Similarly this rendering:

[foo]: /ha

Yields in the dingus:

<hr />

I would have expected a simple <hr />. Also both cmark and md2html render this as:


(my impression is the cmark and md2html’s behaviour is an artefact of their implementations, which is to gather a paragraph, peel any initial sequence of link reference definitions and treat the remains as a paragraph).

So what are the rules that govern the behaviour for what comes after a link reference definition ?

Yes, you’re right, these things are a result of an implementation shortcut:

I agree that the spec doesn’t define this precisely enough. The cmark behavior is to treat the following lines as they’d be treated if parsed as continuation lines in a paragraph. So e.g.

% cmark
 1. blah


% cmark
[foo]: ha
 2. blah
<p>2. blah</p>

(Remember that only ordered lists starting with 1 can interrupt a paragraph.)

Similarly in

[foo]: /ha

we don’t have a code block for the same reason that we don’t in


I think this is reasonable behavior and maybe it should be enshrined in the spec. But comments welcome. The empty <p> in the JavaScript implementation can be regarded as a bug.

Thanks for our answers.

Apparently there’s already an issue filed for it.

I have a conflict of interest in being for this so I’ll refrain from commenting :–) but I think it would be nice if there was a common behaviour for parsers on these (likely) corner cases.

P.S. I forgot to add the spec tag when I posted this other topic but it is also a request for clarification of the spec. If you have time to have a look at it that would be great.