akhaliq HF Staff commited on
Commit
783914a
·
1 Parent(s): 56db192
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -428,6 +428,19 @@ def parse_transformers_js_output(text):
428
  if css_match:
429
  files['style.css'] = css_match.group(1).strip()
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  return files
432
 
433
  def format_transformers_js_output(files):
 
428
  if css_match:
429
  files['style.css'] = css_match.group(1).strip()
430
 
431
+ # Fallback: support === index.html === format if any file is missing
432
+ if not (files['index.html'] and files['index.js'] and files['style.css']):
433
+ # Use regex to extract sections
434
+ html_fallback = re.search(r'===\s*index\.html\s*===\n([\s\S]+?)(?=\n===|$)', text, re.IGNORECASE)
435
+ js_fallback = re.search(r'===\s*index\.js\s*===\n([\s\S]+?)(?=\n===|$)', text, re.IGNORECASE)
436
+ css_fallback = re.search(r'===\s*style\.css\s*===\n([\s\S]+?)(?=\n===|$)', text, re.IGNORECASE)
437
+ if html_fallback:
438
+ files['index.html'] = html_fallback.group(1).strip()
439
+ if js_fallback:
440
+ files['index.js'] = js_fallback.group(1).strip()
441
+ if css_fallback:
442
+ files['style.css'] = css_fallback.group(1).strip()
443
+
444
  return files
445
 
446
  def format_transformers_js_output(files):