SwiftPackageIndex / SwiftPackageIndex-Server

The Swift Package Index is the place to find Swift packages!
https://swiftpackageindex.com
Apache License 2.0
538 stars 42 forks source link

Anchor links in Readme files are broken #3300

Closed ZevEisenberg closed 3 weeks ago

ZevEisenberg commented 3 weeks ago

Please describe the bug

In a repo's readme, you can make an anchor link specified like [Link Name](#AnchorName), where #AnchorName corresponds to a Markdown heading. On GitHub, this is correctly translated into an HTML anchor link that scrolls the page to the relevant section. But when that readme is displayed on the Swift Package Index, the link destination has user-content- prepended to it, which makes it not work.

Explain the steps needed to reproduce the bug

  1. Go to https://github.com/pointfreeco/swift-url-routing (for example).
  2. Look at the list of anchor links near the top of the readme, and hover over the Documetation link.
  3. Note that your browser's link preview bar (if visible) says "Go to #Documentation on this page".
  4. Click the link and see that it navigates to the Documentation section.
  5. Go to the same project on the Swift Package Index at https://swiftpackageindex.com/pointfreeco/swift-url-routing.
  6. Hover over the Documentation link in the readme.
  7. Note that your browser's link preview bar says "Go to #user-content-Documentation on this page"
  8. Click the link.

What was the expected behaviour?

Page scrolls or jumps down to the Documentation section.

Screenshots

If applicable, please add screenshots to help explain your problem.

What web browser were you using? (if relevant)

Safari

If you're reporting a bug with the front end, please include your browser information below:

Additional context

daveverwer commented 3 weeks ago

Ah, thanks for reporting this, @ZevEisenberg! This must have changed on the GitHub side, as we have some processing code that's supposed to fix them, and they certainly worked until recently. I'll take a look to see what has changed.

I've been reluctant to put a snapshot test in that snapshots the GitHub README API response so we can be aware of rendering changes as I bet it changes all the time. That said, maybe a separate little tool that I run every few weeks might be a good idea.

daveverwer commented 3 weeks ago

This is now fixed and deployed to production. Thanks again for the bug report, @ZevEisenberg!