commit 95e5d5e339dabaef85b0e353eeccdf25970c17e5
parent 1dbb2d5ebd9ef874b6336c93bddc6306d1d1b750
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 30 Jun 2026 00:00:52 +0200
fix #11554
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/_exts/typescriptdomain.py b/_exts/typescriptdomain.py
@@ -522,6 +522,15 @@ class MyPygmentsBridge(PygmentsBridge):
self.line = location.line
self.path = location.source
self.docname = self.builder.env.path2doc(self.path)
+ # The path/line above point at the source file the code block was
+ # written in (used for diagnostics). However, relative links must be
+ # computed against the document that is *currently being written* --
+ # not the (possibly ``.. include``-d) source file, which may live in a
+ # deeper directory and would inject spurious "../" segments into every
+ # cross reference. Prefer the builder's current output docname.
+ current = getattr(self.builder, "current_docname", None)
+ if current:
+ self.docname = current
return super().highlight_block(source, lang, opts, force, location, **kwargs)