Commit Graph

7 Commits (9db221780f28e161c02c4106f63d0b6f185933d4)

Author SHA1 Message Date
silverwind ae3dde1c87
Rework file highlight rendering and fix yaml copy-paste ()
* Rework file highlight rendering and fix yaml copy-paste

* use Split+Trim to replace tag parser

* remove unnecessary bytes.Count

* remove newLineInHTML = "
"

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
silverwind 527e5bd1b2
Fix copy/paste of empty lines ()
* 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>
Jelle Hulter bbd30787d3
Updated Chroma to v0.10.0 ()
zeripath 3c4724d70e
Add .gitattribute assisted language detection to blame, diff and render ()
Use check attribute code to check the assigned language of a file and send that in to
chroma as a hint for the language of the file.

Signed-off-by: Andrew Thornton <art27@cantab.net>
wxiaoguang 750a8465f5
A better go code formatter, and now `make fmt` can run in Windows ()
* go build / format tools
* re-format imports
zeripath f31e7a67cf
Just use a slice when rendering file ()
Highlight currently uses a map which is memory inefficient. Switch to use a slice instead.

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath 23a87a003e
Ensure empty lines are copiable and final new line too ()
* Ensure empty lines are copiable and final new line too

When files are highlighted the newline character needs to be added in a whitespace
compliant mode. Also ensure the final empty newline is rendered.

Fix 

* Add test and ensure spans closed

Signed-off-by: Andrew Thornton <art27@cantab.net>