mkdocstrings / autorefs

Automatically link across pages in MkDocs.
https://mkdocstrings.github.io/autorefs/
ISC License
51 stars 7 forks source link

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

Closed pawamoy closed 2 months ago

pawamoy commented 2 months ago

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

Additional context

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