Skip to content

Commit

Permalink
Fix incorrect parsing of links after square brackets
Browse files Browse the repository at this point in the history
Links parser would identify the first square brackets as invalid link and then continue from after the entire link, which skipped the valid link right next to the brackets
  • Loading branch information
Crozzers committed Dec 17, 2023
1 parent c34c957 commit cfbc79c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/tm-cases/link_after_square_brackets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>[before]
<a href="https://google.com">Some link</a>
[after]</p>
3 changes: 3 additions & 0 deletions test/tm-cases/link_after_square_brackets.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[before]
[Some link](https://google.com)
[after]

0 comments on commit cfbc79c

Please sign in to comment.