-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
link text containing backtick code doesn't work for []::()
#1209
Comments
What is interesting about this is that it only fails when it is the only thing in a paragraph. Adding any other text, before or after the link, it then parses fine. |
I found a bunch of examples of this bug in the "This Week in Rust" repository, which has a lot of unordered lists containing only links, so the link is the only thing in the enclosing tag (an |
I noticed another example, where there are no parentheses:
|
This is a weird issue for sure, and I doubt it is something as simple as the link pattern needs improvement because it does work, depending on unrelated context. I suspect that something else is causing the content to get dropped, but it will require a deep dive to debug what is going on. |
Well, I know what is causing the issue now, I'm just not sure how to fix it yet. The block processor called I'll have to try and figure out how we can work around this. I probably won't have a solution this weekend, but this is a good starting point as we now have a root cause. |
This is a very specific edge case which requires the internal square brackets, the colon and (optionally) the internal parentheses. Without any one of those specific characters in that specific order, this would not be an issue. For the record, the example (
And the second example (
I should note that between the square brackets of the reference we do not allow a closing square bracket (regex: However, if it is wrong to exclude nested square brackets from references, then I see a few possible workarounds:
Any of those solutions would drastically complicate the regex we use and/or require us to not use a single regex for the entire match. |
Whether square brackets are allowed within references seems to be mixed (see Babelmark). I find the strangest result to be the reference implementation (markdown.pl) which does not recognize the link as pointing to the reference, but it does recognize the reference and remove it from the document. It is clear that there is a bug there, but is the bug with the link or the reference? It is impossible to say for sure. Also of interest is the large number of implementations which error out with this very simple input. It seems that for the most part it is not expected that square brackets be nested inside references. The few implementations which do support it are the ones which already have the reputation of being more forgiving that average. Therefore, I am comfortable excluding the opening square bracket. We already disallow the closing square bracket anyway, so this is consistent with our existing behavior. |
I'm not sure if This Week in Rust is an extreme outlier, but we use code backticks inside link text quite a lot (which often includes square brackets and other interesting characters), and it looks like we've been using them (mostly) successfully since about 2013. Today, it works about 99% of the time (because If we're going to be collateral damage, then I guess that's the way it goes, but I hope you understand that this would be a significant breaking change for us. |
I think you are misunderstanding. The change would apply to the reference pattern, not the link pattern.
We would restrict brackets in the |
Ah, thank you for the clarification! Sorry for my misunderstanding. |
Yes, that is correct. Of note is the fact that reference ids should generally be rather plain. While we do support the shortcut where the id is the link label ( |
We already disallow right square brackets. This also disallows left square brackets, which ensures link references will be less likely to collide with standard links in some weird edge cases. Fixes Python-Markdown#1209.
We already disallow right square brackets. This also disallows left square brackets, which ensures link references will be less likely to collide with standard links in some weird edge cases. Fixes #1209.
I verified that the committed fix works on all of the problematic examples in the TWiR repository. Thank you! |
With Markdown 3.3.6, the following markdown link doesn't render properly (no output is generated):
If I remove the inner right-bracket
]
or the following colon:
, or the open parenthesis(
, then it does render something.commonmark
0.9.1 is able to render this link as expected:The text was updated successfully, but these errors were encountered: