3 prev='' next='' idoff=0
7 # busybox does not ship base64, only uuencode. Other platforms might need base64 instead
8 if which uuencode >/dev/null; then
10 | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
11 elif which busybox >/dev/null; then
12 busybox uuencode -m - <"$1" \
13 | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
16 | sed ':X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
20 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
24 tag="${tag}${line%%>*}"
26 if [ "$line" = "${line%%>*}" ]; then
27 # $line did not contain ">" and thus was added to $tag entirely
28 if ! read -r line; then
35 # $line is shortened by segment added to $tag
40 ### Image embedding for Inline styles
41 while expr "$tag" : '.*<[^>]*style="[^"]*url("\?[^)]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"\?)'; do
44 file="${tag#${pre}url(}" file="${file%)$post}"
45 file="${file#\"}" file="${file%\"}"
46 echo Inlining Background Image "$file" >&2
47 if [ -r "$file" ]; then
48 tag="${pre}url('data:image/${file##*.};base64,$(_base64 "$file")')${post}"
52 ### Image embedding for Image tags
53 while expr "$tag" : '.*<img [^>]*src="[^"]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"'; do
54 pre="${tag%%src=\"*\"*}"
55 post="${tag#*src=\"*\"}"
56 file="${tag#${pre}src=\"}" file="${file%\"$post}"
57 echo Inlining Image "$file" >&2
58 if [ -r "$file" ]; then
59 tag="${pre}src=\"data:image/${file##*.};base64,$(_base64 "${file}")\"${post}"
65 *\<head\>*|\*\<head\ *\>) # Inline styles into head
66 printf '%s<meta name="viewport" content="width=device-width">
67 <meta charset="UTF-8">
68 <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
69 cat "${0%/*}/clickslide.css"
70 printf '\n--></style>%s' "${tag#*<head*>}"
71 tag='' depth=$((depth + 1))
73 *\<slide\ *id=\"?*\"*\>*) # Count slide id, insert "next" button
75 next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
76 next="autoslide${idoff}"
77 idoff="$((idoff + 1))"
78 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
79 "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
80 tag='' depth=$((depth + 1))
82 *\<slide\ *\>*|*\<slide\>*)
84 next="autoslide${idoff}"
85 idoff="$((idoff + 1))"
86 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
87 "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
88 tag='' depth=$((depth + 1))
90 *\</slide\>*) # Insert "previous" button
91 printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
92 "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
93 tag='' depth=$((depth - 1))
95 *\<body*\>*) # Insert toplevel link
96 printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
97 tag='' depth=$((depth + 1))
99 *\</body*\>*) # Insert total slide count
100 printf '<span class="count">%i</span>%s' "$idoff" "$tag"
101 tag='' depth=$((depth - 1))
103 *\<*class=\"uncover\"*\>*) # Insert checkboxes in "uncover" lists
104 #printf '%s<li></li>' "$tag"
106 tag='' depth=$((depth + 1))
111 tag='' depth=$((depth - 1))
112 [ $depth -lt $ucdepth ] && ucdepth=-1
115 if [ $ucdepth = $depth ]; then
116 printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
120 [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))