-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Diff syntax highlighting should not be line-by-line #33358
Comments
Is it possible to highlight a specific part of a file if we know the file type? Since markdown allows highlighting within embedded code sections, this could be an effective way to focus on relevant content. Instead of rendering the entire file, we could adopt a similar approach to diff views, where only a portion of the file is displayed by default. |
No, chroma assumes it is being passed a full file (basically all syntax highlighters work that way). Any random section of a file is not guaranteed to highlight correctly, only the whole file content is. |
So do you mean all code sections embedded in the issue markdown are not guaranteed to highlight correctly? |
You mean those inline code blocks that render when linking to code in discussions? They are also affected. They need to pass the whole content for highlighting purpose and then only render a subsection of the highlighted HTML. This kind of rendering is best-effort thought because if the snippet is incomplete code, there will be highlighting bugs. Basically our interface with chroma should be to only ever pass full files to it, and then reduce the returned highlighted lines to what we need to display. |
A related PR but stale: fix highlight problem of git diff #24336 |
Description
Diff lines are passed individually line-by-line to chroma, which its a massive source of highlighting bugs because the highlighter needs to see the whole file to highlight correctly. We should instead:
This assumes chroma does not output HTML tags that span multiple lines, but I think this may already be the case.
The text was updated successfully, but these errors were encountered: