First the sentence seems slightly contradictory it says that after a destination there may be optional space, tabs and one endline but then the end of the sentence says that the title must be separated by spaces and tabs, no end line is mentioned. I guess maybe what was meant is:
[âŚ] it should be separated from the link destination by at least one space, tab or line ending.
Second I donât understand how this wording defines the behaviour of example 197. Somehow in that example the âfailureâ to parse the link title results in the whole link reference definition to not being recognized (rather than take the the definition up to the link destination and treat the rest as inline)
But in the following example:
[foo]:
/url
'the
title'
[foo]
The definition gets recognized up to the link destination by both cmark and md2html:
First the sentence seems slightly contradictory it says that after a destination there may be optional space, tabs and one endline but then the end of the sentence says that the title must be separated by spaces and tabs, no end line is mentioned. I guess maybe what was meant is:
[âŚ] it should be separated from the link destination by at least one space, tab or line ending.
You are right that it would be correct to mention the possibility of
a line ending here, but this formulation isnât quite right: you
canât use two newlines, for example. Better to formulate like
the others: âby spaces or tabs (including up to one [line ending]).â
Second I donât understand how this wording defines the behaviour of example 197. Somehow in that example the âfailureâ to parse the link title results in the whole link reference definition to not being recognized (rather than take the the definition up to the link destination and treat the rest as inline)
A reference link definition is a block-level construct, so it
canât be followed directly by inline content. Perhaps we should
make that explicit by saying that after the items mention, and
optional spaces or tabs, there should be a line-ending. I note
that this is left implicit also for some other block-level
elements, e.g. in Setext headings it is not explicitly stated
that the setext underline must be followed by end-of-line and not
other content.
But in the following example:
[foo]:
/url
'the
title'
[foo]
The definition gets recognized up to the link destination by both cmark and md2html:
Yes: the relevant difference is that in this example, the link
destination is followed by end-of-line, and in the previous one,
it is followed by some non-whitespace content.
It could be added yes, but in this case I found it more clear since it has
âŚany number of trailing spaces or tabs
Emphasis is mine. The trailing aspect makes it difficult to think having other content there is allowed. But thereâs no harm in making that more explicit.
Right but had there been no blank line in my example this would have been accepted. So basically the logic is
If the link destination is followed by spaces and tabs not including one line ending. You must parse the rest of the line as a link title. If that fails, the whole thing was not a link reference definition.
If the link destination is followed by spaces and tabs including one line ending. You need to try to parse a link title on the line following the destination, if that succeeds itâs part of the link definition, otherwise you got a link reference definition without a title.
P.S. Tell me if you want me to file an issue for clarification on the spec issue tracker.