akhaliq HF Staff commited on
Commit
e8140e4
·
1 Parent(s): d6a6b23
Files changed (1) hide show
  1. backend_parsers.py +4 -4
backend_parsers.py CHANGED
@@ -130,10 +130,10 @@ def parse_transformers_js_output(code: str) -> Dict[str, str]:
130
  # Fallback: support === index.html === format if any file is missing
131
  if not (files['index.html'] and files['index.js'] and files['style.css']):
132
  # Use regex to extract sections - match === markers with optional whitespace and newlines
133
- # Made [\r\n]+ optional with * instead of + to handle cases where content follows immediately
134
- html_fallback = re.search(r'===\s*index\.html\s*===\s*[\r\n]*([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE)
135
- js_fallback = re.search(r'===\s*index\.js\s*===\s*[\r\n]*([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE)
136
- css_fallback = re.search(r'===\s*style\.css\s*===\s*[\r\n]*([\s\S]+?)(?=\n===|$)', code, re.IGNORECASE)
137
 
138
  print(f"[Parser] Fallback extraction - HTML found: {bool(html_fallback)}, JS found: {bool(js_fallback)}, CSS found: {bool(css_fallback)}")
139
 
 
130
  # Fallback: support === index.html === format if any file is missing
131
  if not (files['index.html'] and files['index.js'] and files['style.css']):
132
  # Use regex to extract sections - match === markers with optional whitespace and newlines
133
+ # Fixed lookahead to allow any whitespace (not just \n) before next === marker
134
+ html_fallback = re.search(r'===\s*index\.html\s*===\s*[\r\n]*([\s\S]+?)(?=\s*===\s*index\.js\s*===|$)', code, re.IGNORECASE)
135
+ js_fallback = re.search(r'===\s*index\.js\s*===\s*[\r\n]*([\s\S]+?)(?=\s*===\s*style\.css\s*===|$)', code, re.IGNORECASE)
136
+ css_fallback = re.search(r'===\s*style\.css\s*===\s*[\r\n]*([\s\S]+?)$', code, re.IGNORECASE)
137
 
138
  print(f"[Parser] Fallback extraction - HTML found: {bool(html_fallback)}, JS found: {bool(js_fallback)}, CSS found: {bool(css_fallback)}")
139