mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Fix indentation in highlight shortcode
This commit adds a new `.InnerDeindent` method to the shortcode context, which is `.Inner` with any indendation removed. This is then used in the built-in `highlight` shortcode to prevent the extra whitespace getting hightlighted. Fixes #4717
This commit is contained in:
@@ -1 +1 @@
|
||||
{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}
|
||||
{{ if len .Params | eq 2 }}{{ highlight (trim .InnerDeindent "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .InnerDeindent "\n\r") (.Get 0) "" }}{{ end }}
|
@@ -272,7 +272,7 @@ func (c *templateContext) collectInner(n *parse.CommandNode) {
|
||||
idents = nt.Ident
|
||||
}
|
||||
|
||||
if c.hasIdent(idents, "Inner") {
|
||||
if c.hasIdent(idents, "Inner") || c.hasIdent(idents, "InnerDeindent") {
|
||||
c.t.parseInfo.IsInner = true
|
||||
break
|
||||
}
|
||||
|
Reference in New Issue
Block a user