Skip to content

Conversation

@silverwind
Copy link
Member

@silverwind silverwind commented Oct 29, 2025

  1. Add the color on the link to the referenced file, which is the more likely thing the user wants to click
  2. Use monospace font on the SHA
  3. Tweak text colors
  4. Change SHA link to go to the commit instead of the repo root with commit filter set
  5. Added the repo name to the file link text
  6. Fix broken line numbering rendering

The only major difference to GitHub is now the missing line numbers.

Before:

Screenshot 2025-10-29 at 19 09 59

After:

image

For comparison, GitHub rendering:

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 29, 2025
@github-actions github-actions bot added modifies/templates This PR modifies the template files modifies/frontend labels Oct 29, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Oct 29, 2025
@silverwind
Copy link
Member Author

silverwind commented Oct 30, 2025

Regarding line numbers, maybe there is some bug. I see this in the template but they don't render:

<td class="lines-num"><span data-line-number="{{$line.Num}}"></span></td>

@silverwind
Copy link
Member Author

silverwind commented Oct 30, 2025

Line numbers are fixed as well, the markup sanitizer was stripping the data-line-number attribute. The fix is probably not ideal because I don't think we should sanitize HTML coming from our own template renderer.

image

Also as per screenshots in #30234, line numbers were intially working, so this must have regressed at some point.

@silverwind silverwind changed the title Improve markup code preview rendering Improve and fix markup code preview rendering Oct 30, 2025
@silverwind silverwind added the backport/v1.24 This PR should be backported to Gitea 1.24 label Oct 30, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 30, 2025
@wxiaoguang wxiaoguang removed the backport/v1.24 This PR should be backported to Gitea 1.24 label Oct 30, 2025
@wxiaoguang
Copy link
Contributor

I think no need to backport to 1.24 since 1.25 has released.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 30, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) October 30, 2025 04:46
@wxiaoguang wxiaoguang merged commit 8b290b8 into go-gitea:main Oct 30, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Oct 30, 2025
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Oct 30, 2025
1. Add the color on the link to the referenced file, which is the more
likely thing the user wants to click
2. Use monospace font on the SHA
3. Tweak text colors
4. Change SHA link to go to the commit instead of the repo root with
commit filter set
5. Added the repo name to the file link text
6. Fix broken line numbering rendering
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Oct 30, 2025
@silverwind silverwind deleted the impprev branch October 30, 2025 07:49
silverwind added a commit that referenced this pull request Oct 30, 2025
Backport #35777 by @silverwind

1. Add the color on the link to the referenced file, which is the more
likely thing the user wants to click
2. Use monospace font on the SHA
3. Tweak text colors
4. Change SHA link to go to the commit instead of the repo root with
commit filter set
5. Added the repo name to the file link text
6. Fix broken line numbering rendering

The only major difference to GitHub is now the missing line numbers.

Before:

<img width="286" height="162" alt="Screenshot 2025-10-29 at 19 09 59"
src="https://github.com/user-attachments/assets/f16b4eec-caf2-4c31-a2b5-ae5f41747d4b"
/>

After:

<img width="378" height="157" alt="image"
src="https://github.com/user-attachments/assets/0c91dfd3-0910-4b2d-a43b-8c87cfbb933e"
/>

For comparison, GitHub rendering:

<img width="286" height="177" alt="image"
src="https://github.com/user-attachments/assets/8a9a07b7-9153-4415-9d7a-5685853e472a"
/>

Co-authored-by: silverwind <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants