Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect parsing of links after square brackets (#552) #556

Merged
merged 2 commits into from
Dec 17, 2023
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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]
Loading