Links with underbars surrounded by hyphens render incorrectly

I’m not sure if this is a commonmark issue, a markdown-it issue, or a Discourse issue, but when sharing the link in this post, I noticed this edge case with the automatic link detection where the sequence -_foo_- breaks it.

This was the original link:

https://blog.acolyer.org/2018/06/28/how-_not_-to-structure-your-database-backed-web-applications-a-study-of-performance-bugs-in-the-wild/

Here’s a simplified example:

https://example.org/foo-_bar_-baz

And rendered:

https://example.org/foo-bar-baz

(And as an image for good measure):

link-detection-issue-edge-case


As a workaround, to make a link like this go to the right destination, you can always just use a real markdown link like so:

[foo _bar_ baz](https://example.org/foo-_bar_-baz)

foo bar baz

2 Likes

This was already opened in the context of a Twitter user with similar character patterns in username, rendering linking to that twitter profile very difficult.

2 Likes

Known issue with commonmark, we can continue discussion here: