mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
cleanup: remove legacy code
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import math
|
||||
import os
|
||||
import shutil
|
||||
from typing import Any, Dict
|
||||
|
||||
import mistune
|
||||
@@ -53,28 +52,3 @@ class ImagePathRewriterRenderer(MarkdownRenderer):
|
||||
def rewrite_image_paths(source: str, prefix: str) -> str:
|
||||
markdown = mistune.create_markdown(renderer=ImagePathRewriterRenderer(prefix))
|
||||
return unescape_braces(str(markdown(source)))
|
||||
|
||||
|
||||
class WebsiteImagePathRewriterRenderer(MarkdownRenderer):
|
||||
def __init__(self, source_dir: str, target_dir: str):
|
||||
super().__init__()
|
||||
self.source_dir = source_dir
|
||||
self.target_dir = target_dir
|
||||
|
||||
def image(self, token, state):
|
||||
url = token["attrs"]["url"]
|
||||
if "%7B" in url:
|
||||
pass
|
||||
elif ".." in url:
|
||||
url = ""
|
||||
elif "://" not in url and not url.startswith("/"):
|
||||
filename = os.path.basename(url)
|
||||
if url.startswith("/"):
|
||||
url = "../" + url[1:]
|
||||
shutil.copyfile(
|
||||
os.path.join(self.source_dir, url),
|
||||
os.path.join(self.target_dir, filename),
|
||||
)
|
||||
url = f"images/{filename}"
|
||||
token["attrs"]["url"] = url
|
||||
return super().image(token, state)
|
||||
|
||||
Reference in New Issue
Block a user