Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ def _sanitize_html(self, s: str) -> str:
[ ]? # one optional space
(?:\n[ ]*)? # one optional newline followed by spaces
\[
(?P<id>.*?)
(?P<id>[^\[\]]*?)
\]
''', re.X | re.S)

Expand Down Expand Up @@ -3179,7 +3179,6 @@ def run(self, text: str):
start_idx = text.index('[', curr_pos)
except ValueError:
break
text_length = len(text)

# Find the matching closing ']'.
# Markdown.pl allows *matching* brackets in link text so we
Expand All @@ -3190,7 +3189,7 @@ def run(self, text: str):

for p in range(
start_idx + 1,
min(start_idx + MAX_LINK_TEXT_SENTINEL, text_length)
min(start_idx + MAX_LINK_TEXT_SENTINEL, len(text))
):
ch = text[p]
if ch == ']':
Expand Down
1 change: 1 addition & 0 deletions test/tm-cases/reference_link_lookalike_issue680.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>[<a href="http://a.com">A</a>] [<a href="http://b.com">B</a>]</p>
1 change: 1 addition & 0 deletions test/tm-cases/reference_link_lookalike_issue680.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[A](http://a.com)] [[B](http://b.com)]