diff --git a/lib/jsdoc/tag/inline.js b/lib/jsdoc/tag/inline.js index b425ef87..8be46e26 100644 --- a/lib/jsdoc/tag/inline.js +++ b/lib/jsdoc/tag/inline.js @@ -61,7 +61,7 @@ exports.replaceInlineTags = function(string, replacers) { string = string || ''; Object.keys(replacers).forEach(function(replacer) { - var tagRegExp = new RegExp('\\{@' + replacer + '\\s+(.+?)\\}', 'gi'); + var tagRegExp = new RegExp('\\{@' + replacer + '\\s+((?:.|\n)+?)\\}', 'gi'); var matches; // call the replacer once for each match while ( (matches = tagRegExp.exec(string)) !== null ) { diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js index 61b1ecc5..739f2cc3 100644 --- a/lib/jsdoc/util/templateHelper.js +++ b/lib/jsdoc/util/templateHelper.js @@ -256,11 +256,13 @@ function splitLinkText(text) { // if a pipe is not present, we split on the first space splitIndex = text.indexOf('|'); if (splitIndex === -1) { - splitIndex = text.indexOf(' '); + splitIndex = text.search(/\s/); } if (splitIndex !== -1) { linkText = text.substr(splitIndex + 1); + // Normalize subsequent newlines to a single space. + linkText = linkText.replace(/\n+/, ' '); target = text.substr(0, splitIndex); } diff --git a/test/specs/jsdoc/util/templateHelper.js b/test/specs/jsdoc/util/templateHelper.js index 3e8e8cdb..9b944248 100644 --- a/test/specs/jsdoc/util/templateHelper.js +++ b/test/specs/jsdoc/util/templateHelper.js @@ -1170,6 +1170,22 @@ describe("jsdoc/util/templateHelper", function() { expect(output).toBe('This is a test.'); }); + it('should allow linebreaks to separate url from link text', function() { + var input = 'This is a {@link\ntest\ntest}.', + output = helper.resolveLinks(input); + + expect(output).toBe('This is a test.'); + }); + + + it('should normalize additional newlines to spaces', function() { + var input = 'This is a {@link\ntest\ntest\n\ntest}.', + output = helper.resolveLinks(input); + + expect(output).toBe('This is a test test.'); + }); + + it('should allow tabs between link tag and content', function() { var input = 'This is a {@link\ttest}.', output = helper.resolveLinks(input);