MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / find_image_refs

Function find_image_refs

scripts/check_article_quality.py:206–235  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

204
205
206def 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
238def index_has_file(path: Path) -> bool:

Callers 1

check_imagesFunction · 0.85

Calls 4

ImageRefClass · 0.85
line_numberFunction · 0.85
normalize_image_targetFunction · 0.85

Tested by

no test coverage detected