Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -307,9 +307,11 @@ def build_resource_cards() -> str:
|
|
| 307 |
|
| 308 |
# Build grouped HTML
|
| 309 |
groups = []
|
|
|
|
| 310 |
for cat, sections in sorted(by_category.items()):
|
|
|
|
| 311 |
groups.append(
|
| 312 |
-
f"<details
|
| 313 |
)
|
| 314 |
|
| 315 |
return "".join(groups)
|
|
@@ -317,15 +319,33 @@ def build_resource_cards() -> str:
|
|
| 317 |
|
| 318 |
def extract_links_markdown_to_html(text: str) -> str:
|
| 319 |
import re
|
|
|
|
| 320 |
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
return "<i>No links found in the last response.</i>"
|
|
|
|
| 326 |
items = []
|
| 327 |
-
for
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
| 329 |
return f"<ul>{''.join(items)}</ul>"
|
| 330 |
|
| 331 |
|
|
|
|
| 307 |
|
| 308 |
# Build grouped HTML
|
| 309 |
groups = []
|
| 310 |
+
default_collapsed = {"tmresources", "environments", "whomtocontact"}
|
| 311 |
for cat, sections in sorted(by_category.items()):
|
| 312 |
+
open_attr = "" if cat.strip().lower() in default_collapsed else " open"
|
| 313 |
groups.append(
|
| 314 |
+
f"<details{open_attr} class=\"group\"><summary>{cat}</summary>{''.join(sections)}</details>"
|
| 315 |
)
|
| 316 |
|
| 317 |
return "".join(groups)
|
|
|
|
| 319 |
|
| 320 |
def extract_links_markdown_to_html(text: str) -> str:
|
| 321 |
import re
|
| 322 |
+
from html import escape
|
| 323 |
|
| 324 |
+
content = text or ""
|
| 325 |
+
|
| 326 |
+
# First: markdown links [label](url)
|
| 327 |
+
md_link_re = re.compile(r"\[([^\]]+)\]\((https?://[^\s)]+)\)")
|
| 328 |
+
seen: dict[str, str] = {}
|
| 329 |
+
for label, url in md_link_re.findall(content):
|
| 330 |
+
label = label.strip()
|
| 331 |
+
seen.setdefault(url, label if label else url)
|
| 332 |
+
|
| 333 |
+
# Then: bare URLs not already captured
|
| 334 |
+
url_re = re.compile(r"(?<!\()https?://[^\s)]+")
|
| 335 |
+
for m in url_re.finditer(content):
|
| 336 |
+
url = m.group(0)
|
| 337 |
+
if url not in seen:
|
| 338 |
+
seen[url] = url
|
| 339 |
+
|
| 340 |
+
if not seen:
|
| 341 |
return "<i>No links found in the last response.</i>"
|
| 342 |
+
|
| 343 |
items = []
|
| 344 |
+
for url, label in seen.items():
|
| 345 |
+
icon = make_icon(url)
|
| 346 |
+
items.append(
|
| 347 |
+
f"<li>{icon} <a href=\"{url}\" target=\"_blank\" rel=\"noopener noreferrer\">{escape(label)}</a></li>"
|
| 348 |
+
)
|
| 349 |
return f"<ul>{''.join(items)}</ul>"
|
| 350 |
|
| 351 |
|