Skip to content

bug: Spaces and slashes not supported in autorefs identifiers #55

@pawamoy

Description

@pawamoy

Description of the bug

Currently we ignore identifiers that contain a space or a slash. This is problematic because object inventories allow spaces and slashes in object names. For example we find the following entry in Python's object inventory:

type hint std:term -1 glossary.html#term-type-hint -

Here type hint is the identifier that we would use to reference the glossary.html#term-type-hint page and anchor.

To Reproduce

In a MkDocs project, enable the mkdocstrings plugin, and load the Python objects inventory with std and py domains:

plugins:
- mkdocstrings:
    handlers:
      python:
        import:
        - url: https://docs.python.org/3/objects.inv
          domains: [std, py]

Add the following cross-ref to your pages, observe that it isn't resolved and rendered:

Link to [type hint][].

Full traceback

/

Expected behavior

Cross-ref should be resolved.

Environment information

python -m mkdocs_autorefs.debug  # | xclip -selection clipboard
  • System: Linux-6.10.6-arch1-1-x86_64-with-glibc2.40
  • Python: cpython 3.11.5 (/media/data/dev/mkdocs-autorefs/.venv/bin/python)
  • Environment variables:
    • PYTHONPATH: /home/pawamoy/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/pep582
  • Installed packages:
    • mkdocs-autorefs v1.0.2.dev12+g57998bf.d20240820

Additional context

Reported on Gitter/Matrix: https://matrix.to/#/!xiyyvEeLIRaWsNQixq:gitter.im/$3QyUA6E7tZIoO7azaDgjFDZ14KXVpcxaHp7Got6RkaQ?via=gitter.im&via=matrix.org

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions