mirror of https://github.com/istio/istio.io.git
39 lines
1.5 KiB
HTML
39 lines
1.5 KiB
HTML
{{- $input := .content -}}
|
|
{{- $pos := .pos -}}
|
|
{{- $lines := split $input "\n" -}}
|
|
|
|
{{- $numLines := len $lines -}}
|
|
{{- if gt $numLines 1 -}}
|
|
|
|
{{- /* look for the first non-empty line and use its indent to determine how much indent to strip */ -}}
|
|
{{- $prefix := "" -}}
|
|
{{- $done := false -}}
|
|
{{- range $index, $line := $lines -}}
|
|
{{- if not $done -}}
|
|
{{- if gt (len $line) 0 -}}
|
|
{{- $done = true -}}
|
|
{{- if hasPrefix $line " " -}}{{- $prefix = " " -}}
|
|
{{- else if hasPrefix $line " " -}}{{- $prefix = " " -}}
|
|
{{- else if hasPrefix $line " " -}}{{- $prefix = " " -}}
|
|
{{- else if hasPrefix $line " " -}}{{- $prefix = " " -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $text := "" -}}
|
|
{{- range $index, $line := $lines -}}
|
|
{{- if eq $index 0 -}}
|
|
{{- /* skip the first line since it just contains the junk to the right of the shortcode */ -}}
|
|
{{- else if eq $index (sub $numLines 1) -}}
|
|
{{- /* skip the last line since it just contains the junk to the left of the shortcode */ -}}
|
|
{{- else -}}
|
|
{{- $text = printf "%s%s\n" $text (strings.TrimPrefix $prefix $line) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $text | safeHTML -}}
|
|
{{- else -}}
|
|
{{- errorf "Shortcode must span muliple lines (%s)" $pos -}}
|
|
{{- end -}}
|