From 4a25b6a875b2b452f58f70fa254a8dd19a5724dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 14 Feb 2025 20:32:07 +0100 Subject: [PATCH] code: set wrap-code flag in all cases #1022 - for plain html block code with

- removing if highlight code has hl_inline=true
---
 layouts/partials/shortcodes/highlight.html | 2 +-
 layouts/partials/stylesheet.html           | 8 ++++++++
 layouts/partials/version.txt               | 2 +-
 static/js/theme.js                         | 3 +++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/layouts/partials/shortcodes/highlight.html b/layouts/partials/shortcodes/highlight.html
index d929b499ce..cc6122ec21 100644
--- a/layouts/partials/shortcodes/highlight.html
+++ b/layouts/partials/shortcodes/highlight.html
@@ -85,7 +85,7 @@
 
 {{- /* enrich attributes */}}
 {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) "highlight" slice) " ")) }}
-{{- if $wrap }}
+{{- if and $wrap (not $hl_inline) }}
   {{- $attributes = merge $options (dict "class" (delimit (append (index $attributes "class" | default slice) "wrap-code" slice) " ")) }}
 {{- end }}
 
diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html
index 215531a4de..33dbfa1dc3 100644
--- a/layouts/partials/stylesheet.html
+++ b/layouts/partials/stylesheet.html
@@ -10,6 +10,13 @@
     
     
     {{- $themevariants := partialCached "_relearn/themeVariants.gotmpl" . }}
+    {{- $wrap := true }}
+    {{- if isset site.Params "highlightwrap" }}
+      {{- $wrap = site.Params.highlightWrap  }}
+    {{- end }}
+    {{- if isset .Params "highlightwrap" }}
+      {{- $wrap = .Params.highlightWrap }}
+    {{- end }}
     {{- $minify := not hugo.IsServer }}
     {{- if and (isset site.Params "minify") (ne site.Params.minify "") }}
       {{- $minify = site.Params.minify }}
@@ -25,6 +32,7 @@
       {{ printf "window.relearn.min = `%s`;" $min | safeJS }}
       window.relearn.disableAnchorCopy={{ printf "%t" (eq .Site.Params.disableAnchorCopy true) | safeJS }};
       window.relearn.disableAnchorScrolling={{ printf "%t" (eq .Site.Params.disableAnchorScrolling true) | safeJS }};
+      window.relearn.enableBlockCodeWrap={{ printf "%t" (eq $wrap true) | safeJS }};
       {{ "// variant stuff" | safeJS }}
       {{- $quotedthemevariants := slice }}
       {{- range $themevariants }}
diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt
index 8b6ffa94db..d1e36e3274 100644
--- a/layouts/partials/version.txt
+++ b/layouts/partials/version.txt
@@ -1 +1 @@
-7.3.2+542aafde241ba67ff5310c922972a6e633b49b13
\ No newline at end of file
+7.3.2+dffe6e1ed0dfd9b297cb438839bd1af816021f18
\ No newline at end of file
diff --git a/static/js/theme.js b/static/js/theme.js
index 22661749b7..78f96b3748 100644
--- a/static/js/theme.js
+++ b/static/js/theme.js
@@ -695,6 +695,9 @@ function initCodeClipboard() {
           var clone = pre.cloneNode(true);
           var div = document.createElement('div');
           div.classList.add('highlight');
+          if (window.relearn.enableBlockCodeWrap) {
+            div.classList.add('wrap-code');
+          }
           div.appendChild(clone);
           pre.parentNode.replaceChild(div, pre);
           pre = clone;