commonmark-spec
commonmark-spec copied to clipboard
Remove restriction of balanced parens in definition destination
For links, balanced parens are useful: [a](b(c)), although it imposes a potential performance problem due to having to track that balance (Implementations may impose limits on parentheses nesting to avoid performance issues, but at least three levels of nesting should be supported. (link))
For definitions, having to track balance adds nothing useful for vendors or authors. Rather, it imposes potential performance problems for vendors or unexpected results for authors.
[x]: a(b
[y]: a)b
[x] [y].
Yields:
<p>[x]: a(b
[y]: a)b</p>
<p>[x] [y].</p>
Expected:
<p><a href="a(b">x</a> <a href="a)b">y</a>.</p>
For a solution in the spec, I suggest either explicitly lifting the restriction for Link reference definitions, or lifting it in the Link destination and enforcing it in Links
[EDIT: whoops, slightly different issue. Leaving it here as the notification has been sent out already. Sorry!]
Here’s an example where a user tried linking an image / image reference, but it didn’t work due to this restriction.
Does not currently work (but I think it should; image):
[][]
[]: about:blank
Does work currently:
[][]
[!\[alt\](image_url)]: about:blank
Does not currently work (but I think it should; image reference):
[![alt][image]][]
[image]: about:blank
[![alt][image]]: about:blank
Does work currently:
[![alt][image]][]
[image]: about:blank
[!\[alt\]\[image\]]: about:blank
I'm not sure. You're right that we don't need to care about balance in the definitions. On the other hand, I think there's some value in having things work the same way in both places (simpler mental model). Curious what others think.