Skip to content

Commit

Permalink
Merge pull request jsdoc#1036 from Oblongmana/fix/markdown-breaks-nam…
Browse files Browse the repository at this point in the history
…epaths-with-special-characters

Fix markdown breaking namepaths w/special chars
  • Loading branch information
hegemonic committed Dec 9, 2015
2 parents 3734dd6 + acc47fd commit 012369a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/jsdoc/util/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ function escapeCode(source) {
.replace(/'/g, ''');
}

/**
* Unencode quotes that occur within {@ ... } after the markdown parser has turned them
* into html entities (unfortunately it isn't possible to escape them before parsing)
*
* @param {string} source - The source text to unencode.
* @return {string} The source text with html entity `"` converted back to standard quotes
*/
function unencodeQuotes(source) {
return source.replace(/\{@[^}\r\n]+\}/g, function (wholeMatch) {
return wholeMatch.replace(/"/g, '"');
});
}


/**
* Retrieve a function that accepts a single parameter containing Markdown source. The function uses
* the specified parser to transform the Markdown source to HTML, then returns the HTML as a string.
Expand Down Expand Up @@ -127,7 +141,9 @@ function getParseFunction(parserName, conf) {
result = marked(source, { renderer: markedRenderer })
.replace(/\s+$/, '')
.replace(/'/g, "'");

result = unescapeUrls(result);
result = unencodeQuotes(result);

return result;
};
Expand Down

0 comments on commit 012369a

Please sign in to comment.