Spaces:
Running
Running
Update app.py
Browse files
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>{
|
178 |
elif line.startswith('## '):
|
179 |
-
line = f"<h2>{
|
180 |
elif line.startswith('### '):
|
181 |
-
line = f"<h3>{
|
182 |
else:
|
183 |
-
line = f"<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}
|