(match: re.Match[str])
| 487 | return f"" |
| 488 | |
| 489 | def replace_link(match: re.Match[str]) -> str: |
| 490 | label, raw_target = match.group(1), match.group(2) |
| 491 | target, title = split_markdown_destination(raw_target) |
| 492 | if is_external_or_anchor(target): |
| 493 | if is_same_repo_source_url(target, project_dir): |
| 494 | return f"[{label}](#source-files-on-github)" |
| 495 | if target.startswith(("http://", "https://")): |
| 496 | return external_link(label, target) |
| 497 | return match.group(0) |
| 498 | source_path, fragment = repo_source_path(project_dir, target) |
| 499 | if source_path.lower() in {f"{project_dir}/readme.md", "readme.md", ""}: |
| 500 | anchor = f"#{fragment}" if fragment else "#_top" |
| 501 | return f"[{label}]({anchor})" |
| 502 | return f"[{label}](#source-files-on-github)" |
| 503 | |
| 504 | text = re.sub(r"!\[([^\]]*)\]\(([^)]+)\)", replace_image, text) |
| 505 | text = re.sub(r"(?<!!)\[([^\]]+)\]\(([^)]+)\)", replace_link, text) |
nothing calls this directly
no test coverage detected