{{/* Inserts a text block into the HTML. See https://preliminary.istio.io/about/contribute/writing-a-new-topic/#embedding-preformatted-blocks for details NOTE: The stuff below cannot be indented. If it is, it can cause the markdown parser to insert spurious paragraphs around the PRE blocks, which turns out to be invalid HTML */}} {{ $scratch := .Scratch }} {{ if .Get 2 }} {{ $scratch.Set "downloadas" (.Get 2) }} {{ end }} {{ if .Get 0 }} {{ $lines := split (strings.TrimRight " " (trim .Inner "\n")) "\n" }} {{ $line0 := index $lines 0 }} {{ if hasPrefix $line0 " "}}{{ $scratch.Set "indent" 16 }} {{ else if hasPrefix $line0 " "}}{{ $scratch.Set "indent" 12 }} {{ else if hasPrefix $line0 " "}}{{ $scratch.Set "indent" 8 }} {{ else if hasPrefix $line0 " "}}{{ $scratch.Set "indent" 4 }} {{ else }}{{ $scratch.Set "indent" 0 }} {{ end }} {{ $scratch.Set "text" "" }} {{ range $line := $lines }} {{ if gt (len $line) ($scratch.Get "indent") }} {{ $l := substr $line ($scratch.Get "indent") }} {{ $scratch.Set "text" (printf "%s\n%s" ($scratch.Get "text") $l )}} {{ else }} {{ $scratch.Set "text" (printf "%s\n%s" ($scratch.Get "text") $line )}} {{ end }} {{ end }} {{ $scratch.Set "text" (trim ($scratch.Get "text") "\n") }} {{ $scratch.Set "syntax" (.Get 0) }} {{ $scratch.Set "output" (.Get 1) }} {{ else }} {{ $scratch.Set "syntax" "error" }} {{ $scratch.Set "text" "MARKDOWN ERROR: text block does not specify syntax" }} {{ end }} {{ if (hasPrefix ($scratch.Get "text") " ") }} {{ $scratch.Set "syntax" "error" }} {{ $scratch.Set "text" "MARKDOWN ERROR: text blocks need to not be indented, or indented by a multiple of 4 spaces" }} {{ end }} {{ if eq ($scratch.Get "syntax") "bash" }} {{ if not (hasPrefix ($scratch.Get "text") "$") }} {{ $scratch.Set "syntax" "error" }} {{ $scratch.Set "text" "MARKDOWN ERROR: text block specifies a bash syntax, but first line does not start with $" }} {{ else }} {{ if hasPrefix (trim ($scratch.Get "text") " ") "$ cat <{{ $scratch.Get "text" }} {{ else }}
{{ $scratch.Get "text" }}
{{ end }} {{/* include a link to the special embedded @@ references so the links are statically checked as we build the site */}} {{ $branch := .Site.Data.args.branch_name }} {{ $links := findRE "@(.*?)@" ($scratch.Get "text") }} {{ range $link := $links }} {{ $target := trim $link "@" }} {{ if gt (len $target) 0 }} {{ $href := printf "https://raw.githubusercontent.com/istio/istio/%s/%s" $branch $target }} {{ end }} {{ end }}