srilakshu012456 commited on
Commit
4ba70dc
·
verified ·
1 Parent(s): 6532a9e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -9
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
- return re.sub(
109
- r"^\s*(?:[\u2060\u200B]*"
110
- r"(?:\d+\s*[.)]"
111
- r"|(?i:step\s*\d+:?)"
112
- r"|[\-\*\u2022]"
113
- r"|[\u2460-\u2473])\s*",
114
- "",
115
- (s or "").strip(),
116
- flags=re.IGNORECASE,
 
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 ""