Precedence of link title over code span

In the definition of code spans in the latest 0.31.2 spec, it states:

Code span backticks have higher precedence than any other inline constructs except HTML tags and autolinks.

However,

[foo](/ "bar`baz")`

is treated as a link followed by a backtick in dingus, and the backtick between bar and baz does not become a opener of a code span. Apparently, link titles have higher precedence than code spans.
This behavior should be stated in the spec, either in 6.1 Code spans or in the lint title definition.

1 Like

Hello, I agree with your interpretation of the spec and I hope by responding I make it more likely that you get someone’s attention who can fix this. A reference implementation of such a widespread standard should be correct.

I think it would be conceptually cleaner to fix commonmark.js rather than amend the spec, since the amendment would substantially complicate the rule about code span precedence. However, perhaps commonmark.js has been in service with this bug for so long that some users depend on it. I can’t really speak to that myself.

Another interesting case is:


[foo](/`hi)`

which is parsed as a link followed by a backtick.

Have to think a bit more about whether the spec or the implementation should be amended.

Note that such cases are unlikely to appear in normal text.

1 Like