Improve image path regex to handle spaces, parentheses, and emojis in standard markdown image links with greedy matching and path trimming
This commit is contained in:
parent
175ac3dea8
commit
ba6271b89b
@ -165,12 +165,13 @@ def _process_standard_images(
|
||||
|
||||
Resolves the path and updates to use /api/image endpoint.
|
||||
"""
|
||||
# Pattern: 
|
||||
pattern = r'!\[([^\]]*)\]\(([^)]+?\.(?:png|jpg|jpeg|gif|svg|webp|bmp|ico))\)'
|
||||
# Pattern:  - match everything including spaces, parentheses, and emojis
|
||||
# Captures from ]( to ) where the content ends with an image extension
|
||||
pattern = r'!\[([^\]]*)\]\((.+\.(?:png|jpg|jpeg|gif|svg|webp|bmp|ico))\)'
|
||||
|
||||
def replace_standard_img(match):
|
||||
alt_text = match.group(1)
|
||||
image_path = match.group(2)
|
||||
image_path = match.group(2).strip()
|
||||
|
||||
# Skip if it's already an absolute URL (http://, https://, //)
|
||||
if re.match(r'^(https?://|//)', image_path):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user