10

Consider the following text

<code>[Collections#sort][1]</code>

[1]: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List, java.util.Comparator)

It does render correctly on preview, but incorrectly once saved. See Sorting and Re-arranging List of HashMaps for this example in real life

3

2 Answers 2

8

The problem is the space which breaks the URL. Try the url encoded one like:
sort(java.util.List%2C+java.util.Comparator)
instead of
sort(java.util.List, java.util.Comparator)

You can also use backticks ` for inline codes.

E.g.:

Notice that, if you want to change sort algorithm during list usage, you can instead use Collections#sort.

Source:

Notice that, if you want to change sort algorithm during list usage, 
you can instead use [`Collections#sort`][1].

[1]: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List%2C+java.util.Comparator)
5
  • 2
    Oh, indeed, encoding the space to %20 did the trick!
    – fretje
    Mar 16, 2010 at 15:35
  • @fretje, yea the 'evil' spaces...
    – o.k.w
    Mar 16, 2010 at 15:38
  • 1
    @o.k.w:whoneedsthemanyway?
    – fretje
    Mar 16, 2010 at 15:40
  • Wow, thanks for the reply and the fix in my answer (didn't even know you could do that !)
    – Riduidel
    Mar 16, 2010 at 15:55
  • @Riduidel: see the bottom part of the faq (stackoverflow.com/faq): Other people can edit my stuff?! Like Wikipedia, this site is collaboratively edited, and all edits are tracked. If you are not comfortable with the idea of your posts being edited by other trusted users, this may not be the site for you.
    – fretje
    Mar 16, 2010 at 16:37
1

As of recently, when entering a link via the button (or Ctrl-L), the characters will automatically be escaped, so this is the safest way.

You must log in to answer this question.

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