Skip to content

project: links fall back to external intersphinx references when local targets are missing #1235

Open

Description

@vivodi

What version of myst-parser are you using?

5.2.0

What version dependencies are you using?

docutils: 0.23
sphinx: 9.2.0

What operating system are you using?

Windows

Describe the Bug

When a reference target does not exist in the current project, using the project: scheme does not prevent MyST-Parser from resolving the reference against external Intersphinx inventories.

For example, consider the following Markdown link:

[Input](project:#input)

If the current project does not define a reference target named input, but intersphinx_mapping is configured as follows:

intersphinx_mapping = {
    'python': ('https://docs.python.org/3', None),
}

MyST-Parser still resolves the reference to the external Python documentation:

https://docs.python.org/3/builtins/functions.html#input

This happens because the external inventory contains python:py:function:input.

Expected Behavior

The project: scheme should restrict reference resolution to the current project. If the specified reference target does not exist in the current project, MyST-Parser should report a warning or error indicating that the reference target could not be found, rather than silently resolving it against an external Intersphinx inventory.

To Reproduce

  1. Create a Sphinx project with MyST-Parser enabled.

  2. Configure Intersphinx:

    intersphinx_mapping = {
        'python': ('https://docs.python.org/3', None),
    }
  3. Ensure that the project does not define a reference target named input.

  4. Add the following link to a Markdown document:

    [Input](project:#input)
  5. Build the documentation.

Actual behavior: The link resolves to the external Python input() documentation.

Expected behavior: A warning or error is reported because the reference target does not exist in the current project.

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions