Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -105,16 +105,19 @@ def _normalize_lines(text: str) -> List[str]:
|
|
| 105 |
def _ensure_numbering(text: str) -> str:
|
| 106 |
text = re.sub(r"[\u2060\u200B]", "", text or "")
|
| 107 |
def strip_prefix_any(s: str) -> str:
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
r"
|
| 112 |
-
r"
|
| 113 |
-
r"
|
| 114 |
-
""
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
)
|
|
|
|
|
|
|
| 118 |
lines = [ln.strip() for ln in (text or "").splitlines() if ln and ln.strip()]
|
| 119 |
if not lines:
|
| 120 |
return text or ""
|
|
|
|
| 105 |
def _ensure_numbering(text: str) -> str:
|
| 106 |
text = re.sub(r"[\u2060\u200B]", "", text or "")
|
| 107 |
def strip_prefix_any(s: str) -> str:
|
| 108 |
+
|
| 109 |
+
#Matches any leading list marker: numbers (1) or 1., 'Step N:', bullets -, *, •, circled numerals
|
| 110 |
+
pattern = (
|
| 111 |
+
r"^\s*(?:" # start, optional spaces, non-capturing group
|
| 112 |
+
r"[\u2060\u200B]*" # optional zero-width characters
|
| 113 |
+
r"(?:\d+\s*[.)]" # classic numbers like '1)' or '2.'
|
| 114 |
+
r"|step\s*\d+:?" # 'Step 3:' (case-insensitive via IGNORECASE)
|
| 115 |
+
r"|[\-\*\u2022]" # bullets '-', '*', '•'
|
| 116 |
+
r"|[\u2460-\u2473])" # circled numerals
|
| 117 |
+
r"\s*)" # trailing spaces, close outer group ← THIS ) WAS MISSING
|
| 118 |
)
|
| 119 |
+
return re.sub(pattern, "", (s or "").strip(), flags=re.IGNORECASE)
|
| 120 |
+
|
| 121 |
lines = [ln.strip() for ln in (text or "").splitlines() if ln and ln.strip()]
|
| 122 |
if not lines:
|
| 123 |
return text or ""
|