-
Notifications
You must be signed in to change notification settings - Fork 443
Description
Issue Description
I've encountered an issue with the markdown2 library where links are not properly converted to HTML when there are square brackets immediately before or after the link syntax. This issue disrupts the expected formatting and link functionality in the converted Markdown text.
Steps to Reproduce
- Use the markdown2 library to convert a Markdown string that includes a link surrounded by square brackets.
- Observe that the link is not correctly converted into an HTML anchor tag.
Sample Python Code to Reproduce the Issue
The following Python code snippet can be used to reproduce the issue with the markdown2 library:
import markdown2
# Sample Markdown string with a link surrounded by square brackets
markdown_text = '''
[before]
[Triggers of Alarm Systems](https://www.youtube.com/watch?v=aJOTlE1K90k&list=RDGMEMQ1dJ7wXfLlqCjwV0xfSNbA&index=3)
[after]
'''
# Convert Markdown to HTML
html_output = markdown2.markdown(markdown_text, extras=['tables', 'footnotes', 'markdown-in-html', 'cuddled-lists'])
# Print the HTML output
print("HTML Output:")
print(html_output)Expected Result
The link in the Markdown string should be converted into an HTML anchor tag, producing an output similar to:
<p>[before]
<a href="https://www.youtube.com/watch?v=aJOTlE1K90k&list=RDGMEMQ1dJ7wXfLlqCjwV0xfSNbA&index=3">Triggers of Alarm Systems</a>
[after]</p>Actual Result
The actual output keeps the Markdown link syntax without converting it into an HTML anchor tag:
<p>[before]
[Triggers of Alarm Systems](https://www.youtube.com/watch?v=aJOTlE1K90k&list=RDGMEMQ1dJ7wXfLlqCjwV0xfSNbA&index=3)
[after]</p>This code snippet should help in replicating the issue for troubleshooting and resolving the problem.
Additional Context
This issue seems to be specific to cases where square brackets immediately surround the Markdown link syntax. Removing the surrounding square brackets results in correct HTML conversion.