Skip to content

Link fixer fails to process cross-references in document body, causing malformed double-hash hrefs #123

Open

Description

@0kelvin0

Problem

When using Sphinx Python domain cross-references (:py:obj:, :type:, etc.) in a SingleHTML build with SimplePDF, the generated hrefs contain malformed double-hash patterns like:
href="#document-api_reference/python_api/mypackage/index#mypackage.MyClass"
These links don't work in the browser and error like below is also shown during build:
ERROR: No anchor #document-api_reference/python_api/mypackage/abc/index#abc.def.ghi for internal URI reference

Expected Behavior

Hrefs should contain only the anchor:
href="#mypackage.MyClass"

Minimal Reproducible Example
RST source:
`.. py:class:: MyClass

Example class.

.. py:attribute:: config
:type: MyClass

References :py:obj:MyClass.`

Configuration
Sphinx: 8.2+
sphinx-simplepdf: 1.6.0
Extensions: sphinx-autoapi (generates API docs with :py:obj: references)
Multi-project documentation build

Activity

  1. 0kelvin0 commented on Dec 19, 2025

    @0kelvin0
    Author

    Seems like it also happens when we do section label
    See :ref:some-files

  2. patrick-sil commented on Feb 17, 2026

    @patrick-sil

    I created a PR for this issue, #133
    The fix is relatively simple, but I'm sure someone with a better understanding of the internals could come up with a better solution.
    Would be nice, if this could be resolved soon, as this is a pretty version-breaking issue in my opinion.

  3. jdillard commented on Sep 30, 2026

    @jdillard
    Contributor

    This appears to be the Sphinx 8.2+ singlehtml regression addressed by sphinx-doc/sphinx#14241.

    That PR restores SingleFileHTMLBuilder.fix_refuris() calls for the assembled document and TOCs, preventing links such as #document-path#real-anchor from reaching the HTML output. Since SimplePDF inherits this builder, it should benefit from the upstream fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions