mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
might as well turn the URL into a link (#371)
This commit is contained in:
parent
306046ce0e
commit
016ee85362
@ -144,13 +144,16 @@ var linkto = exports.linkto = function(longname, linktext, cssClass) {
|
||||
// handle cases like:
|
||||
// @see <http://example.org>
|
||||
// @see http://example.org
|
||||
var stripped = text.replace(/^<|>$/g, '');
|
||||
var stripped = longname && longname.replace(/^<|>$/g, '');
|
||||
if ( hasUrlPrefix(stripped) ) {
|
||||
return stripped;
|
||||
url = stripped;
|
||||
// remove the angle brackets from the link text if necessary
|
||||
if (longname === text) {
|
||||
text = stripped;
|
||||
}
|
||||
}
|
||||
|
||||
// handle complex type expressions that may require multiple links
|
||||
if (longname && longname.search(/[<{(]/) !== -1) {
|
||||
else if (longname && longname.search(/[<{(]/) !== -1) {
|
||||
parsedType = parseType(longname);
|
||||
return catharsis.stringify(parsedType, {
|
||||
cssClass: cssClass,
|
||||
|
||||
@ -289,14 +289,19 @@ describe("jsdoc/util/templateHelper", function() {
|
||||
'<a href="fakeclass.html">LinktoFakeClass</a>)>');
|
||||
});
|
||||
|
||||
it('returns the URL when a URL is specified', function() {
|
||||
it('returns a link when a URL is specified', function() {
|
||||
var link = helper.linkto('http://example.com');
|
||||
expect(link).toBe('http://example.com');
|
||||
expect(link).toBe('<a href="http://example.com">http://example.com</a>');
|
||||
});
|
||||
|
||||
it('returns the URL if a URL wrapped in angle brackets is specified', function() {
|
||||
it('returns a link if a URL wrapped in angle brackets is specified', function() {
|
||||
var link = helper.linkto('<http://example.com>');
|
||||
expect(link).toBe('http://example.com');
|
||||
expect(link).toBe('<a href="http://example.com">http://example.com</a>');
|
||||
});
|
||||
|
||||
it('returns a link with link text if a URL and link text are specified', function() {
|
||||
var link = helper.linkto('http://example.com', 'text');
|
||||
expect(link).toBe('<a href="http://example.com">text</a>');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user