openfree commited on
Commit
f3d6c8c
ยท
verified ยท
1 Parent(s): ae87a48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -39
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
- """Format screenplay for display"""
2382
- if not screenplay_text:
2383
- return "No screenplay content yet."
2384
-
2385
- formatted = "# ๐ŸŽฌ Screenplay\n\n"
2386
-
2387
- # Format scene headings
2388
- formatted_text = re.sub(
2389
- r'^(INT\.|EXT\.)(.*?),
2390
- r'**\1\2**',
2391
- screenplay_text,
2392
- flags=re.MULTILINE
2393
- )
2394
-
2395
- # Format character names (all caps on their own line)
2396
- formatted_text = re.sub(
2397
- r'^([A-Z][A-Z\s]+),
2398
- r'**\1**',
2399
- formatted_text,
2400
- flags=re.MULTILINE
2401
- )
2402
-
2403
- # Add spacing for readability
2404
- lines = formatted_text.split('\n')
2405
- formatted_lines = []
2406
-
2407
- for i, line in enumerate(lines):
2408
- formatted_lines.append(line)
2409
- # Add extra space after scene headings
2410
- if line.startswith('**INT.') or line.startswith('**EXT.'):
2411
- formatted_lines.append('')
2412
-
2413
- formatted += '\n'.join(formatted_lines)
2414
-
2415
- # Add page count
2416
- page_count = len(screenplay_text.split('\n')) / 55
2417
- formatted = f"**Total Pages: {page_count:.1f}**\n\n" + formatted
2418
-
2419
- return formatted
 
 
 
 
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"""