(text: str)
| 204 | |
| 205 | |
| 206 | def find_image_refs(text: str) -> list[ImageRef]: |
| 207 | search_text = mask_ignored_markdown_blocks(text) |
| 208 | refs: list[tuple[int, ImageRef]] = [] |
| 209 | for match in MARKDOWN_IMAGE_RE.finditer(search_text): |
| 210 | refs.append( |
| 211 | ( |
| 212 | match.start(), |
| 213 | ImageRef( |
| 214 | line=line_number(text, match.start()), |
| 215 | target=normalize_image_target(match.group("target")), |
| 216 | ), |
| 217 | ) |
| 218 | ) |
| 219 | |
| 220 | for match in HTML_IMG_RE.finditer(search_text): |
| 221 | src_match = HTML_SRC_RE.search(match.group(0)) |
| 222 | if not src_match: |
| 223 | continue |
| 224 | target = src_match.group("double") or src_match.group("single") or src_match.group("bare") or "" |
| 225 | refs.append( |
| 226 | ( |
| 227 | match.start(), |
| 228 | ImageRef( |
| 229 | line=line_number(text, match.start()), |
| 230 | target=normalize_image_target(target), |
| 231 | ), |
| 232 | ) |
| 233 | ) |
| 234 | |
| 235 | return [ref for _, ref in sorted(refs, key=lambda item: item[0])] |
| 236 | |
| 237 | |
| 238 | def index_has_file(path: Path) -> bool: |
no test coverage detected