summaryrefslogtreecommitdiffstats
path: root/tpl/tplimpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-30 20:42:46 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-31 09:05:54 +0200
commit6f7bf3f2d7eda178d0dba4a6bf3dfa50229df7ae (patch)
tree781580c54bed6942f1844def43750b027d8bbc76 /tpl/tplimpl
parent9e904d756be02ca30e4cd9abb1eae8ba01f9c8af (diff)
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
Diffstat (limited to 'tpl/tplimpl')
-rw-r--r--tpl/tplimpl/embedded/templates/shortcodes/highlight.html2
-rw-r--r--tpl/tplimpl/template_ast_transformers.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/tpl/tplimpl/embedded/templates/shortcodes/highlight.html b/tpl/tplimpl/embedded/templates/shortcodes/highlight.html
index b063f92ad..54e92bb09 100644
--- a/tpl/tplimpl/embedded/templates/shortcodes/highlight.html
+++ b/tpl/tplimpl/embedded/templates/shortcodes/highlight.html
@@ -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 }} \ No newline at end of file
+{{ if len .Params | eq 2 }}{{ highlight (trim .InnerDeindent "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .InnerDeindent "\n\r") (.Get 0) "" }}{{ end }} \ No newline at end of file
diff --git a/tpl/tplimpl/template_ast_transformers.go b/tpl/tplimpl/template_ast_transformers.go
index dee1fd6c2..bc02d93ac 100644
--- a/tpl/tplimpl/template_ast_transformers.go
+++ b/tpl/tplimpl/template_ast_transformers.go
@@ -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
}