{{- /* Inserts a text block into the HTML. See https://preliminary.istio.io/about/contribute/creating-and-editing-pages/#embedding-preformatted-blocks for details */ -}} {{- $downloadas := "" -}} {{- if .Get 2 -}} {{- $downloadas = .Get 2 -}} {{- end -}} {{- $expand_links := "true" -}} {{- if .Get 3 -}} {{- $expand_links = .Get 3 -}} {{- end -}} {{- $syntax := "" -}} {{- $text := "" -}} {{- $output := "" -}} {{- if .Get 0 -}} {{- $text = partial "strip_indent.html" (dict "content" .Inner "pos" .Page.Position) -}} {{- $syntax = .Get 0 -}} {{- $output = .Get 1 -}} {{- else -}} {{- errorf "Text block does not specify a syntax (%s)" .Position -}} {{- $syntax = "plain" -}} {{- end -}} {{- if (hasPrefix $text " ") -}} {{- errorf "Text blocks need to not be indented, or indented by a multiple of 4 spaces (%s)" .Position -}} {{- end -}} {{- if eq $syntax "bash" -}} {{- if not (hasPrefix $text "$") -}} {{- errorf "Text block specifies a bash syntax, but the first line of the block does not start with $ (%s)" .Position -}} {{- else -}} {{- $syntax = "command" -}} {{- if $output -}} {{- $syntax = printf "command-output-as-%s" $output -}} {{- end -}} {{- end -}} {{- end -}} {{- $result := "" -}} {{- if $downloadas -}} {{- $result = printf "
%s
" $syntax $expand_links $downloadas (htmlEscape $text) -}}
{{- else -}}
{{- $result = printf "%s
" $syntax $expand_links (htmlEscape $text) -}}
{{- end -}}
{{- if eq $expand_links "true" -}}
{{- /* include a dummy link to the special embedded @@ references so the links are statically checked as we build the site */ -}}
{{- $branch := .Site.Data.args.source_branch_name -}}
{{- $links := findRE "@(.*?)@" $text -}}
{{- range $link := $links -}}
{{- $target := trim $link "@" -}}
{{- if gt (len $target) 0 -}}
{{- $result = printf "Zip%s" $branch $target $result -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $result | safeHTML -}}