Trim newlines in the hightlight shortcode
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 23 Sep 2017 16:14:07 +0000 (18:14 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 23 Sep 2017 16:14:07 +0000 (18:14 +0200)
Fixes #3898

tpl/tplimpl/template_embedded.go

index 2eb9b22830815648c21c8546b3a497dca3c5b4df..dd3254560462f4e66c4cb377a111284b11ef88a8 100644 (file)
@@ -16,7 +16,7 @@ package tplimpl
 func (t *templateHandler) embedShortcodes() {
        t.addInternalShortcode("ref.html", `{{ if len .Params | eq 2 }}{{ ref .Page (.Get 0) (.Get 1) }}{{ else }}{{ ref .Page (.Get 0) }}{{ end }}`)
        t.addInternalShortcode("relref.html", `{{ if len .Params | eq 2 }}{{ relref .Page (.Get 0) (.Get 1) }}{{ else }}{{ relref .Page (.Get 0) }}{{ end }}`)
-       t.addInternalShortcode("highlight.html", `{{ if len .Params | eq 2 }}{{ highlight .Inner (.Get 0) (.Get 1) }}{{ else }}{{ highlight .Inner (.Get 0) "" }}{{ end }}`)
+       t.addInternalShortcode("highlight.html", `{{ if len .Params | eq 2 }}{{ highlight (trim .Inner "\n\r") (.Get 0) (.Get 1) }}{{ else }}{{ highlight (trim .Inner "\n\r") (.Get 0) "" }}{{ end }}`)
        t.addInternalShortcode("test.html", `This is a simple Test`)
        t.addInternalShortcode("figure.html", `<!-- image -->
 <figure {{ with .Get "class" }}class="{{.}}"{{ end }}>