Syntax highlighting incorrect in Diff for PascalObject #14028

Closed
opened 2025-11-02 11:00:37 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @NeeeeB on GitHub (Jan 22, 2025).

Description

There is a problem with colors and syntax highlighting in diff for PascalObject language (maybe other too, didn't try).
This is what the diff looks like :

Image
As you can see, the 2 lines of comments (beginning with //) are not treated as comments.

The problem is not present in the code explorer where comments are properly detected :

Image

Gitea Version

1.23.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

package manager (Arch) so systemD

Database

None

Originally created by @NeeeeB on GitHub (Jan 22, 2025). ### Description There is a problem with colors and syntax highlighting in diff for PascalObject language (maybe other too, didn't try). This is what the diff looks like : ![Image](https://github.com/user-attachments/assets/d627bfc8-cde2-4775-9774-505aa6e0ba8b) As you can see, the 2 lines of comments (beginning with //) are not treated as comments. The problem is not present in the code explorer where comments are properly detected : ![Image](https://github.com/user-attachments/assets/970438af-6d06-41f3-95c9-026e6c4eaa06) ### Gitea Version 1.23.1 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? package manager (Arch) so systemD ### Database None
GiteaMirror added the type/bugtype/upstream labels 2025-11-02 11:00:37 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jan 22, 2025):

The reason is this: https://github.com/go-gitea/gitea/issues/19684#issuecomment-1158961098 and https://github.com/go-gitea/gitea/issues/21970

  • Full file highlighting: guess the syntax by file content
  • Diff highlighting: only use the file extension (then maybe it is rendered as traditional pascal but not object pascal) and highlight line by line

(Just a guess) maybe we could hard code all *.pas to use object pascal syntax as a workaround.

@wxiaoguang commented on GitHub (Jan 22, 2025): The reason is this: https://github.com/go-gitea/gitea/issues/19684#issuecomment-1158961098 and https://github.com/go-gitea/gitea/issues/21970 * Full file highlighting: guess the syntax by file content * Diff highlighting: only use the file extension (then maybe it is rendered as traditional pascal but not object pascal) and highlight line by line ~~(Just a guess) maybe we could hard code all `*.pas` to use object pascal syntax as a workaround.~~
Author
Owner

@wxiaoguang commented on GitHub (Jan 22, 2025):

Hmm, it is a upstream bug: https://github.com/alecthomas/chroma/issues/1042

@wxiaoguang commented on GitHub (Jan 22, 2025): Hmm, it is a upstream bug: https://github.com/alecthomas/chroma/issues/1042
Author
Owner

@NeeeeB commented on GitHub (Jan 22, 2025):

Yup, I was gonna reply that comments in Pascal and ObjectPascal are the same, //
Thanks for opening that issue in Chroma.

@NeeeeB commented on GitHub (Jan 22, 2025): Yup, I was gonna reply that comments in Pascal and ObjectPascal are the same, // Thanks for opening that issue in Chroma.
Author
Owner

@silverwind commented on GitHub (Jan 22, 2025):

Opened https://github.com/go-gitea/gitea/issues/33358 for discussing a general fix.

@silverwind commented on GitHub (Jan 22, 2025): Opened https://github.com/go-gitea/gitea/issues/33358 for discussing a general fix.
Author
Owner

@wxiaoguang commented on GitHub (Jan 23, 2025):

Opened #33358 for discussing a general fix.

This is another case than #33358 , this case could be fixed by upstream

@wxiaoguang commented on GitHub (Jan 23, 2025): > Opened [#33358](https://github.com/go-gitea/gitea/issues/33358) for discussing a general fix. This is another case than #33358 , this case could be fixed by upstream
Author
Owner

@silverwind commented on GitHub (Jan 23, 2025):

Yeah, that's why i left this open. A general solution with the full-file syntax highlight would also fix this issue assuming the file has more than one line and a trailing newline.

@silverwind commented on GitHub (Jan 23, 2025): Yeah, that's why i left this open. A general solution with the full-file syntax highlight would also fix this issue assuming the file has more than one line and a trailing newline.
Author
Owner

@wxiaoguang commented on GitHub (Mar 9, 2025):

After Full-file syntax highlighting for diff pages #33766 , I think this issue could also be fixed, because there is always a new line after the comment.

Feel free to reopen if there is still any problem.

@wxiaoguang commented on GitHub (Mar 9, 2025): After Full-file syntax highlighting for diff pages #33766 , I think this issue could also be fixed, because there is always a new line after the comment. Feel free to reopen if there is still any problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14028