(match: re.Match[str])
| 434 | ) |
| 435 | |
| 436 | def replace(match: re.Match[str]) -> str: |
| 437 | target = match.group("target") |
| 438 | if target.startswith(f"{SITE_BASE}/"): |
| 439 | doc_path = target[len(SITE_BASE) + 1 :] |
| 440 | elif target.startswith("/"): |
| 441 | doc_path = target.lstrip("/") |
| 442 | else: |
| 443 | doc_path = posixpath.normpath((source_relative.parent / target).as_posix()) |
| 444 | |
| 445 | route = doc_path.removesuffix(".md") |
| 446 | if route.endswith("/index"): |
| 447 | route = route[: -len("/index")] |
| 448 | href = site_path(f"/{route}/") |
| 449 | if match.group("anchor"): |
| 450 | href += match.group("anchor") |
| 451 | return f"{match.group('prefix')}{href}{match.group('suffix')}" |
| 452 | |
| 453 | return doc_link.sub(replace, text) |
| 454 |
nothing calls this directly
no test coverage detected