diff --git a/app.py b/app.py index c00af11..6a43da7 100644 --- a/app.py +++ b/app.py @@ -15,6 +15,7 @@ from flask_limiter.util import get_remote_address import google.generativeai as genai import requests from dotenv import load_dotenv +import markdown # Load environment variables load_dotenv() @@ -111,54 +112,7 @@ def is_valid_pdf(pdf_path): return False def format_summary(summary): - """Converts markdown-like text to HTML formatting, including nested lists (both ordered and unordered).""" - summary = re.sub(r'\*\*(.*?)\*\*', r'\1', summary) # Bold text - summary = re.sub(r'\*(?!\s)(.*?)\*', r'\1', summary) # Italic text (ignoring lists) - - lines = summary.split('\n') - formatted_lines = [] - list_stack = [] # Track nesting levels and types - - for line in lines: - unordered_match = re.match(r'^(\s*)\*\s(.+)', line) # Matches "* item" - ordered_match = re.match(r'^(\s*)(\d+)\.\s(.+)', line) # Matches "1. item" - - if unordered_match or ordered_match: - indent = unordered_match.group(1) if unordered_match else ordered_match.group(1) - level = len(indent) // 4 # Assume 4 spaces per indent level - - list_type = '