Skip to content

External hyperlink produces garbled HTML when end of URL happens to overlap with name of identifier #817

Open

Description

@vrama628

Problem Description

pdoc produces incorrect HTML when trying to link to a URL whenever the end of the URL happens to be a . followed by any identifier that appears in the project. This results in HTML that displays incorrectly and links to the wrong place. This seems to happen regardless of whether the link is written via Markdown syntax or reStructuredText syntax.

Steps to reproduce the behavior:

  1. Create issue/__init__.py like this:
    def com():
        """
        [something](https://example.com)
        """
        pass
  2. Run pdoc issue to generate documentation
  3. Observe the generated documentation for the com function. It produces HTML that looks like this:
    <a href="https://example<a href=" #com"="">.com</a>"&gt;something
    which visually renders as:
    .com">something
    
    where the .com text seems to link to the invalid URL https://example<a href=.

System Information

pdoc: 15.0.4
Python: 3.11.12
Platform: macOS-15.3.1-arm64-arm-64bit

Activity

  1. elliot-100 commented on Feb 23, 2026

    @elliot-100
    Contributor

    ... when trying to link to a URL whenever the end of the URL happens to be a . followed by any identifier that appears in the project.

    Seems to occur more widely than this - if you replace the content of your test file with:

    """https://api.example.com/"""
    example = 0
    

    it renders visually as:

    .example.com/"> https://api.example.com
    example = 0
    
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions