Replaced toLink function with one that recognises {@link url text} or {@link url} tags. Previous implementation didn't appear to resolve links

This commit is contained in:
Rotorz Limited 2011-08-30 21:50:27 +02:00
parent 90ac234799
commit 3df288bcd2

View File

@ -66,9 +66,24 @@ function toLink(longname, content) {
if (!longname) {
throw new Error('Missing required parameter: url');
}
content = content || longname;
var url = linkMap.longnameToUrl[longname];
// Has link been specified manually?
var url;
if (/^(http|ftp)s?:/.test(longname)) {
url = longname;
// Has link text been specified {@link http://github.com GitHub Website}
var split = url.indexOf(' ');
if (split !== -1) {
content = url.substr(split + 1);
url = url.substr(0, split);
}
}
else {
url = linkMap.longnameToUrl[longname];
}
content = content || longname;
if (!url) {
return content;