(raw: str)
| 190 | |
| 191 | |
| 192 | def normalize_image_target(raw: str) -> str: |
| 193 | target = html.unescape(raw).strip() |
| 194 | if target.startswith("<") and ">" in target: |
| 195 | return target[1 : target.index(">")].strip() |
| 196 | |
| 197 | for quote in ('"', "'"): |
| 198 | marker = f" {quote}" |
| 199 | if marker in target and target.endswith(quote): |
| 200 | candidate = target[: target.rfind(marker)].strip() |
| 201 | if candidate: |
| 202 | return candidate |
| 203 | return target |
| 204 | |
| 205 | |
| 206 | def find_image_refs(text: str) -> list[ImageRef]: |