/
githubmirror
/
screenshot-to-code
Обзор
Документация
Войти
/
githubmirror
/
screenshot-to-code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
backend/codegen/utils.py
33 строки
1 KB
Abi Raja
update model for edits and format for prompt
10 мар 2026, 21:54
10 мар 2026, 21:54
5366927
Код
Авторство
О чём код?
import re def extract_html_content(text: str) -> str: file_match = re.search( r"<file\s+path=\"[^\"]+\">\s*(.*?)\s*</file>", text, re.DOTALL | re.IGNORECASE, ) if file_match: return extract_html_content(file_match.group(1).strip()) # First, strip markdown code fences if present text = re.sub(r'^```html?\s*\n?', '', text, flags=re.MULTILINE) text = re.sub(r'\n?```\s*$', '', text, flags=re.MULTILINE) # Try to find DOCTYPE + html tags together match_with_doctype = re.search( r"(<!DOCTYPE\s+html[^>]*>.*?<html.*?>.*?</html>)", text, re.DOTALL | re.IGNORECASE ) if match_with_doctype: return match_with_doctype.group(1) # Fall back to just <html> tags match = re.search(r"(<html.*?>.*?</html>)", text, re.DOTALL) if match: return match.group(1) else: # Otherwise, we just send the previous HTML over print( "[HTML Extraction] No <html> tags found in the generated content" ) return text