-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
user-content- prefix of user-generated IDs in markup breaks anchored links between files or wiki pages #12062
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
Closed
2 of 7 tasks
Comments
I think #11903 should fix this |
Oh great, I tried searching everywhere but obviously didn't use the right keywords. Thank you for pointing me to the right place. |
Yes, #11903 will make anchors from URL work with and without the |
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
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Uh oh!
There was an error while loading. Please reload this page.
[x]
):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:

But the anchor in the other file is rewritten:

The text was updated successfully, but these errors were encountered: