From 501bd0f6bf679d1f5f5158c2789e066a2b2d240e Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Thu, 23 Mar 2023 09:34:15 +0100 Subject: [PATCH] fix --- site/layouts/shortcodes/scss-docs.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/site/layouts/shortcodes/scss-docs.html b/site/layouts/shortcodes/scss-docs.html index 2bfdf8de5ec6..d28b29c926db 100644 --- a/site/layouts/shortcodes/scss-docs.html +++ b/site/layouts/shortcodes/scss-docs.html @@ -50,6 +50,27 @@ - {{- highlight $match "scss" "" -}} + {{- $unindent := 0 -}} + {{- $found := false -}} + {{- $first_line:= index (split $match "\n") 0 -}} + {{- range $char := split $first_line "" -}} + {{- if and (eq $char " ") (not $found) -}} + {{- $unindent = add $unindent 1 -}} + {{- else -}} + {{- $found = true -}} + {{- end -}} + {{- end -}} + {{- $output := "" -}} + {{- if (gt $unindent 0) -}} + {{- $prefix := (strings.Repeat $unindent " ") -}} + {{- range $line := split $match "\n" -}} + {{- $line = strings.TrimPrefix $prefix $line -}} + {{ $output = printf "%s%s\n" $output $line }} + {{- end -}} + {{- $output = chomp $output -}} + {{- else -}} + {{- $output = $match -}} + {{- end -}} + {{- highlight $output "scss" "" -}} {{- end -}}