This commit is contained in:
2024-04-26 13:41:56 +08:00
parent f5712c73c7
commit 653fe79f13
4 changed files with 209 additions and 169 deletions

View File

@@ -0,0 +1,38 @@
import os
def main():
current_dir = os.path.dirname(os.path.realpath(__file__))
# Get all directories in the parent directory
data: dict[str, list[str]] = {}
for d in os.listdir(os.path.join(current_dir, "..")):
if not os.path.isdir(os.path.join(current_dir, "..", d)):
continue
if d.startswith("."):
continue
# Get all png files in the directory
files = [f for f in os.listdir(os.path.join(current_dir, "..", d)) if f.endswith(".png")]
if not files:
continue
data[d] = files
# Generate markdown table
columnWidth = max(len(name) for name in data.keys())
markdown = "| Name | Image |\n"
markdown += '|-------------------------------|--------|\n'
for name, images in data.items():
markdown += f"| {name.ljust(columnWidth)} | "
for image in images:
markdown += f'<img src="../{name}/{image}" width="100" /> '
markdown += "|\n"
print(markdown)
if __name__ == "__main__":
main()