Spaces:
Running on Zero
Running on Zero
Fix tag highlighting: chip the escaped tag form after html.escape
Browse files
app.py
CHANGED
|
@@ -136,10 +136,12 @@ def highlight_tags(caption: str) -> str:
|
|
| 136 |
return (
|
| 137 |
f'<span style="background:rgba(99,102,241,.18);border:1px solid rgba(99,102,241,.55);'
|
| 138 |
f'border-radius:6px;padding:0 6px;margin:0 2px;font-family:monospace;'
|
| 139 |
-
f'font-size:.92em;color:var(--body-text-color);white-space:nowrap;">{
|
| 140 |
)
|
| 141 |
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
|
| 144 |
|
| 145 |
# ---------------------------------------------------------------------------
|
|
|
|
| 136 |
return (
|
| 137 |
f'<span style="background:rgba(99,102,241,.18);border:1px solid rgba(99,102,241,.55);'
|
| 138 |
f'border-radius:6px;padding:0 6px;margin:0 2px;font-family:monospace;'
|
| 139 |
+
f'font-size:.92em;color:var(--body-text-color);white-space:nowrap;">{m.group(0)}</span>'
|
| 140 |
)
|
| 141 |
|
| 142 |
+
# Escape first, then chip the escaped tag form (<Image_N>) so the rest
|
| 143 |
+
# of the caption stays safely escaped while tags render as styled chips.
|
| 144 |
+
return re.sub(r"<(Image_\d+)>", chip, html.escape(caption))
|
| 145 |
|
| 146 |
|
| 147 |
# ---------------------------------------------------------------------------
|