diff --git a/CHANGES.rst b/CHANGES.rst index 3becdc1db2d..066e18778f8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -142,6 +142,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 87590544f6d..efc4eaa2f2c 100644 --- a/sphinx/builders/singlehtml.py +++ b/sphinx/builders/singlehtml.py @@ -41,8 +41,7 @@ def get_outdated_docs(self) -> str | list[str]: # type: ignore[override] 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