Skip to content
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

Parsing of underscores in URLs #670

Closed
habi opened this issue Nov 26, 2020 · 7 comments
Closed

Parsing of underscores in URLs #670

habi opened this issue Nov 26, 2020 · 7 comments

Comments

@habi
Copy link

habi commented Nov 26, 2020

Today I learned that Element.io uses Commonmark.

And I was shared a link to a room, namely https://app.element.io/#/room/#_oftc_#osm-ch:matrix.org

Commonmark parses this as Screenshot 2020-11-26 at 22 48 04 and breaks the URL into two pieces.
These two pieces can be copy-pasted to a browser, but then don't link to the correct place anymore.

I think that underscores in URLs should not be parsed, like GFM does not and keep the URL intact.

@wooorm
Copy link
Contributor

wooorm commented Nov 26, 2020

CommonMark doesn't support just a url. GFM does. So, this sounds more like a problem with GFM? It's not a lot of info to go on to debug your problem...

@habi
Copy link
Author

habi commented Nov 26, 2020

When I paste the link on https://spec.commonmark.org/dingus/ 'oftc' is rendered italic. It's also italic when I'm sent the link in Element and breaks the URL into two pieces. I can copy the link from the rendered view, but the it is wrong because the two underscores are not in the pasted URL anymore.

@habi
Copy link
Author

habi commented Nov 26, 2020

So, this sounds more like a problem with GFM?

No, GFM keeps the link intact by not rendering 'oftc' italic in an URL when between two underscores.

@Crissov
Copy link
Contributor

Crissov commented Nov 27, 2020

CommonMark does not support “autolinks” directly, but GFM and other implementations include an extension that parses raw URLs into links. In vanilla CM you world have to enclose an URL with angular brackets to have it recognized. No markup inside of the address will be applied then:

<https://app.element.io/#/room/#_oftc_#osm-ch:matrix.org>
<https://app.element.io/#/room/%23_oftc_%23osm-ch:matrix.org>

@jgm
Copy link
Member

jgm commented Nov 27, 2020

Or, if you don't want it to be a hyperlink, use code backticks

`https://app.element.io/#/room/#_oftc_#osm-ch:matrix.org`

@jgm jgm closed this as completed Nov 27, 2020
@habi
Copy link
Author

habi commented Nov 27, 2020

I know that I can use either backticks or angular brackets, but the user that sends me the link might not, breaking the link for me.

Does that mean that Element.io implements the ComomMark specs wrongly, because the URL that is sent to me is autolinked (and broken up in the process)?

@Crissov
Copy link
Contributor

Crissov commented Nov 27, 2020

It means that Element.io implements a superset of CommonMark and the problem lies weiterhin their extension (which happens to be a common one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants