From 7e073f968190d7505e6feb2c025357a562430527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 22 Jun 2023 17:34:04 +0200 Subject: [PATCH] highlight: handle string options in funnel file #169 as it may happen to be called with string options in case of documented `partial (compat)` mode --- layouts/partials/shortcodes/highlight.html | 11 +++++++++-- layouts/shortcodes/highlight.html | 11 ++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/layouts/partials/shortcodes/highlight.html b/layouts/partials/shortcodes/highlight.html index 72f159b0cb..9ba5f9a403 100644 --- a/layouts/partials/shortcodes/highlight.html +++ b/layouts/partials/shortcodes/highlight.html @@ -12,7 +12,14 @@ {{- else if eq $k "content" }} {{- $content = trim $v "\n\r" }} {{- else if eq $k "options" }} - {{- $options = $v }} + {{- if eq (printf "%T" $v) "string" }} + {{- range (split $v ",") }} + {{- $pair := split . "=" }} + {{- $options = $options | merge (dict (index $pair 0) (index $pair 1)) }} + {{- end }} + {{- else }} + {{- $options = $v }} + {{- end }} {{- else if eq $k "type" }} {{- $type = $v }} {{- else if eq $k "wrap" }} @@ -27,7 +34,7 @@ {{- if eq $k "wrap" }} {{- $otherAttributes = (dict $k $v) | merge $otherAttributes }} {{- else }} - {{- $otherOptions = $otherOptions | merge (dict $k $v) }} + {{- $otherOptions = (dict $k $v) | merge $otherOptions }} {{- end }} {{- end }} {{- $options = $otherOptions }} diff --git a/layouts/shortcodes/highlight.html b/layouts/shortcodes/highlight.html index 63773e5e42..2b10b91214 100644 --- a/layouts/shortcodes/highlight.html +++ b/layouts/shortcodes/highlight.html @@ -9,27 +9,20 @@ {{- end }} {{- $attributes := dict }} {{- $options := dict }} -{{- $stringOptions := "" }} -{{- $otherOptions := dict }} {{- $type := "" }} {{- range $k, $v := .Params }} {{- if eq $k 0 }} {{- $type = $v }} {{- else if eq $k 1 }} - {{- $stringOptions = trim $v "\n\r\t " }} + {{- $options = $v }} {{- else if eq $k "type" }} {{- $type = $v }} {{- else if eq $k "wrap" }} {{- $attributes = $attributes | merge (dict $k $v) }} {{- else }} - {{- $otherOptions = $otherOptions | merge (dict $k $v) }} + {{- $options = $options | merge (dict $k $v) }} {{- end }} {{- end }} -{{- range (split $stringOptions ",") }} - {{- $pair := split . "=" }} - {{- $options = $options | merge (dict (index $pair 0) (index $pair 1)) }} -{{- end }} -{{- $options = $options | merge $otherOptions }} {{- partial "shortcodes/highlight.html" (dict "context" .Page "attributes" $attributes