@@ -82,7 +82,7 @@ def resolve_snippet(self, markdown: str, page: Page) -> str:
82
82
83
83
snippet_content = self .snippets [snippet_address ][snippet_id ]
84
84
85
- snippet_content = relativize_links (snippet_content , page .file . src_uri , snippet_id )
85
+ snippet_content = relativize_links (snippet_content , page .url , snippet_id )
86
86
87
87
snippet_content = self .preserve_indentation (snippet_content , markdown )
88
88
@@ -119,6 +119,10 @@ def read_snippets_from_file(file_content) -> dict[str, str]:
119
119
120
120
121
121
def relativize_links (snippet_content , current_path , snippet_id ) -> str :
122
+ current_path = '/' + current_path .strip ('/' ) + '/'
123
+ current_path_without_filename = current_path .rsplit ("/" , 2 )[0 ]
124
+ current_path_without_filename = remove_mike_version_from_path (current_path_without_filename )
125
+
122
126
matches = re .findall (markdown_link_pattern , snippet_content )
123
127
for match in matches :
124
128
link_text = match [0 ]
@@ -143,10 +147,6 @@ def relativize_links(snippet_content, current_path, snippet_id) -> str:
143
147
link_without_filetype = link_and_filetype [0 ]
144
148
filetype = link_and_filetype [1 ]
145
149
146
- current_path_without_filename = current_path .rsplit ("/" , 2 )[0 ]
147
-
148
- current_path_without_filename = remove_mike_version_from_path (current_path_without_filename )
149
-
150
150
relative_link = os .path .relpath (f"docs/{ link_without_filetype } " , f"docs/{ current_path_without_filename } " )
151
151
152
152
relative_link += "." + filetype
0 commit comments