executablebooks / markdown-it-py

Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed. Now in Python!
https://markdown-it-py.readthedocs.io
MIT License
662 stars 68 forks source link

Markdown Image link that has title text with escaped quotation is not recognized #305

Open krisyang1125 opened 9 months ago

krisyang1125 commented 9 months ago

Describe the bug

When I have a markdown image like this where the title contains the same escaped quotation mark as the one it's nested in, the parser will fail to parse the node as an markdown image ![panda dancing with cat](https://i.imgur.com/img.jpg 'title\'')

I expected the markdown image link to be recognize as image node type

I use this parser to extract image links from markdown text and host them on my server for security reasons. This false negative is not ideal for my use case.

Let me know if you need any other info. Thanks

Reproduce the bug

text = """![panda dancing with cat](https://i.imgur.com/img.jpg 'title\'')"""
md = MarkdownIt("gfm-like")
syntax_tree = SyntaxTreeNode(md.parse(text))

# Traverse the tree and check if a tree node of image type exists

List your environment

Version of markdown-it-py: 3.0.0 Versions of mdit-py-plugins: 0.3.5 The version of Python you're using: 3.9 Your operating system: Ubuntu 18.04.6

welcome[bot] commented 9 months ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada: