Skip to content

Commit

Permalink
Update render code
Browse files Browse the repository at this point in the history
  • Loading branch information
silasprincipe committed Oct 9, 2024
1 parent 04308f8 commit 534f05a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/scripts/render_and_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def capture_screenshot(html_content, output_path):

# Function to update README.md
def update_readme(section, file_name, file_path, screenshot_path):
print(f"Updating README...")
readme_path = os.path.join(notebooks_dir, "README.md")
title = file_name.split(".")[0] # Get title from file name
title = title.replace("_", " ").title() # Replace underscores with spaces and capitalize
Expand All @@ -79,9 +80,11 @@ def update_readme(section, file_name, file_path, screenshot_path):

if pattern.search(content):
# If the entry exists, update it with the new screenshot path
print(f"Entry already exists on {readme_path}")
content = pattern.sub(new_entry, content)
else:
# If no entry exists, add a new one under the correct section
print(f"Adding new entry to {readme_path} on section {section}...")
if section == "Python":
content = re.sub(r"(# Python\n)", rf"\1{new_entry}\n", content)
elif section == "R":
Expand Down

0 comments on commit 534f05a

Please sign in to comment.