Skip to content

Commit

Permalink
Merge pull request #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 faf56e5 + ca3741f commit 1b08126
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))

1 comment on commit 1b08126

@vercel
Copy link

@vercel vercel bot commented on 1b08126 Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.