File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -857,13 +857,20 @@ def replace_markdown(match):
857857 text = match .group (1 )
858858 path = match .group (2 )
859859
860+ # Strip leading/trailing whitespace from path
861+ path_stripped = path .strip ()
862+
860863 # Skip external links and mailto (including angle bracket wrapped)
861- if (path .startswith ('http' ) or path .startswith ('//' ) or
862- path .startswith ('<mailto:' ) or 'mailto:' in path ):
864+ if (path_stripped .startswith ('http' ) or path_stripped .startswith ('//' ) or
865+ path_stripped .startswith ('<mailto:' ) or 'mailto:' in path_stripped ):
866+ return match .group (0 )
867+
868+ # Only process actual internal links that start with /
869+ if not path_stripped .startswith ('/' ):
863870 return match .group (0 )
864871
865872 changes_made += 1
866- return f'[{ text } ]({ prefix } { path } )'
873+ return f'[{ text } ]({ prefix } { path_stripped } )'
867874
868875 content = re .sub (r'\[([^\]]+)\]\((/[^)]*)\)' , replace_markdown , content )
869876
You can’t perform that action at this time.
0 commit comments