-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
PHP Syntax Highlighting does not working in review mode #21970
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
Comments
Syntax highlight works on edit/view file page: https://try.gitea.io/den/test/src/commit/8877ea0e117b428f22e72ee3f2908603ef88182c/testphp2.php |
IMO it's similar to this one: #19684 (comment) When Gitea renders the diff page, it calls the syntax highlighter line by line, then the highlighter can not work properly. Just my guess. |
Can syntax highlighter check at least file name extension and try to highlight it line by line?
|
My guess is: the PHP syntax highlighter needs to see a I haven't looked into the code. Just FYI. |
@wxiaoguang is right here. I am fairly certain that the correct lexer will be being selected here - the issue is that without the lexer seeing the Now, the only way to fix that would be to search backwards until you find the start of the block, which essentially requires one to lex the whole of the document and not just the fragment. Whilst that would be fine for small files it's not gonna work very nicely for big files. |
@zeripath |
If missing |
same problem |
+1 |
I debugged it. It doesn't know the correct lexer to use for the file. So it let's chroma guess. But Chroma prefers phtml over php. Which results in no real syntax highlighting. |
Lets continue in #33358 regarding the problem with line-by-line syntax highlighting. |
It is another different case than #33358, because chroma requires php file to start with Although 33358 could help, but I think for this case, upstream or we could have a quick solution. |
Fix go-gitea#33358, fix go-gitea#21970 This adds a step in the `GitDiffForRender` that does syntax highlighting for the entire file and then only references lines from that syntax highlighted code. This allows things like multi-line comments to be syntax highlighted correctly. --------- Co-authored-by: wxiaoguang <[email protected]> (cherry picked from commit 3f1f808)
Description
Hello
PHP syntax highlighting does not working in Code-Review mode.
But i see that its works for TypeScript, Kotlin etc.
Current example on try.gitea.io:
https://try.gitea.io/den/test/pulls/1/files
Screenshots
Gitea Version
1.19.0+dev-135-gf047ee0a4
Can you reproduce the bug on the Gitea demo site?
Yes
Operating System
Windows 10 Pro
Browser Version
Chrome 107
The text was updated successfully, but these errors were encountered: