Remove the trailing new line in .Code

Fixes #9572
This commit is contained in:
Bjørn Erik Pedersen
2022-02-26 10:42:21 +01:00
parent afd63bf7d5
commit 10928a4f78
7 changed files with 74 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import (
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/text"
"github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/markup/converter/hooks"
"github.com/gohugoio/hugo/markup/internal/attributes"
@@ -123,7 +124,9 @@ func (h chromaHighlighter) RenderCodeblock(w hugio.FlexiWriter, ctx hooks.Codebl
return err
}
return highlight(w, ctx.Code(), ctx.Lang(), attributes, cfg)
code := text.Puts(ctx.Code())
return highlight(w, code, ctx.Lang(), attributes, cfg)
}
var id = identity.NewPathIdentity("chroma", "highlight")