Spaces:
Running
Running
fix
Browse files- backend_parsers.py +21 -1
backend_parsers.py
CHANGED
|
@@ -81,7 +81,14 @@ def parse_transformers_js_output(code: str) -> Dict[str, str]:
|
|
| 81 |
if js_fallback:
|
| 82 |
files['index.js'] = js_fallback.group(1).strip()
|
| 83 |
if css_fallback:
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# Additional fallback: extract from numbered sections or file headers
|
| 87 |
if not (files['index.html'] and files['index.js'] and files['style.css']):
|
|
@@ -102,6 +109,19 @@ def parse_transformers_js_output(code: str) -> Dict[str, str]:
|
|
| 102 |
content = re.sub(r'\n```\s*$', '', content)
|
| 103 |
files[file_key] = content.strip()
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
# Normalize transformers.js imports to use v3.8.0 CDN
|
| 106 |
cdn_url = "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.0"
|
| 107 |
|
|
|
|
| 81 |
if js_fallback:
|
| 82 |
files['index.js'] = js_fallback.group(1).strip()
|
| 83 |
if css_fallback:
|
| 84 |
+
css_content = css_fallback.group(1).strip()
|
| 85 |
+
files['style.css'] = css_content
|
| 86 |
+
|
| 87 |
+
# Also normalize HTML to reference style.css (singular)
|
| 88 |
+
if files['index.html'] and 'styles.css' in files['index.html']:
|
| 89 |
+
print("[Parser] Normalizing styles.css reference to style.css in HTML")
|
| 90 |
+
files['index.html'] = files['index.html'].replace('href="styles.css"', 'href="style.css"')
|
| 91 |
+
files['index.html'] = files['index.html'].replace("href='styles.css'", "href='style.css'")
|
| 92 |
|
| 93 |
# Additional fallback: extract from numbered sections or file headers
|
| 94 |
if not (files['index.html'] and files['index.js'] and files['style.css']):
|
|
|
|
| 109 |
content = re.sub(r'\n```\s*$', '', content)
|
| 110 |
files[file_key] = content.strip()
|
| 111 |
|
| 112 |
+
# Normalize filename references in HTML
|
| 113 |
+
if files['index.html'] and files['style.css']:
|
| 114 |
+
if 'styles.css' in files['index.html']:
|
| 115 |
+
print("[Parser] Normalizing styles.css reference to style.css in HTML")
|
| 116 |
+
files['index.html'] = files['index.html'].replace('href="styles.css"', 'href="style.css"')
|
| 117 |
+
files['index.html'] = files['index.html'].replace("href='styles.css'", "href='style.css'")
|
| 118 |
+
|
| 119 |
+
if files['index.html'] and files['index.js']:
|
| 120 |
+
if 'app.js' in files['index.html']:
|
| 121 |
+
print("[Parser] Normalizing app.js reference to index.js in HTML")
|
| 122 |
+
files['index.html'] = files['index.html'].replace('src="app.js"', 'src="index.js"')
|
| 123 |
+
files['index.html'] = files['index.html'].replace("src='app.js'", "src='index.js'")
|
| 124 |
+
|
| 125 |
# Normalize transformers.js imports to use v3.8.0 CDN
|
| 126 |
cdn_url = "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.0"
|
| 127 |
|