Skip to content

Commit

Permalink
Link parenthesis, marked#1509
Browse files Browse the repository at this point in the history
  • Loading branch information
yahtnif committed Jul 6, 2019
1 parent b512f54 commit b00493c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 13 additions & 0 deletions __tests__/base/link
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@ bold around autolink: __test@test.com__
hTtP://fOo.CoM


Link parenthesis:

([one](http://example.com/1)) ([two](http://example.com/2))

([one](http://example.com/1)) ([two](http://example.com/2))

([one](http://example.com/1 "a")) ([two](http://example.com/2 "b"))



<p>autolink: <a href="https://example.com">https://example.com</a></p>
<p>Link: <a href="https://example.com/">constructor</a>.</p>
<p>(See <a href="https://www.example.com/example">https://www.example.com/example</a>.)</p>
<p>((<a href="https://example.com">https://example.com</a>))</p>
<p>bold around autolink: <strong><a href="mailto:test@test.com">test@test.com</a></strong></p>
<p><a href="hTtP://fOo.CoM">hTtP://fOo.CoM</a></p>
<p>Link parenthesis:</p>
<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>
<p>(<a href="http://example.com/1">one</a>) (<a href="http://example.com/2">two</a>)</p>
<p>(<a href="http://example.com/1" title="a">one</a>) (<a href="http://example.com/2" title="b">two</a>)</p>
5 changes: 1 addition & 4 deletions src/inline-lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ export class InlineLexer {
if ((execArr = this.rules.link.exec(nextPart))) {
const lastParenIndex = this.findClosingBracket(execArr[2], '()')
if (lastParenIndex > -1) {
const linkLen =
execArr[0].length -
(execArr[2].length - lastParenIndex) -
(execArr[3] || '').length
const linkLen = 4 + execArr[1].length + lastParenIndex
execArr[2] = execArr[2].substring(0, lastParenIndex)
execArr[0] = execArr[0].substring(0, linkLen).trim()
execArr[3] = ''
Expand Down

0 comments on commit b00493c

Please sign in to comment.