Skip to content

Conversation

@eri24816
Copy link

@eri24816 eri24816 commented Sep 14, 2024

Add the right square bracket (]) to the list of escaped symbols. This is necessary to correctly represent a link text containing a right square bracket:

html = '<a href="citation.html">[How to cite this work]</a>'
print(markdownify(html))

# before this pr: r'[\[How to cite this work]](citation.html)'
# after this pr:  r'[\[How to cite this work\]](citation.html)'

@jsm28
Copy link
Contributor

jsm28 commented Oct 2, 2024

Could you also add a test for this case to the testsuite? (Note, you need a fix to test function naming from #149 or #122 for the miscellaneous escaping tests to actually be run.)

jsm28 added a commit to jsm28/python-markdownify that referenced this pull request Feb 5, 2025
As discussed in matthewwithanm#148, right square brackets need to be escaped for
correct handling in links in some cases.  This is an alternative to
that PR that is based on current sources and adds the requested
testcase, since there was no response to the request in that PR for a
testcase to be added to the testsuite.
@chrispy-snps
Copy link
Collaborator

Closing, as this is now covered by #187.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants