multimodalart HF Staff commited on
Commit
2b2ef11
·
verified ·
1 Parent(s): 9277e75

Fix tag highlighting: chip the escaped tag form after html.escape

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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;">{html.escape(m.group(0))}</span>'
140
  )
141
 
142
- return re.sub(r"<Image_\d+>", chip, html.escape(caption))
 
 
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 (&lt;Image_N&gt;) so the rest
143
+ # of the caption stays safely escaped while tags render as styled chips.
144
+ return re.sub(r"&lt;(Image_\d+)&gt;", chip, html.escape(caption))
145
 
146
 
147
  # ---------------------------------------------------------------------------