diff --git a/CHANGES.rst b/CHANGES.rst index a02119c1e..8632ec5ad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -147,6 +147,9 @@ Bugs fixed * #12040: HTML Search: Ensure that document titles that are partially-matched by the user search query are included in search results. Patch by James Addison. +* #11970: singlehtml builder: make target URIs to be same-document references in + the sense of :rfc:`RFC 3986, ยง4.4 <3986#section-4.4>`, e.g., ``index.html#foo`` + becomes ``#foo``. Patch by eanorige. Testing ------- diff --git a/sphinx/builders/singlehtml.py b/sphinx/builders/singlehtml.py index 87590544f..efc4eaa2f 100644 --- a/sphinx/builders/singlehtml.py +++ b/sphinx/builders/singlehtml.py @@ -41,8 +41,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder): def get_target_uri(self, docname: str, typ: str | None = None) -> str: if docname in self.env.all_docs: # all references are on the same page... - return self.config.root_doc + self.out_suffix + \ - '#document-' + docname + return '#document-' + docname else: # chances are this is a html_additional_page return docname + self.out_suffix