Guiyom commited on
Commit
09a8e4b
·
verified ·
1 Parent(s): d2319df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -9
app.py CHANGED
@@ -38,7 +38,7 @@ def capture_visual_screenshot(srcdoc: str) -> str:
38
  driver = None
39
  try:
40
  driver = webdriver.Chrome(options=options)
41
- driver.set_window_size(1080, 720) # Adjust per your expected visual dimensions
42
 
43
  # Write the srcdoc to a temporary HTML file
44
  with tempfile.NamedTemporaryFile(delete=False, suffix=".html") as tmp_file:
@@ -47,7 +47,7 @@ def capture_visual_screenshot(srcdoc: str) -> str:
47
  file_url = "file://" + tmp_file.name
48
 
49
  driver.get(file_url)
50
- time.sleep(3) # Allow time for JavaScript (e.g., mermaid) to render
51
 
52
  screenshot_png = driver.get_screenshot_as_png()
53
  image = Image.open(BytesIO(screenshot_png))
@@ -2215,12 +2215,10 @@ def replace_focus_placeholders(report_html: str, context: str, initial_query: st
2215
  focus_html = generate_focus_snippet(instructions, context, initial_query, crumbs)
2216
  # Remove any outer HTML or body tags from the generated snippet:
2217
  focus_html = re.sub(r"<\/?(html|head|body)[^>]*>", "", focus_html, flags=re.DOTALL|re.IGNORECASE).strip()
2218
- # Now wrap in a single container with reduced font size:
2219
  return (
2220
  f'<!-- Focus {placeholder_num} Start -->'
2221
- f'<p style="text-align: center;">-----------------------------------------------------------------------</p>'
2222
- f'{focus_html}'
2223
- f'<p style="text-align: center;">-----------------------------------------------------------------------</p>'
2224
  f'<!-- Focus {placeholder_num} End -->'
2225
  )
2226
  except Exception as e:
@@ -3013,10 +3011,36 @@ class ReportGenerator:
3013
  pre, div {{ white-space: pre-wrap; }}
3014
  ol, ul {{ font-size: 11pt; margin-left: 20px; line-height: 1.5; }}
3015
  hr {{ border: 1px solid #ccc; margin: 20px 0; }}
3016
- table {{ border-collapse: collapse; width: 100%; margin-bottom: 10px; }}
3017
- th, td {{ border: 1px solid #ccc; padding: 8px; text-align: left; }}
3018
- th {{ background-color: #f2f2f2; }}
 
 
 
 
 
 
 
 
 
 
 
 
 
3019
  .page-break {{ page-break-before: always; }}
 
 
 
 
 
 
 
 
 
 
 
 
 
3020
  </style>
3021
  </head>
3022
  <body>
 
38
  driver = None
39
  try:
40
  driver = webdriver.Chrome(options=options)
41
+ driver.set_window_size(1200, 800) # Adjust per your expected visual dimensions
42
 
43
  # Write the srcdoc to a temporary HTML file
44
  with tempfile.NamedTemporaryFile(delete=False, suffix=".html") as tmp_file:
 
47
  file_url = "file://" + tmp_file.name
48
 
49
  driver.get(file_url)
50
+ time.sleep(5) # Allow time for JavaScript (e.g., mermaid) to render
51
 
52
  screenshot_png = driver.get_screenshot_as_png()
53
  image = Image.open(BytesIO(screenshot_png))
 
2215
  focus_html = generate_focus_snippet(instructions, context, initial_query, crumbs)
2216
  # Remove any outer HTML or body tags from the generated snippet:
2217
  focus_html = re.sub(r"<\/?(html|head|body)[^>]*>", "", focus_html, flags=re.DOTALL|re.IGNORECASE).strip()
2218
+ # Wrap the entire focus content in one div with a dedicated CSS class
2219
  return (
2220
  f'<!-- Focus {placeholder_num} Start -->'
2221
+ f'<div class="focus-placeholder">{focus_html}</div>'
 
 
2222
  f'<!-- Focus {placeholder_num} End -->'
2223
  )
2224
  except Exception as e:
 
3011
  pre, div {{ white-space: pre-wrap; }}
3012
  ol, ul {{ font-size: 11pt; margin-left: 20px; line-height: 1.5; }}
3013
  hr {{ border: 1px solid #ccc; margin: 20px 0; }}
3014
+ table {{
3015
+ border-collapse: collapse;
3016
+ width: 100%;
3017
+ margin-bottom: 10px;
3018
+ table-layout: fixed; /* force fixed layout so columns wrap */
3019
+ }}
3020
+ th, td {{
3021
+ border: 1px solid #ccc;
3022
+ padding: 8px;
3023
+ text-align: left;
3024
+ word-wrap: break-word; /* allow word wrapping */
3025
+ overflow-wrap: break-word;
3026
+ }}
3027
+ th {{
3028
+ background-color: #f2f2f2;
3029
+ }}
3030
  .page-break {{ page-break-before: always; }}
3031
+ .focus-placeholder {{
3032
+ border: 1px solid black;
3033
+ padding: 10px;
3034
+ font-size: 12pt;
3035
+ line-height: 1.6;
3036
+ margin-bottom: 10px;
3037
+ word-wrap: break-word;
3038
+ }}
3039
+ .focus-placeholder p {{
3040
+ margin: 0;
3041
+ padding: 0;
3042
+ border: none;
3043
+ }}
3044
  </style>
3045
  </head>
3046
  <body>