3 prev='' next='' idoff=0
8 | sed '1d; :X;$!{N;bX;}; s;\n;;g; s;=\+;;g;'
11 { "${0%/*}"/cgilite/html-sh.sed || cat; } \
15 tag="${tag}${line%%>*}"
17 if [ "$line" = "${line%%>*}" ]; then
18 # $line did not contain ">" and thus was added to $tag entirely
19 if ! line="$(line)"; then
26 # $line is shortened by segment added to $tag
31 ### Image embedding for Inline styles
32 while expr "$tag" : '.*<[^>]*style="[^"]*url("\?[^)]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"\?)'; do
35 file="${tag#${pre}url(}" file="${file%)$post}"
36 file="${file#"}" file="${file%"}"
37 echo Inlining Background Image "$file" >&2
38 if [ -r "$file" ]; then
39 tag="${pre}url('data:image/${file##*.};base64,$(base64 "$file")')${post}"
43 ### Image embedding for Image tags
44 while expr "$tag" : '.*<img [^>]*src="[^"]\+\.\(png\|jpg\|jpeg\|gif\|svg\)"'; do
45 pre="${tag%%src=\"*\"*}"
46 post="${tag#*src=\"*\"}"
47 file="${tag#${pre}src=\"}" file="${file%\"$post}"
48 echo Inlining Image "$file" >&2
49 if [ -r "$file" ]; then
50 tag="${pre}src=\"data:image/${file##*.};base64,$(base64 "${file}")\"${post}"
56 *\<head\>*|\*\<head\ *\>) # Inline styles into head
57 printf '%s<meta name="viewport" content="width=device-width">
58 <meta charset="UTF-8">
59 <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
60 cat "${0%/*}/clickslide.css"
61 printf '\n--></style>%s' "${tag#*<head*>}"
62 tag='' depth=$((depth + 1))
64 *\<slide\ *id=\"?*\"*\>*) # Count slide id, insert "next" button
66 next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
67 next="autoslide${idoff}"
68 idoff="$((idoff + 1))"
69 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
70 "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
71 tag='' depth=$((depth + 1))
73 *\<slide\ *\>*|*\<slide\>*)
75 next="autoslide${idoff}"
76 idoff="$((idoff + 1))"
77 printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
78 "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
79 tag='' depth=$((depth + 1))
81 *\</slide\>*) # Insert "previous" button
82 printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
83 "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
84 tag='' depth=$((depth - 1))
86 *\<body*\>*) # Insert toplevel link
87 printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
88 tag='' depth=$((depth + 1))
90 *\</body*\>*) # Insert total slide count
91 printf '<span class="count">%i</span>%s' "$idoff" "$tag"
92 tag='' depth=$((depth - 1))
94 *\<*class=\"uncover\"*\>*) # Insert checkboxes in "uncover" lists
95 #printf '%s<li></li>' "$tag"
97 tag='' depth=$((depth + 1))
102 tag='' depth=$((depth - 1))
103 [ $depth -lt $ucdepth ] && ucdepth=-1
106 if [ $ucdepth = $depth ]; then
107 printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
111 [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))