From fc6a05ced62b1e28924ba37440fe925e29eca9c6 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 31 Mar 2025 11:42:40 +1300 Subject: [PATCH] fix: Improve testimonial parsing for different dash formats --- scripts/homepage.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/homepage.py b/scripts/homepage.py index 22c140066..c7a274c5c 100755 --- a/scripts/homepage.py +++ b/scripts/homepage.py @@ -459,20 +459,38 @@ def get_testimonials_js(): link = "" # Try to extract author and link if they exist + # Check for the em dash format first: "— [author](link)" if "— [" in full_line and "](" in full_line: author_parts = full_line.split("— [") if len(author_parts) > 1: author = author_parts[1].split("]")[0].strip() - + # Extract the link if it exists link_parts = full_line.split("](") if len(link_parts) > 1: link = link_parts[1].split(")")[0].strip() + # Check for regular dash format: "- [author](link)" + elif " - [" in full_line and "](" in full_line: + author_parts = full_line.split(" - [") + if len(author_parts) > 1: + author = author_parts[1].split("]")[0].strip() + + # Extract the link if it exists + link_parts = full_line.split("](") + if len(link_parts) > 1: + link = link_parts[1].split(")")[0].strip() + # Check for em dash without link: "— author" elif "— " in full_line: # Format without a link, just plain text author author_parts = full_line.split("— ") if len(author_parts) > 1: author = author_parts[1].strip() + # Check for regular dash without link: "- author" + elif " - " in full_line: + # Format without a link, just plain text author + author_parts = full_line.split(" - ") + if len(author_parts) > 1: + author = author_parts[1].strip() testimonials.append( {"text": quote_text, "author": author, "link": link}