1,105,534 Community Members

Request to improve the URL handling functionality

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

Hello,

I'm mostly active in the Java forums these days, and often I find the desire to link to a method in the Java API, but the markdown syntax doesn't seem to handle the URL format quite well.

Here's an example of a URL that I was recently trying to link to:

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...)

I guess you can easily notice that it breaks a valid URL.

Member Avatar
Dani
The Queen of DaniWeb
20,573 posts since Feb 2002
Reputation Points: 1,356 [?]
Q&As Helped to Solve: 931 [?]
Skill Endorsements: 204 [?]
Administrator
Featured
Sponsor
 
0
 
Member Avatar
Dani
The Queen of DaniWeb
20,573 posts since Feb 2002
Reputation Points: 1,356 [?]
Q&As Helped to Solve: 931 [?]
Skill Endorsements: 204 [?]
Administrator
Featured
Sponsor
 
1
 

Here's how you do that:

[Click here](http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...))

OR

[http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...)](http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...))

OR

Click the 'Link' button in the editor toolbar or hit Ctrl+L to insert a link.

All three ways should work.

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

Thank you, problem solved :)

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

I've reopened this question because of another issue that I'm facing.

In this post the URL doesn't get rendered correctly. I checked using a different browser with cleared cache.

I wrote the text "Math.pow", selected it, clicked the Link button, and pasted there the copied URL:
http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#pow(double, double).

Result:
[Math.pow](http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#pow(double, double))

Also it feels unpleasant that a URL gets URLified when marked as inline code.

I use Pale Moon 15.4.1-x64 and Chrome 24.0.1312.57 m.

Member Avatar
Dani
The Queen of DaniWeb
20,573 posts since Feb 2002
Reputation Points: 1,356 [?]
Q&As Helped to Solve: 931 [?]
Skill Endorsements: 204 [?]
Administrator
Featured
Sponsor
 
0
 

Test: Math.pow

Member Avatar
Dani
The Queen of DaniWeb
20,573 posts since Feb 2002
Reputation Points: 1,356 [?]
Q&As Helped to Solve: 931 [?]
Skill Endorsements: 204 [?]
Administrator
Featured
Sponsor
 
1
 

The issue is that your link cannot have a space within it.

Convert spaces to %20 as so:

Math.pow

It is by design that URLs get URLified within code. It's a common occurrence that code includes a comment with a link to its author, etc. Because it doesn't make sense to allow markup within code, since code should be literal, I chose to auto-linkify all links within code.

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

Convert spaces to %20 as so

That fixes it. Thank you :)

It is by design that URLs get URLified within code.

However this post first inline code box doesn't URLify the whole link. As you can see the '(T...)' part is not URLified. How is that done then?
Also that makes me wonder why a valid URL such as
'http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#pow(double,%20double)'
or
'http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...)'
doesn't get URLified as a whole automatically?

Member Avatar
~s.o.s~
Failure as a human
10,399 posts since Jun 2006
Reputation Points: 2,496 [?]
Q&As Helped to Solve: 992 [?]
Skill Endorsements: 72 [?]
Administrator
Featured
 
0
 

The problem is with closing parentheses. Just escape the closing parentheses by leading it with backslash character and it should work out fine. For e.g.

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...) [without backslash]

v/s

http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#asList(T...) [with backslash before the )]

EDIT: It seems like there is a bug in the MD renderer. The preview shows the complete URLfied URL for the second case but after a submit it disappears.

Member Avatar
Dani
The Queen of DaniWeb
20,573 posts since Feb 2002
Reputation Points: 1,356 [?]
Q&As Helped to Solve: 931 [?]
Skill Endorsements: 204 [?]
Administrator
Featured
Sponsor
 
0
 

It's possible there is a bug in the live-preview. :( Will check into that ...

The auto-linkify feature will automatically quit at the sight of parentheses (Because it makes sense for people to naturally type naked links in parentheses like this: http://www.daniweb.com).

However, the explicity linkify feature will linkify everything (including parens) up until the first non-URL compliant character that it sees (such as a space).

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article