summary
remark-parse is currently pretty lenient about whitespace within links, more so than either GitHub or commonmark. Here is an example of text that I would not expect to become a link, yet currently does:
[display text] (https://example.com)
In remark-parse, the (https://example.com) text would be considered the address of the link, even though there is a space between the two parts.
Is this intended? It feels like a bug. In particular this has been frustrating to me in its integrations with prettier, where I often am writing markdown intended for GitHub and the whitespace between the two parts is automatically stripped.
If y'all consider this a bug, I'd be happy to submit a PR to fix it!
@samouri are you seeing this even when the option commonmark is set to true?
commonmark doesn't seem to have an effect on this. The pedantic options does net the behavior I'd expect (separating the text and link)
Reason for that is that GH used to support the space, but “pedantic” didn’t.
If you’re willing to work on the problem, we would accept PRs with a fix.
It’s also something that would go in https://github.com/remarkjs/remark/issues/439!
What is the usual protocol for informing downstream folks of this change?
@samouri How do you mean? What are you worrying/wondering about?
I know that prettier is dependent on this package. This will mean a different behavior when applying prettier to markdown files with this edgecase.
I think it's a good change, but I figure any change at all could be disruptive for dependents (e.g. if they have some unit tests that start failing).
This is arguable* a breaking change, yes. Whether a release is breaking is signalled through semver.
* arguable because, if someone before wrote [a] (b), and prettier formatted it as [a](b), and we now stop supporting the earlier. Everything’s pretty fine 🤷♂️
But indeed, remark-parse is used by millions of users, and we don’t want to break their flow. We’re generally on the safe side with releases.
Thank you for the explanation! Makes sense 👍
Most helpful comment
Thank you for the explanation! Makes sense 👍