Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user-content- prefix of user-generated IDs in markup breaks anchored links between files or wiki pages #12062

Closed
2 of 7 tasks
AnneLaureF opened this issue Jun 26, 2020 · 3 comments
Labels
topic/ui Change the appearance of the Gitea UI
Milestone

Comments

@AnneLaureF
Copy link

AnneLaureF commented Jun 26, 2020

Description

Since #9477 the web interface adds a "user-content-" prefix to IDs in markup files.
The internal links [link to internal anchor](#my-anchor) are correctly updated with the prefix, but links to an anchor of another file are not. This makes the link point to a non existing ID and navigation ends up at the top of the other page.

This breaks navigation between long markup files.
Tested with markdown files in repository, and in the wiki pages, as you can see in the test repo https://try.gitea.io/annelauref/TEST_prefix_ID

I think a solution would be to add the prefix to anchors in relative links.

Edited to say: manually adding user-content- to links between file could be a workaround for some repos but it is confusing (needed for some links but no all) and breaks compatibility with at least Github (for me it's happening on a repo that has multiple remotes, one on an internal Gitea server and one on Github)

Screenshots

As you can see in this image, this link is not rewritten:
image

But the anchor in the other file is rewritten:
image

@lafriks
Copy link
Member

lafriks commented Jun 26, 2020

I think #11903 should fix this

@AnneLaureF
Copy link
Author

Oh great, I tried searching everywhere but obviously didn't use the right keywords. Thank you for pointing me to the right place.
I'll wait patiently for 1.13.0 then :)

@silverwind
Copy link
Member

silverwind commented Jun 26, 2020

Yes, #11903 will make anchors from URL work with and without the user-content- prefix. The feature does require JS to be enabled, but that applies to GitHub's links too.

silverwind added a commit to silverwind/gitea that referenced this issue Jun 26, 2020
This changes the links on headings like '# Usage' in markdown from

  `https://host/user/repo#user-content-usage`

to just

  `https://host/user/repo#usage`

matching GitHub and GitLab. The linked id elements still have the prefix
and this behaviour matches GitHub and GitLab too, so JS is needed to
scroll to the active anchor. I suspect it's like that to avoid namespace
collission between user-generated content and other page content.
Compatibilty for old links is included so they will continue to work.

Also included are some enhancements to make the clickable area for the
link icon larger and fix its color on arc-green.

Fixes: go-gitea#11896
Fixes: go-gitea#12062
@lunny lunny closed this as completed in 9c54fef Jun 26, 2020
@lafriks lafriks added the topic/ui Change the appearance of the Gitea UI label Jun 26, 2020
@lafriks lafriks added this to the 1.13.0 milestone Jun 26, 2020
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
This changes the links on headings like '# Usage' in markdown from

  `https://host/user/repo#user-content-usage`

to just

  `https://host/user/repo#usage`

matching GitHub and GitLab. The linked id elements still have the prefix
and this behaviour matches GitHub and GitLab too, so JS is needed to
scroll to the active anchor. I suspect it's like that to avoid namespace
collission between user-generated content and other page content.
Compatibilty for old links is included so they will continue to work.

Also included are some enhancements to make the clickable area for the
link icon larger and fix its color on arc-green.

Fixes: go-gitea#11896
Fixes: go-gitea#12062
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

No branches or pull requests

3 participants