Skip to content

Commit 2b231d0

Browse files
committed
fix: Update image URL generation for Markdown to BBCode conversion
1 parent 1dee0b3 commit 2b231d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

markdown_to_bbcode.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def replace_headers(match):
8282
def replace_images(match):
8383
image_url = match.group(1)
8484
if repo_name and not re.match(r'^https?://', image_url):
85-
absolute_url = f"https://github.com/{repo_name}/raw/main/{relative_path}/{image_url}"
85+
absolute_url = f"https://raw.githubusercontent.com/{repo_name}/refs/heads/main/{relative_path}/{image_url}"
86+
absolute_url = absolute_url.replace('//', '/')
8687
if bbcode_type == 'egosoft':
8788
return f"[spoiler][img]{absolute_url}[/img][/spoiler]"
8889
else:
@@ -323,7 +324,7 @@ def main():
323324
sys.exit(1)
324325

325326
# Extract relative path part from input_path
326-
relative_path = os.path.dirname(input_path)
327+
relative_path = os.path.dirname(input_path)
327328

328329
# Convert Markdown to BBCode
329330
bbcode_result = convert_markdown_to_bbcode(markdown_content, repo_name=repo_name, bbcode_type=bbcode_type, relative_path=relative_path)

0 commit comments

Comments
 (0)