Skip to content

linkcheck incorrectly splits anchor if # is part of URI #11446

@rsokolewicz

Description

@rsokolewicz

Describe the bug

I wanted to add the URL https://microsoft.github.io/pyright/#/type-concepts-advanced to my documentation, but when running the link check, sphinx-build -b linkcheck . _build I get an error message:

(           index: line    5) broken    https://microsoft.github.io/pyright/#/type-concepts-advanced - Anchor '/type-concepts-advanced' not found

In this case, the URL is split by # and the entire righthand part is assigned as an anchor, while the # does not designate an anchor but is just part of the directory path.

How to Reproduce

minimal reproducible example:

conf.py

# Add the following import at the top of the file
import sphinx.ext.extlinks

# Project information
project = "My Project"
author = "Your Name"

# Extensions
extensions = [
    "sphinx.ext.extlinks",  # Add the extension here
]

# Define your external link patterns
extlinks = {
    "url": ("%s", None),  # Define the 'url' role pattern
}

# Theme
html_theme = "alabaster"

index.rst

title
-----


:url:`https://microsoft.github.io/pyright/#/type-concepts-advanced`

and running sphinx-build -b linkcheck . _build in the same directory.

Environment Information

running with `sphinx==7.0.1`.

Sphinx extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions