3 prev='' next='' idoff=0
7 { uuencode -m - <"$1" \
8 | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
11 | sed ':X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
15 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
19 tag="${tag}${line%%>*}"
21 if [ "$line" = "${line%%>*}" ]; then
22 # $line did not contain ">" and thus was added to $tag entirely
23 if ! line="$(line)"; then
30 # $line is shortened by segment added to $tag
35 ### Image embedding for Inline styles
36 while expr "$tag" : '.*<[^>]*style="[^"]*url("\?[^)]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"\?)'; do
39 file="${tag#${pre}url(}" file="${file%)$post}"
40 file="${file#\"}" file="${file%\"}"
41 echo Inlining Background Image "$file" >&2
42 if [ -r "$file" ]; then
43 tag="${pre}url('data:image/${file##*.};base64,$(_base64 "$file")')${post}"
47 ### Image embedding for Image tags
48 while expr "$tag" : '.*<img [^>]*src="[^"]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"'; do
49 pre="${tag%%src=\"*\"*}"
50 post="${tag#*src=\"*\"}"
51 file="${tag#${pre}src=\"}" file="${file%\"$post}"
52 echo Inlining Image "$file" >&2
53 if [ -r "$file" ]; then
54 tag="${pre}src=\"data:image/${file##*.};base64,$(_base64 "${file}")\"${post}"
60 *\<head\>*|\*\<head\ *\>) # Inline styles into head
61 printf '%s<meta name="viewport" content="width=device-width">
62 <meta charset="UTF-8">
63 <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
64 cat "${0%/*}/clickslide.css"
65 printf '\n--></style>%s' "${tag#*<head*>}"
66 tag='' depth=$((depth + 1))
68 *\<slide\ *id=\"?*\"*\>*) # Count slide id, insert "next" button
70 next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
71 next="autoslide${idoff}"
72 idoff="$((idoff + 1))"
73 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
74 "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
75 tag='' depth=$((depth + 1))
77 *\<slide\ *\>*|*\<slide\>*)
79 next="autoslide${idoff}"
80 idoff="$((idoff + 1))"
81 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
82 "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
83 tag='' depth=$((depth + 1))
85 *\</slide\>*) # Insert "previous" button
86 printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
87 "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
88 tag='' depth=$((depth - 1))
90 *\<body*\>*) # Insert toplevel link
91 printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
92 tag='' depth=$((depth + 1))
94 *\</body*\>*) # Insert total slide count
95 printf '<span class="count">%i</span>%s' "$idoff" "$tag"
96 tag='' depth=$((depth - 1))
98 *\<*class=\"uncover\"*\>*) # Insert checkboxes in "uncover" lists
99 #printf '%s<li></li>' "$tag"
101 tag='' depth=$((depth + 1))
106 tag='' depth=$((depth - 1))
107 [ $depth -lt $ucdepth ] && ucdepth=-1
110 if [ $ucdepth = $depth ]; then
111 printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
115 [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))