29

I just tried to link to a Wikipedia article that uses n dashes in its title and URI: KMP.

Cannot see the link in "KMP" ([KMP](https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm))? Right, me neither. That's because Markdown doesn't recognise
https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm
as a valid link. I had to use the form
https://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm
which luckily is a redirect to the actual page. Of course,
https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
would work as well, but that's not what your browser shows in the address bar either.

I'll assume this is not the only character that doesn't work. If you insist on using them as punctuation marks that delimit URLs in text, please at least allow them […](…) style links.

5
  • 6
    Highly related: meta.stackoverflow.com/questions/252947/… Note: Balpha actually retagged that question from "bug" to "support just a couple days ago, so you're probably better off tagging this as "feature-request" so it shows up as one on their radar. (Considering it reads like you want a change in what they seem to see as by-design markdown behavior.)
    – Kendra
    Commented Jun 25, 2015 at 21:30
  • @Kendra: Thanks for the reference. I understand the url detection of markdown, but I consider it a bug that [KMP](https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm) does not work.
    – Bergi
    Commented Jun 25, 2015 at 21:39
  • Which the OP of the linked post also mentions, Bergi. "Moreover, when used inline like so or as a reference like so, it doesn't get auto-linked at all." So that's already been reported. Once again, your posts reads to me more as requesting it be changed (which would be a feature-request) and if you don't wish to ask for the change in this post but only to report the bug, then this question is a duplicate of the one I linked, as that one already reports the exact problem you wish to report here. (Really, it covers all methods of linking in a question/answer already.)
    – Kendra
    Commented Jun 25, 2015 at 21:42
  • meta.stackexchange.com/questions/34587/…
    – royhowie
    Commented Jun 26, 2015 at 7:35
  • 3
    For that matter, any URL with ( or ) is horrible broken, since Markdown didn't follow the RFC that mandates <> are to be used as URL delimiters ...
    – o11c
    Commented Jun 26, 2015 at 8:05

3 Answers 3

4

This works now. If you edit your question (or look at the live-rendered version), you'll see that "KMP" is a link. Note that you have actually mark it as a link, like you did with [...](...). Free-form link recognition is stricter when trying to guess which parts of the text you probably want to have hyperlinked and still won't handle certain characters in links.

4
  • Nice. If freeform stays stricter, should the stripped-down comment-markdown start supporting <IRI here> syntax? Commented Jul 3, 2015 at 13:53
  • 1
    Hmm, interesting idea. I'll think about it.
    – balpha StaffMod
    Commented Jul 3, 2015 at 13:55
  • Ah, thanks. So your tag edit on this meta question didn't cause a re-render of the post body?
    – Bergi
    Commented Jul 3, 2015 at 14:39
  • @Bergi No, if the post body is unchanged, it won't be rerendered.
    – balpha StaffMod
    Commented Jul 3, 2015 at 14:40
32

but that's not what your browser shows in the address bar either

Yeah, but you're supposed to put in a URL, not whatever your browser shows in the address bar. I wouldn't expect [example.com](example.com) to work either, for instance, as the URL needs to start with http://. The fact that browsers nowadays no longer display the protocol doesn't change the fact that it's still part of the URL.

Similarly, https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm is not a valid URL. https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm is, even if browsers display it differently.

In fact, in Firefox and Chrome, if I visit that page, then even though I see in the address bar, if I go to the address bar and copy the URL, I correctly get %E2%80%93.

I don't think there's really a problem here. Perhaps not all browsers work the same way, but for browsers that don't, I think if your browser doesn't offer you an easy way to obtain the actual URL for a currently opened page, you should treat that as bug in your browser, not (or at least not yet) as something that SO should work around.

4
  • FWIW, my IE11 copying a shortcut using m-dashes yields "%E2%80%93" and also shows the percent form in the address bar.
    – TripeHound
    Commented Jun 26, 2015 at 9:39
  • 7
    Couldn't agree more. An URL is an URL and adding support for linkifying not-URLs as if they were URLs is an incredibly slippery slope. SO is not IE :) Commented Jun 27, 2015 at 19:17
  • "An URL is an URL" is pretty hard to say.
    – bishop
    Commented Jun 28, 2015 at 18:43
  • 2
    @bishop Some people pronounce "URL" as a single syllable, similar to "earl", but with a shorter vowel sound. People who pronounce it as such are correct in saying and writing "an URL". I pronounce it letter by letter, hence "a URL" in my answer. Either is fine, just use whichever form matches the pronunciation you use.
    – user743382
    Commented Jun 28, 2015 at 18:49
22

Basically, this is an internationalization issue in disguise.

Specifically, the issue is whether URLs in Markdown should be parsed as URIs or as IRIs. The difference is that URIs (RFC 3986) can consist only of (a limited subset of) US-ASCII characters; to embed any other kinds of characters in a URI, they must be %-encoded. IRIs (RFC 3987), however, can contain (almost) any Unicode characters (which are automatically encoded by the browser when it sends the HTTP request).

Essentially all browsers support IRIs nowadays (the standard is over 10 years old, after all), so you can use either of the links above in HTML, and they'll work. But Stack Exchange's Markdown parser still lacks IRI support (even though it was written long after IRIs were introduced), so you have to use the ugly percent-encoded version here.

I wish someone would fix that.

Update: Yay! My wish came true!

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .