]> git.plutz.net Git - clickslide/commitdiff
Inlining images
authorPaul Hänsch <paul@plutz.net>
Thu, 28 Feb 2019 16:58:58 +0000 (17:58 +0100)
committerPaul Hänsch <paul@plutz.net>
Thu, 28 Feb 2019 16:58:58 +0000 (17:58 +0100)
clickslide.css
clickslide.sh

index 174384b54e3d653f893f2db87b2347a16e2af7e1..3410470241b016d3a91484bb0252a50f5dc4db71 100644 (file)
@@ -132,7 +132,7 @@ div.slide:after {
 div.slide > * {
   margin-top: 1em;
   max-width: 85%;
-  z-index: 1;
+  overflow: hidden;
 }
 
 div.slide > *:first-child:last-child,
index dcb01db6dc4b3264d00cfa3ee5dca6b7d2863c5c..5c9d155a57da709d6534d588f2b8c7092f9da458 100755 (executable)
@@ -3,6 +3,11 @@
 prev='' next='' idoff=0
 depth=0 ucdepth=-1
 
+base64() {
+  uuencode -m - <"$1" \
+  | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
+}
+
 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
 | {
   line="$(line)"
@@ -29,9 +34,20 @@ depth=0 ucdepth=-1
       post="${tag#*url(*)}"
       file="${tag#${pre}url(}" file="${file%)$post}"
       file="${file#"}" file="${file%"}"
+      echo Inlining Background Image "$file" >&2
+      if [ -r "$file" ]; then
+        tag="${pre}url('data:image/${file##*.};base64,$(base64 "$file")')${post}"
+      fi
+    done >/dev/null
+
+    ### Image embedding for Image tags
+    while expr "$tag" : '.*<img [^>]*src="[^"]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"'; do
+      pre="${tag%%src=\"*\"*}"
+      post="${tag#*src=\"*\"}"
+      file="${tag#${pre}src=\"}" file="${file%\"$post}"
       echo Inlining Image "$file" >&2
       if [ -r "$file" ]; then
-        tag="${pre}url('data:image/${file##*.};base64,$(base64 <"${file}" |tr -d \\n)')${post}"
+        tag="${pre}src=\"data:image/${file##*.};base64,$(base64 "${file}")\"${post}"
       fi
     done >/dev/null