From a0aeeb7cfdef73bbf04b28a90d244fab533d5e3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 28 Feb 2019 17:58:58 +0100 Subject: [PATCH] Inlining images --- clickslide.css | 2 +- clickslide.sh | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/clickslide.css b/clickslide.css index 174384b..3410470 100644 --- a/clickslide.css +++ b/clickslide.css @@ -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, diff --git a/clickslide.sh b/clickslide.sh index dcb01db..5c9d155 100755 --- a/clickslide.sh +++ b/clickslide.sh @@ -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" : '.*]*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 -- 2.39.2