zomato-backend / utils.py
Rahul-Samedavar's picture
removed few insights
ba9555f
raw
history blame contribute delete
917 Bytes
import re
def extract_points(markdown_text: str) -> list[str]:
"""
Extracts numbered/bulleted markdown points as clean strings.
Removes:
- markdown bold/italic/code formatting
- numbering/bullets
- extra spaces/newlines
"""
lines = markdown_text.splitlines()
points = []
for line in lines:
line = line.strip()
if not line:
continue
# Match numbered or bulleted list items
if re.match(r"^(\d+\.\s+|[-*]\s+)", line):
# Remove numbering/bullets
line = re.sub(r"^(\d+\.\s+|[-*]\s+)", "", line)
# Remove markdown formatting
line = re.sub(r"\*\*(.*?)\*\*", r"\1", line) # bold
line = re.sub(r"\*(.*?)\*", r"\1", line) # italic
line = re.sub(r"`(.*?)`", r"\1", line) # inline code
points.append(line.strip())
return points