mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Changes to allow target and text in {@link target text} to be separated by newlines and for text to contain newlines.
This commit is contained in:
parent
2090b8d2fe
commit
32d00c20ca
@ -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 ) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -1170,6 +1170,22 @@ describe("jsdoc/util/templateHelper", function() {
|
||||
expect(output).toBe('This is a <a href="path/to/test.html">test</a>.');
|
||||
});
|
||||
|
||||
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 <a href="path/to/test.html">test</a>.');
|
||||
});
|
||||
|
||||
|
||||
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 <a href="path/to/test.html">test test</a>.');
|
||||
});
|
||||
|
||||
|
||||
it('should allow tabs between link tag and content', function() {
|
||||
var input = 'This is a {@link\ttest}.',
|
||||
output = helper.resolveLinks(input);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user