Skip to content
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

Highlighted diff emitting extraneous newlines #12172

Closed
silverwind opened this issue Jul 7, 2020 · 1 comment · Fixed by #12180
Closed

Highlighted diff emitting extraneous newlines #12172

silverwind opened this issue Jul 7, 2020 · 1 comment · Fixed by #12180
Labels
Milestone

Comments

@silverwind
Copy link
Member

silverwind commented Jul 7, 2020

Example: https://try.gitea.io/silverwind/updates/commit/03967f99a6cbb87c7ea7385d264ed42539b0162f

#12047 seems to cause text in diffs to sometimes split up a single line:

image

It should be

image

I think the issue is that either we or chroma are emitting newlines where there shouldn't be ones. Here's the raw HTML of line 2 line with three newlines present on a single actual line:

<span class="mono wrap">	npx ver 
<span class="added-code"><span class="err">-</span><span class="err">C</span> 
</span><span class="err">p</span><span class="err">a</span><span class="err">t</span><span class="err">c</span><span class="err">h</span>
</span>

cc: @mrsdizzie

mrsdizzie added a commit to mrsdizzie/gitea that referenced this issue Jul 7, 2020
Somewhere when tokenizing a newline gets added to code formatted by chroma. This breaks the case of 'added-code' inside of an 'added-line' in a diff. Just remove any newline when processing chunks of code since we don't need it.

Fixes go-gitea#12172
@mrsdizzie
Copy link
Member

Hmm weird it does seem to be happening somewhere in Chroma in the tokenizing stage. Put up a PR to just remove the added newline

@lafriks lafriks added this to the 1.13.0 milestone Jul 7, 2020
lafriks pushed a commit that referenced this issue Jul 7, 2020
* Remove newline when highlighting random chunks of code

Somewhere when tokenizing a newline gets added to code formatted by chroma. This breaks the case of 'added-code' inside of an 'added-line' in a diff. Just remove any newline when processing chunks of code since we don't need it.

Fixes #12172

* don't process empty lines

* This is the proper way to fix this by telling chroma not to add the newline in the first place
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
* Remove newline when highlighting random chunks of code

Somewhere when tokenizing a newline gets added to code formatted by chroma. This breaks the case of 'added-code' inside of an 'added-line' in a diff. Just remove any newline when processing chunks of code since we don't need it.

Fixes go-gitea#12172

* don't process empty lines

* This is the proper way to fix this by telling chroma not to add the newline in the first place
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants