File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,15 @@ def extract_codeblock(match):
134
134
135
135
# 2) Now do the normal Markdown parsing on whatever’s left (outside code blocks)
136
136
137
+ # Now handle Markdown links and convert them to HTML
138
+ def replace_markdown_link (match ):
139
+ link_text = match .group (1 ) # The text to display
140
+ url = match .group (2 ) # The URL
141
+ return f'<a href="{ html .escape (url )} ">{ html .escape (link_text )} </a>'
142
+
143
+ # Replace Markdown links [text](url) with HTML <a> tags
144
+ text = re .sub (r'\[([^\]]+)\]\(([^)]+)\)' , replace_markdown_link , text )
145
+
137
146
# Headings: only match at the start of lines (via ^) and multiline
138
147
text = re .sub (r'^(######)\s+(.*)' , r'➤ <b>\2</b>' , text , flags = re .MULTILINE )
139
148
text = re .sub (r'^(#####)\s+(.*)' , r'➤ <b>\2</b>' , text , flags = re .MULTILINE )
You can’t perform that action at this time.
0 commit comments