Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,22 +78,18 @@ def process_file(file_obj):
|
|
| 78 |
# BUILD HTML TRANSCRIPT
|
| 79 |
# ------------------------------
|
| 80 |
def build_html_transcript(text, coded_df):
|
| 81 |
-
"""
|
| 82 |
-
Return HTML with optional colored highlights for coded segments.
|
| 83 |
-
Also inject JS to auto-fill segment box when user highlights text.
|
| 84 |
-
"""
|
| 85 |
display_text = text
|
| 86 |
if coded_df is not None and not coded_df.empty:
|
| 87 |
-
# sort by start index to avoid overlapping HTML issues
|
| 88 |
for _, row in coded_df.iterrows():
|
| 89 |
seg = row["Coded Segment"]
|
| 90 |
color = COLOR_MAP.get(row["Code"], "yellow")
|
| 91 |
display_text = display_text.replace(seg, f"<span style='background-color:{color}'>{seg}</span>", 1)
|
| 92 |
|
| 93 |
-
|
|
|
|
| 94 |
html = f"""
|
| 95 |
-
<div style='white-space: pre-wrap; font-size:
|
| 96 |
-
{
|
| 97 |
</div>
|
| 98 |
<script>
|
| 99 |
const transcript = document.getElementById('transcript');
|
|
|
|
| 78 |
# BUILD HTML TRANSCRIPT
|
| 79 |
# ------------------------------
|
| 80 |
def build_html_transcript(text, coded_df):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
display_text = text
|
| 82 |
if coded_df is not None and not coded_df.empty:
|
|
|
|
| 83 |
for _, row in coded_df.iterrows():
|
| 84 |
seg = row["Coded Segment"]
|
| 85 |
color = COLOR_MAP.get(row["Code"], "yellow")
|
| 86 |
display_text = display_text.replace(seg, f"<span style='background-color:{color}'>{seg}</span>", 1)
|
| 87 |
|
| 88 |
+
safe_text = display_text.replace("\n", "<br>")
|
| 89 |
+
|
| 90 |
html = f"""
|
| 91 |
+
<div style='white-space: pre-wrap; font-size:16px; line-height:1.5; max-height:600px; overflow:auto; border:1px solid #ccc; padding:5px;' id='transcript'>
|
| 92 |
+
{safe_text}
|
| 93 |
</div>
|
| 94 |
<script>
|
| 95 |
const transcript = document.getElementById('transcript');
|