AIRider commited on
Commit
36c388a
ยท
verified ยท
1 Parent(s): 23b09fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -25
app.py CHANGED
@@ -155,43 +155,22 @@ def analyze(url):
155
  # ์š”์•ฝ ์ƒ์„ฑ
156
  summary = summarize_text(title, description, script)
157
 
158
- # HTML ๋ณ€ํ™˜ ๋ฐ ์ด์Šค์ผ€์ดํ”„ ์ฒ˜๋ฆฌ
159
- def escape_html_except_highlights(text):
160
- parts = text.split('<highlight>')
161
- escaped_parts = []
162
- for i, part in enumerate(parts):
163
- if i % 2 == 0: # ํ•˜์ด๋ผ์ดํŠธ ํƒœ๊ทธ ์™ธ๋ถ€
164
- escaped_parts.append(html.escape(part))
165
- else: # ํ•˜์ด๋ผ์ดํŠธ ํƒœ๊ทธ ๋‚ด๋ถ€
166
- highlight_parts = part.split('</highlight>')
167
- if len(highlight_parts) > 1:
168
- escaped_parts.append(f'<span class="highlight">{html.escape(highlight_parts[0])}</span>{html.escape(highlight_parts[1])}')
169
- else:
170
- escaped_parts.append(html.escape(part))
171
- return ''.join(escaped_parts)
172
-
173
  lines = summary.split('\n')
174
  formatted_lines = []
175
  for line in lines:
176
  if line.startswith('# '):
177
- line = f"<h1>{escape_html_except_highlights(line[2:])}</h1>"
178
  elif line.startswith('## '):
179
- line = f"<h2>{escape_html_except_highlights(line[3:])}</h2>"
180
  elif line.startswith('### '):
181
- line = f"<h3>{escape_html_except_highlights(line[4:])}</h3>"
182
  else:
183
- line = f"<p>{escape_html_except_highlights(line)}</p>"
184
  formatted_lines.append(line)
185
 
186
  formatted_summary = '\n'.join(formatted_lines)
187
 
188
  summary_content = f"""<div style="background-color: #e6f3ff; padding: 20px; border-radius: 10px; margin-top: 20px;">
189
- <style>
190
- .highlight {{
191
- background-color: #FFDAB9;
192
- font-weight: bold;
193
- }}
194
- </style>
195
  <h3>์š”์•ฝ</h3>
196
  <h2>{html.escape(title)}</h2>
197
  {formatted_summary}
 
155
  # ์š”์•ฝ ์ƒ์„ฑ
156
  summary = summarize_text(title, description, script)
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  lines = summary.split('\n')
159
  formatted_lines = []
160
  for line in lines:
161
  if line.startswith('# '):
162
+ line = f"<h1>{html.escape(line[2:])}</h1>"
163
  elif line.startswith('## '):
164
+ line = f"<h2>{html.escape(line[3:])}</h2>"
165
  elif line.startswith('### '):
166
+ line = f"<h3>{html.escape(line[4:])}</h3>"
167
  else:
168
+ line = f"<p>{html.escape(line)}</p>"
169
  formatted_lines.append(line)
170
 
171
  formatted_summary = '\n'.join(formatted_lines)
172
 
173
  summary_content = f"""<div style="background-color: #e6f3ff; padding: 20px; border-radius: 10px; margin-top: 20px;">
 
 
 
 
 
 
174
  <h3>์š”์•ฝ</h3>
175
  <h2>{html.escape(title)}</h2>
176
  {formatted_summary}