diff --git a/CHANGES.md b/CHANGES.md index 9a5ac73e..fd70e0cf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - [pull #547] Update `markdown-in-html` extra to handle markdown on same line as HTML (#546) - [pull #550] Fix tables with trailing whitespace not being recognized (#549) - [pull #545] Fix multiple instances of strong emphasis (`**`) in one line (#541) +- [pull #556] Fix incorrect parsing of links after square brackets (#552) ## python-markdown2 2.4.11 diff --git a/lib/markdown2.py b/lib/markdown2.py index 34a270b3..c0db9874 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -1786,7 +1786,8 @@ def _do_links(self, text): curr_pos = start_idx + 1 else: # This id isn't defined, leave the markup alone. - curr_pos = match.end() + # set current pos to end of link title and continue from there + curr_pos = p continue # Otherwise, it isn't markup. diff --git a/test/tm-cases/link_after_square_brackets.html b/test/tm-cases/link_after_square_brackets.html new file mode 100644 index 00000000..a5421f3c --- /dev/null +++ b/test/tm-cases/link_after_square_brackets.html @@ -0,0 +1,3 @@ +

[before] +Some link +[after]

diff --git a/test/tm-cases/link_after_square_brackets.text b/test/tm-cases/link_after_square_brackets.text new file mode 100644 index 00000000..7c569d7b --- /dev/null +++ b/test/tm-cases/link_after_square_brackets.text @@ -0,0 +1,3 @@ +[before] +[Some link](https://google.com) +[after]