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

Markdown anchors should not have user-content- prefix in href #11896

Closed
silverwind opened this issue Jun 15, 2020 · 0 comments · Fixed by #11903
Closed

Markdown anchors should not have user-content- prefix in href #11896

silverwind opened this issue Jun 15, 2020 · 0 comments · Fixed by #11903
Labels
topic/ui Change the appearance of the Gitea UI
Milestone

Comments

@silverwind
Copy link
Member

silverwind commented Jun 15, 2020

A heading like # Usage generates a anchor user-content-usage-example with same href which is rather ugly in shared links:

<h2 id="user-content-usage">Usage<a href="#user-content-usage"></a></h2>

GitHub and GitLab both do:

<h2><a id="user-content-usage" href="#usage"></a>Usage</h2>

I think we should follow and also omit the user-content prefix in href. This could be a breaking change, but I think we could maybe support both cases to not break existing links.

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 pushed a commit 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: #11896
Fixes: #12062
@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

Successfully merging a pull request may close this issue.

2 participants