diff --git a/rss-generator.py b/rss-generator.py index 00a9786..2b92309 100644 --- a/rss-generator.py +++ b/rss-generator.py @@ -56,6 +56,44 @@ def fetch_app_description(app_id): print(f"Error fetching description for {app_id}: {e}") return "" +def format_description(text): + """Convert plain text description to formatted HTML with proper line breaks and lists.""" + if not text: + return "" + + # Normalize line breaks (handle both \r\n and \n) + text = text.replace('\r\n', '\n') + + lines = text.split('\n') + formatted_lines = [] + in_list = False + + for line in lines: + stripped = line.strip() + + # Check if this is a bullet point + if stripped and stripped[0] == '-': + if not in_list: + formatted_lines.append('') + in_list = False + # Add non-empty paragraphs + if stripped: + formatted_lines.append(f'

{stripped}

') + + # Close any open list + if in_list: + formatted_lines.append('') + + return '\n'.join(formatted_lines) + def create_rss_feed(apps_data, feed_name, feed_description, output_file): """Create an RSS feed from apps data using feedgen.""" @@ -91,7 +129,9 @@ def create_rss_feed(apps_data, feed_name, feed_description, output_file): # Fetch description from detail endpoint description = fetch_app_description(app_id) - # Ensure description is never None or empty string defaults to empty + # Format the description with HTML + description = format_description(description) + # Ensure description is never None if description is None: description = "" @@ -107,7 +147,7 @@ def create_rss_feed(apps_data, feed_name, feed_description, output_file): fe.title(str(app['title'])) # Ensure title is a string fe.link(href=f'https://repebblesearch.com/apps/{app_id}', rel='alternate') - # Set description (now includes image) + # Set description (now includes formatted text and image) if description: fe.description(description) else: @@ -175,4 +215,3 @@ def main(): if __name__ == "__main__": main() -