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;'
13 | sed ':X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
17 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
21 tag="${tag}${line%%>*}"
23 if [ "$line" = "${line%%>*}" ]; then
24 # $line did not contain ">" and thus was added to $tag entirely
25 if ! line="$(line)"; then
32 # $line is shortened by segment added to $tag
37 ### Image embedding for Inline styles
38 while expr "$tag" : '.*<[^>]*style="[^"]*url("\?[^)]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"\?)'; do
41 file="${tag#${pre}url(}" file="${file%)$post}"
42 file="${file#\"}" file="${file%\"}"
43 echo Inlining Background Image "$file" >&2
44 if [ -r "$file" ]; then
45 tag="${pre}url('data:image/${file##*.};base64,$(_base64 "$file")')${post}"
49 ### Image embedding for Image tags
50 while expr "$tag" : '.*<img [^>]*src="[^"]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"'; do
51 pre="${tag%%src=\"*\"*}"
52 post="${tag#*src=\"*\"}"
53 file="${tag#${pre}src=\"}" file="${file%\"$post}"
54 echo Inlining Image "$file" >&2
55 if [ -r "$file" ]; then
56 tag="${pre}src=\"data:image/${file##*.};base64,$(_base64 "${file}")\"${post}"
62 *\<head\>*|\*\<head\ *\>) # Inline styles into head
63 printf '%s<meta name="viewport" content="width=device-width">
64 <meta charset="UTF-8">
65 <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
66 cat "${0%/*}/clickslide.css"
67 printf '\n--></style>%s' "${tag#*<head*>}"
68 tag='' depth=$((depth + 1))
70 *\<slide\ *id=\"?*\"*\>*) # Count slide id, insert "next" button
72 next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
73 next="autoslide${idoff}"
74 idoff="$((idoff + 1))"
75 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
76 "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
77 tag='' depth=$((depth + 1))
79 *\<slide\ *\>*|*\<slide\>*)
81 next="autoslide${idoff}"
82 idoff="$((idoff + 1))"
83 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
84 "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
85 tag='' depth=$((depth + 1))
87 *\</slide\>*) # Insert "previous" button
88 printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
89 "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
90 tag='' depth=$((depth - 1))
92 *\<body*\>*) # Insert toplevel link
93 printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
94 tag='' depth=$((depth + 1))
96 *\</body*\>*) # Insert total slide count
97 printf '<span class="count">%i</span>%s' "$idoff" "$tag"
98 tag='' depth=$((depth - 1))
100 *\<*class=\"uncover\"*\>*) # Insert checkboxes in "uncover" lists
101 #printf '%s<li></li>' "$tag"
103 tag='' depth=$((depth + 1))
108 tag='' depth=$((depth - 1))
109 [ $depth -lt $ucdepth ] && ucdepth=-1
112 if [ $ucdepth = $depth ]; then
113 printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
117 [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))