matthewwithanm / python-markdownify

Convert HTML to Markdown
MIT License
1.17k stars 140 forks source link

Escape right square bracket #148

Open eri24816 opened 2 months ago

eri24816 commented 2 months ago

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 commented 1 month ago

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.)