mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
@@ -21,7 +21,13 @@ type Tmpl struct {
|
||||
func (t *GoHTMLTemplate) EmbedShortcodes() {
|
||||
t.AddInternalShortcode("ref.html", `{{ .Get 0 | ref .Page }}`)
|
||||
t.AddInternalShortcode("relref.html", `{{ .Get 0 | relref .Page }}`)
|
||||
t.AddInternalShortcode("highlight.html", `{{ .Get 0 | highlight .Inner }}`)
|
||||
t.AddInternalShortcode("highlight.html", `
|
||||
{{ if len .Params | eq 2 }}
|
||||
{{ highlight .Inner (.Get 0) (.Get 1) }}
|
||||
{{ else }}
|
||||
{{ highlight .Inner (.Get 0) "" }}
|
||||
{{ end }}
|
||||
`)
|
||||
t.AddInternalShortcode("test.html", `This is a simple Test`)
|
||||
t.AddInternalShortcode("figure.html", `<!-- image -->
|
||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
||||
|
@@ -875,7 +875,7 @@ func ReturnWhenSet(a, k interface{}) interface{} {
|
||||
return ""
|
||||
}
|
||||
|
||||
func Highlight(in interface{}, lang string) template.HTML {
|
||||
func Highlight(in interface{}, lang, opts string) template.HTML {
|
||||
var str string
|
||||
av := reflect.ValueOf(in)
|
||||
switch av.Kind() {
|
||||
@@ -883,7 +883,7 @@ func Highlight(in interface{}, lang string) template.HTML {
|
||||
str = av.String()
|
||||
}
|
||||
|
||||
return template.HTML(helpers.Highlight(html.UnescapeString(str), lang))
|
||||
return template.HTML(helpers.Highlight(html.UnescapeString(str), lang, opts))
|
||||
}
|
||||
|
||||
var markdownTrimPrefix = []byte("<p>")
|
||||
|
Reference in New Issue
Block a user