diff --git a/lib/markdown2.py b/lib/markdown2.py index 9b693530..16e5d50f 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -1460,7 +1460,7 @@ def _sanitize_html(self, s: str) -> str: [ ]? # one optional space (?:\n[ ]*)? # one optional newline followed by spaces \[ - (?P.*?) + (?P[^\[\]]*?) \] ''', re.X | re.S) @@ -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 @@ -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 == ']': diff --git a/test/tm-cases/reference_link_lookalike_issue680.html b/test/tm-cases/reference_link_lookalike_issue680.html new file mode 100644 index 00000000..182d8906 --- /dev/null +++ b/test/tm-cases/reference_link_lookalike_issue680.html @@ -0,0 +1 @@ +

[A] [B]

diff --git a/test/tm-cases/reference_link_lookalike_issue680.text b/test/tm-cases/reference_link_lookalike_issue680.text new file mode 100644 index 00000000..ad07eb9d --- /dev/null +++ b/test/tm-cases/reference_link_lookalike_issue680.text @@ -0,0 +1 @@ +[[A](http://a.com)] [[B](http://b.com)] \ No newline at end of file