Skip to content

Commit

Permalink
Update generate_readme.py
Browse files Browse the repository at this point in the history
  • Loading branch information
harilvfs committed Jan 25, 2025
1 parent 79a8107 commit 0d6ecfa
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/generate_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
README_FILE = "README.md"

def generate_markdown(images):
"""Generates Markdown table format for images."""
"""Generates Markdown grid format for images with four images per row."""
rows = []
row = []
for i, img in enumerate(images, start=1):
row.append(f"<img src='{img}' alt='img' width='150px'>")
if i % 3 == 0:
rows.append("|" + " | ".join(row) + " |")
row.append(f"<img src='{img}' alt='img' width='200px'>")
if i % 4 == 0:
rows.append("| " + " | ".join(row) + " |")
row = []
if row:
rows.append("|" + " | ".join(row) + " |")
separator = "| " + " | ".join(["---"] * 3) + " |"
return separator.join(["\n"] + rows)
rows.append("| " + " | ".join(row) + " |")
separator = "| " + " | ".join(["---"] * 4) + " |\n"
return "\n".join(["\n" + separator] + rows)

def main():
images = [
Expand All @@ -29,6 +29,7 @@ def main():
return

markdown = generate_markdown(images)

readme_content = (
"# Wallpaper Previews\n\n"
"Here is a preview of all wallpapers in this repository:\n\n"
Expand All @@ -40,3 +41,4 @@ def main():

if __name__ == "__main__":
main()

0 comments on commit 0d6ecfa

Please sign in to comment.