1

This link below contains ( and ) which totally confuses the link system on SO.

http://docs.oracle.com/javase/7/docs/api/java/awt/geom/Rectangle2D.html#intersects(double, double, double, double)

Attempts to use it:

[standard link](http://docs.oracle.com/javase/7/docs/api/java/awt/geom/Rectangle2D.html#intersects(double, double, double, double))

[end of text link][1]

I think it is an absolutely awful link with spaces, brackets and all, but it is valid nonetheless. There should be a way to create a working link to a specific method in javadoc.


faulty link below

[1]: http://docs.oracle.com/javase/7/docs/api/java/awt/geom/Rectangle2D.html#intersects(double, double, double, double)

2
  • Do you know about the Ctrl-L or Command-L keyboard shortcut? That works fine for me.
    – Arjan
    Jan 1, 2014 at 19:43
  • 2
    Sigh, Oracle documentation... Jan 1, 2014 at 20:39

2 Answers 2

7

Technically, this is not a valid URL. Spaces are not a valid character in URLs and must be encoded as %20 (or +, under classical rules).

The Stack Exchange markdown engine applies heuristics to determine the end of a URL; it allows some characters to go unencoded, including balanced parentheses and commas, but doesn't go as far as to allow spaces. I don't think the engine should change to accommodate spaces.

This is arguably the job of your browser. When I copy the URL from the Firefox URL bar to the clipboard, Firefox helpfully copies it as

http://docs.oracle.com/javase/7/docs/api/java/awt/geom/Rectangle2D.html#intersects%28double,%20double,%20double,%20double%29

Chrome, on the other hand, copies

http://docs.oracle.com/javase/7/docs/api/java/awt/geom/Rectangle2D.html#intersects(double, double, double, double)

to the clipboard. You have to either encode the URL manually, or use the hyperlink editor tool (press Ctrl+L or click on the corresponding button in the editor toolbar). This tool performs the necessary conversion (it escapes all special characters).

3
  • The version with + signs only "works" in the sense of going to the right page, but not in the sense of going to the right anchor on the page. At least, that's the behavior on Firefox and Chromium. The version with %20 works right on both. Jan 1, 2014 at 20:36
  • @IlmariKaronen You're right, + isn't supported here. I corrected my answer. Jan 1, 2014 at 20:47
  • Ps. The + encoding is a special convention for HTML form data, and is only valid in the query segment of the URL (and technically only if the application being queried is expecting form data). The standard way to encode a space, which works in all parts of a URL, is %20. Jan 1, 2014 at 20:50
3

Properly encoding the URL would make it work. As stated in this answer by Jeff, you can do the following:

  • Select the anchor text
  • Press Ctrl + L
  • Paste the URL

The markdown editor will do all the necessary encoding for you and it will produce a valid link.

Example link to Java Docs

You must log in to answer this question.

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