Skip to content

Commit

Permalink
Merge pull request markedjs#1557 from UziTech/image-paren
Browse files Browse the repository at this point in the history
fix image parentheses
  • Loading branch information
joshbruce committed Oct 3, 2019
2 parents 76dadaf + 6725e71 commit c746c6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/marked.js
Expand Up @@ -723,7 +723,8 @@ InlineLexer.prototype.output = function(src) {
if (cap = this.rules.link.exec(src)) {
var lastParenIndex = findClosingBracket(cap[2], '()');
if (lastParenIndex > -1) {
var linkLen = 4 + cap[1].length + lastParenIndex;
var start = cap[0].indexOf('!') === 0 ? 5 : 4;
var linkLen = start + cap[1].length + lastParenIndex;
cap[2] = cap[2].substring(0, lastParenIndex);
cap[0] = cap[0].substring(0, linkLen).trim();
cap[3] = '';
Expand Down
3 changes: 3 additions & 0 deletions test/specs/new/image_paren.html
@@ -0,0 +1,3 @@
<p><img src="img1.svg" alt=""> (or <img src="img2.svg" alt="">)</p>

<p><img src="img1.svg" alt="one"> (or <img src="img2.svg" alt="two">)</p>
3 changes: 3 additions & 0 deletions test/specs/new/image_paren.md
@@ -0,0 +1,3 @@
![](img1.svg) (or ![](img2.svg))

![one](img1.svg) (or ![two](img2.svg))

0 comments on commit c746c6d

Please sign in to comment.