mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix copy/paste of empty lines (#19798)
* Fix copy/paste of empty newlines again Fixes: https://github.com/go-gitea/gitea/issues/19331 Regressed by: https://github.com/go-gitea/gitea/pull/18270 Needed to do another newline addition to the Chroma output HTML to get copy/paste work again. The previous replacement conditions are probably obsolete, but as I'm not 100% sure, I opted to keep them. Specifically, the Chroma HTML change mentioned in https://github.com/go-gitea/gitea/pull/18270#issuecomment-1013350246 broke our previous newline replacement for such empty lines. Also included are a few changes to make the test more pleasant to work with. * run go mod tidy * add util.Dedent * copy in the code Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		@@ -203,6 +203,8 @@ func File(numLines int, fileName, language string, code []byte) []string {
 | 
			
		||||
			content = "\n"
 | 
			
		||||
		} else if content == `</span><span class="w">` {
 | 
			
		||||
			content += "\n</span>"
 | 
			
		||||
		} else if content == `</span></span><span class="line"><span class="cl">` {
 | 
			
		||||
			content += "\n"
 | 
			
		||||
		}
 | 
			
		||||
		content = strings.TrimSuffix(content, `<span class="w">`)
 | 
			
		||||
		content = strings.TrimPrefix(content, `</span>`)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user