Skip to content

Commit

Permalink
Merge pull request markedjs#1435 from UziTech/links-parens
Browse files Browse the repository at this point in the history
Links parens
  • Loading branch information
joshbruce committed Mar 8, 2019
2 parents 378a681 + 7a9a1a0 commit 556113a
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
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
Expand Up @@ -113,10 +113,16 @@
"html": "<p><strong><a href=\"mailto:test@test.com\">test@test.com</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 556113a

Please sign in to comment.