fix: preserve root-relative links when moving debt entries

This commit is contained in:
MrMha committed 2026-10-17 18:40:23 +04:00
1 parent 82f0c9aec9
commit 14c2b0bd46
2 files changed
+12 -1

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@ def key(kind, text):
def relink(text, source, destination):
def replace(match):
target = match.group(1)
if re.match(r"^[A-Za-z][A-Za-z0-9+.-]*:|//", target):
if re.match(r"^[A-Za-z][A-Za-z0-9+.-]*:|/", target):
return match.group(0)
path, _, anchor = target.partition("#")
resolved = posixpath.normpath(posixpath.join(posixpath.dirname(source), path)) if path else source
+11
View File
@@ -25,6 +25,17 @@ ORIGINAL = index([A_STUB, B_STUB, C_STUB], [A_FUNCTIONAL, SHADER, SHARED])
class DebtSplitTests(unittest.TestCase):
def test_split_preserves_root_relative_links(self):
targets = ("/AnyPS5/guide.html#usage", "/images/example.png", "/")
references = " ".join(f"[reference]({target})" for target in targets)
self.write(INDEX, ORIGINAL.replace(A_STUB, A_STUB + " " + references))
self.split()
moved = self.read("docs/dev/debt/libSceA.md")
for target in targets:
with self.subTest(target=target):
self.assertIn(f"[reference]({target})", moved)
self.assertIn("../../../core/libs/prx/libSceA/Export.cpp", moved)
def setUp(self):
self.directory = tempfile.TemporaryDirectory()
self.root = Path(self.directory.name)