MCPcopy Create free account
hub / github.com/DevCloudNinjas/DevOps-Projects / replace

Function replace

tools/build_starlight_content.py:436–451  ·  view source on GitHub ↗
(match: re.Match[str])

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

site_pathFunction · 0.85

Tested by

no test coverage detected