Commit Graph

5 Commits

Author SHA1 Message Date
Alaa Abdelwahab
e77c1c26e5 feat(diff): add rendered diff view for markup files (#40509)
Markdown, org-mode and other inline-rendered markup files get a
source/rendered toggle in commit, compare and pull request diffs, like
images and CSV. Source stays the default, matching GitHub. The rendered
diff is fetched when opened, and only offered when both the old and the
new name are markup files.

The rendered diff follows GitHub's rich diff: changed blocks get a
colored bar, words are marked inline, formatting-only changes are
underlined, code blocks are compared by line and tables by cell, with a
whole replacement when the columns of a table or row change. Math,
mermaid and emoji are shown as removed and added whole, and invisible
characters are escaped like in the source diff. A diff that takes too
long is reported like a suppressed source diff. Wiki diffs get no
toggle, and the rendered diff tab in the web editor is left for a
follow-up.

| Change | Rendered diff |
| --- | --- |
| Source stays the default | <img width="600" alt="Source stays the
default"
src="https://github.com/user-attachments/assets/87b140a6-4228-4514-8806-6897aeace766"
/> |
| Paragraphs and words | <img width="600" alt="Paragraphs and words"
src="https://github.com/user-attachments/assets/e9c3b969-fb54-43b8-a167-364a81959015"
/> |
| Formatting, links and tasks | <img width="600" alt="Formatting, links
and tasks"
src="https://github.com/user-attachments/assets/2582db39-8d28-44e1-bc19-1128f259f070"
/> |
| Lists | <img width="600" alt="Lists"
src="https://github.com/user-attachments/assets/23868a95-da05-4c41-a329-b8a06b6a94ad"
/> |
| Tables | <img width="600" alt="Tables"
src="https://github.com/user-attachments/assets/ac924a0c-33df-4d89-af2d-bb2d74309d17"
/> |
| Code blocks | <img width="600" alt="Code blocks"
src="https://github.com/user-attachments/assets/4a756005-ebf8-418f-a5a5-50520ef2ac4f"
/> |
| Math and mermaid | <img width="600" alt="Math and mermaid"
src="https://github.com/user-attachments/assets/d1c6c96f-e7f4-4ed2-9744-8677fda68bbe"
/> |

This supersedes https://github.com/go-gitea/gitea/pull/37167, whose
review raised the block-level and math/mermaid cases.

Fixes: https://github.com/go-gitea/gitea/issues/21633

Assisted-by: Claude Code:claude-opus-5-5

---------

Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-11-27 12:50:14 +00:00
schop-rob
497e169398 fix(diff): load both blobs of renamed files for diff rendering (#39969)
When opening a pull request that renamed a CSV file:
the compare page fails with a 500.

Fix: load the left blob for every file that was not added, and the right blob
(from `Name`) for every file that was not deleted. That matches what the
templates did before #38517.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-24 08:44:16 +00:00
silverwind
eb4468ff4e enhance!: raise minimum git version to 2.34 (#39565)
Raise the minimum git version to 2.34, the version in Ubuntu 22.04,
Debian 12 and RHEL 8 ship newer, and remove the fallbacks it makes
obsolete.

- Always enable AGit
- Use `diff --skip-to` and `apply -3` unconditionally
- Set the default branch of new repos and wikis via `git init
--initial-branch`
- Detect rebase conflicts via `REBASE_HEAD`
2026-10-04 16:26:14 +08:00
wxiaoguang
a7df0d5f41 fix: git diff blob excerpt (#38808)
1. refactor the legacy code and add more comments, remove the "+1/-1"
tricks, clarify the BuildBlobExcerptDiffSection behavior
2. fix a line-counting bug (see screenshot below)
2026-08-07 02:44:55 +00:00
wxiaoguang
7f7dc2d16c chore: fix git diff render (#38746)
Fix a regression from #38517 (the tail section index is not correctly
assigned).

And add a test to cover GetDiffForRender.
2026-08-02 19:34:26 +02:00