Spaces:
Sleeping

clementBE commited on
Commit
8d45bb0
·
verified ·
1 Parent(s): b9fd23f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
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
- # HTML with JS
 
94
  html = f"""
95
- <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'>
96
- {display_text.replace('\n','<br>')}
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');