Skip to content

Commit cfbc79c

Browse files
committed
Fix incorrect parsing of links after square brackets
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
1 parent c34c957 commit cfbc79c

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/markdown2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,8 @@ def _do_links(self, text):
17861786
curr_pos = start_idx + 1
17871787
else:
17881788
# This id isn't defined, leave the markup alone.
1789-
curr_pos = match.end()
1789+
# set current pos to end of link title and continue from there
1790+
curr_pos = p
17901791
continue
17911792

17921793
# Otherwise, it isn't markup.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>[before]
2+
<a href="https://google.com">Some link</a>
3+
[after]</p>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[before]
2+
[Some link](https://google.com)
3+
[after]

0 commit comments

Comments
 (0)