Skip to content

Commit

Permalink
Merge pull request #1435 from UziTech/links-parens
Browse files Browse the repository at this point in the history
Links parens
  • Loading branch information
joshbruce authored Mar 8, 2019
2 parents ae9484d + 9dc35bf commit b5fb988
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,10 @@ InlineLexer.prototype.output = function(src) {
if (cap = this.rules.link.exec(src)) {
var lastParenIndex = findClosingBracket(cap[2], '()');
if (lastParenIndex > -1) {
var removeChars = cap[2].length - lastParenIndex;
var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length;
cap[2] = cap[2].substring(0, lastParenIndex);
cap[0] = cap[0].substring(0, cap[0].length - removeChars);
cap[0] = cap[0].substring(0, linkLen).trim();
cap[3] = '';
}
src = src.substring(cap[0].length);
this.inLink = true;
Expand Down
8 changes: 7 additions & 1 deletion test/specs/marked/marked.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,16 @@
"html": "<p><strong><a href=\"mailto:[email protected]\">[email protected]</a></strong></p>",
"example": 1347
},
{
{
"section": "Emphasis extra tests",
"markdown": "_test_. _test_: _test_! _test_? _test_-",
"html": "<p><em>test</em>. <em>test</em>: <em>test</em>! <em>test</em>? <em>test</em>-</p>",
"example": 15
},
{
"section": "Links",
"markdown": "[One](https://example.com/1) ([Two](https://example.com/2)) [Three](https://example.com/3)",
"html": "<p><a href=\"https://example.com/1\">One</a> (<a href=\"https://example.com/2\">Two</a>) <a href=\"https://example.com/3\">Three</a></p>",
"example": 16
}
]

0 comments on commit b5fb988

Please sign in to comment.