Skip to content

DocC renderer incompatible with :~:text= fragments #735

Open
@gwynne

Description

@gwynne

Description

In the present day, all of the major browsers have support for what MDN refers to as text fragments, which allow linking to any location on a given page - regardless of whether that location has an associated <a name=""> element - by specifying particular text on that page.

The short of it is, text fragments don't work in DocC catalogs. This is presumably related to the implementation of src/mixins/onPageLoadScrollToFragment.js.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

Navigating to a link pointing to DocC documentation which includes a text fragment should scroll to the first occurrence of that text on the page in question.

Actual behavior

The top of the page is displayed. If using Safari, the URL in the address bar is reset to have an empty fragment (e.g., just #).

Steps To Reproduce

  1. Using any recent version of Safari, navigate to https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes#:~:text=buildPartialBlock.

Swift-DocC-Render Version Information

b6cf582

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