Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2377,46 +2377,52 @@ def extract_logline_from_theme(theme_text: str) -> str:
|
|
2377 |
match = re.search(r'\*\*(?:Logline|๋ก๊ทธ๋ผ์ธ):\*\*\s*(.+)', theme_text, re.IGNORECASE)
|
2378 |
return match.group(1).strip() if match else ""
|
2379 |
|
|
|
|
|
2380 |
def format_screenplay_display(screenplay_text: str) -> str:
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
|
|
|
|
|
|
|
|
2420 |
|
2421 |
def format_stages_display(stages: List[Dict]) -> str:
|
2422 |
"""Format stages display for screenplay"""
|
|
|
2377 |
match = re.search(r'\*\*(?:Logline|๋ก๊ทธ๋ผ์ธ):\*\*\s*(.+)', theme_text, re.IGNORECASE)
|
2378 |
return match.group(1).strip() if match else ""
|
2379 |
|
2380 |
+
import re
|
2381 |
+
|
2382 |
def format_screenplay_display(screenplay_text: str) -> str:
|
2383 |
+
"""Convert raw screenplay text to a nicely formatted Markdown preview."""
|
2384 |
+
|
2385 |
+
if not screenplay_text:
|
2386 |
+
return "No screenplay content yet."
|
2387 |
+
|
2388 |
+
# 1) ์ ๋ชฉ ์์ญ
|
2389 |
+
formatted = "# ๐ฌ Screenplay\n\n"
|
2390 |
+
|
2391 |
+
# 2) ์ฌ ํค๋ฉ(INT./EXT. ๋ผ์ธ) ๋ณผ๋ ์ฒ๋ฆฌ
|
2392 |
+
# - ^ : ํ์ ์์
|
2393 |
+
# - .* : ํ ์ ์ฒด
|
2394 |
+
# - re.MULTILINE : ๊ฐ ์ค๋ง๋ค ^ $๊ฐ ๋์
|
2395 |
+
formatted_text = re.sub(
|
2396 |
+
r'^(INT\.|EXT\.).*$', # ์บก์ฒ: INT. ๋๋ EXT.์ผ๋ก ์์ํ๋ ํ ์ค
|
2397 |
+
r'**\g<0>**', # ์ ์ฒด ํ์ ๊ตต๊ฒ
|
2398 |
+
screenplay_text,
|
2399 |
+
flags=re.MULTILINE
|
2400 |
+
)
|
2401 |
+
|
2402 |
+
# 3) ๋๋ฌธ์ ์ ์(์ธ๋ฌผ ์ด๋ฆ) ๋ณผ๋ ์ฒ๋ฆฌ
|
2403 |
+
# - [A-Z][A-Z\s]+$ : ALL-CAPS ๊ธ์์ ๊ณต๋ฐฑ๋ง์ผ๋ก ์ด๋ค์ง ํ
|
2404 |
+
formatted_text = re.sub(
|
2405 |
+
r'^([A-Z][A-Z\s]+)$',
|
2406 |
+
r'**\g<0>**',
|
2407 |
+
formatted_text,
|
2408 |
+
flags=re.MULTILINE
|
2409 |
+
)
|
2410 |
+
|
2411 |
+
# 4) ๊ฐ๋
์ฑ์ ์ํด INT./EXT. ๋ค์ ๋น ์ค ์ฝ์
|
2412 |
+
lines = formatted_text.splitlines()
|
2413 |
+
pretty_lines = []
|
2414 |
+
for line in lines:
|
2415 |
+
pretty_lines.append(line)
|
2416 |
+
if line.startswith("**INT.") or line.startswith("**EXT."):
|
2417 |
+
pretty_lines.append("") # ๋น ์ค ์ถ๊ฐ
|
2418 |
+
|
2419 |
+
formatted += "\n".join(pretty_lines)
|
2420 |
+
|
2421 |
+
# 5) ํ์ด์ง ์(์คํฌ๋ฆฝํธ ๊ท์น: 1 ํ์ด์ง โ 55 ๋ผ์ธ) ๊ณ์ฐ
|
2422 |
+
page_count = len(screenplay_text.splitlines()) / 55
|
2423 |
+
formatted = f"**Total Pages: {page_count:.1f}**\n\n" + formatted
|
2424 |
+
return formatted
|
2425 |
+
|
2426 |
|
2427 |
def format_stages_display(stages: List[Dict]) -> str:
|
2428 |
"""Format stages display for screenplay"""
|