9 cachedir
="${XDG_CACHE_HOME:-$HOME/.cache}/llpp"
10 test -d "$cachedir" || die
"cache directory '$cachedir' does not exist"
16 command -v "$1" >/dev
/null
2>&1
21 eval "$1() { die \"$2 is needed for \$type conversion\"; }"
26 <pre style="font-size: ${1}pt;">
28 Lorem ipsum dolor sit amet, consectetur...datat non proident, sunt in
29 culpa qui officia deserunt mollit anim id est laborum.
30 Posting Soccer Goals On Vine Is Illegal, Say England's Premier League
31 abcdefghizklmnopqrstwxyz
32 ABCDEFGHIZKLMNOPQRSTWXYZ
33 абвгдеёжзийклмнопрстуфхцчшщэюя
34 АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЭЮЯ
39 S in S9 59 S9 is like 5
40 3ЗЭэзээз3ЗqgO0o ijklI1| bgqpykvwlliliiijil1
44 curly vs plain braces {} () {}
49 Before [Bef ore, Be for e]
57 mkfifo [mk f i fo, mk f i fo]
64 # https://github.com/react-boilerplate/react-boilerplate/issues/1340
65 test -d "$cachedir/fonts" || mkdir
"$cachedir/fonts"
66 cat >"$cachedir/fonts/text.html" <<EOF
67 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
68 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
71 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
72 <style type="text/css">
86 for size
in 6 8 10 12 4 2; do
87 text
$size >>"$cachedir/fonts/text.html"
89 cat >>"$cachedir/fonts/text.html" <<EOF
95 trap 'test -n "$casp" && rm -f "$casp"' 0
97 while getopts c
:m
:t
:f opt
; do
102 c
) css
="-s $OPTARG";;
103 ?
) die
"usage: $0 [-c css] [-m mime/type] [-t filter] [-f] [path|url]";;
106 shift $
(($OPTIND - 1))
107 test -z "$1" && die
"usage $0: path"
110 if ${force-test ! -e "$1"} && expr >/dev
/null
"$1" : "\(ftp\|https\?\)://"; then
111 if executable_p wget
; then
115 elif executable_p curl
; then
120 die
"no program to fetch remote urls found"
123 md5of
="$cachedir/$(basename "$1")"
124 dl
"$1" "$md5of" ||
test -e "$md5of"
132 ft
=$
(file -L --mime-type -b "$1") || die
"$ft"
136 application
/x-gzip | application
/x-compress
) dc=zcat
;;
137 application
/x-xz
) dc=xzcat
;;
138 application
/x-bzip2
) dc=bzcat
;;
139 *) unset dc || true
;;
142 filt
='"${dc-cat}" "$1" |'
144 if test -z "$type"; then
145 test -z "$mime" && mime
=$
(file -L --mime-type -bz "$1" || die
"$mime")
147 application
/postscript
) type=ps
;;
148 application
/pdf
) type=pdf
;;
149 image
/vnd.djvu
) type=djvu
;;
150 text
/html
) type=html
;;
151 text
/plain
) type=text
;;
152 application
/msword
) type=word
;;
153 application
/vnd.openxmlformats-officedocument.
* \
154 | application
/vnd.ms-powerpoint \
155 | application
/vnd.ms-excel \
156 | application
/vnd.oasis.opendocument.
*) type=uno
;;
157 image
/svg
+xml
) type=svg
;;
158 image
/png | image
/jpeg
) test -n "$dc" && type="image" ||
type="image2";;
159 image
/*) type=image
;;
160 application
/x-dvi
) type=dvi
;;
161 application
/x-font-ttf \
162 | application
/vnd.ms-opentype \
163 | application
/font-sfnt
) type=font
;;
164 *) die
"unhandled file type: '$mime'";;
170 ps
) conv
='ps2pdf - "$casp"';;
171 image2|pdf
) test -z "$dc" && exec llpp
"$@" || conv
='cat >"$casp"';;
173 missing texi2html
"texi2html(http://www.nongnu.org/texi2html/)"
174 missing prince
"PrinceXML(http://www.princexml.com/)"
175 conv
='texi2html - -o - | prince $css - -o "$casp"'
178 missing ddjvu
"ddjvu(http://djvu.sourceforge.net/doc/man/ddjvu.html)"
179 conv
='ddjvu -format=pdf - "$casp"'
182 missing prince
"PrinceXML(http://www.princexml.com/)"
183 conv
='prince $css - -o "$casp"'
186 missing pandoc
"pandoc(http://pandoc.org)"
188 conv
='pandoc -r html - -w epub -o "$casp"'
191 if executable_p unoconv
&& test -z "$dc"; then
193 conv
='unoconv -o "$casp" "$1"'
195 missing antiword
"antiword or unoconv"
196 conv
='antiword -m 8859-1.txt -a a4 - >"$casp"'
200 test -n "$dc" && die
"cannot convert compressed '$mime'"
202 missing unoconv
"unoconv(http://dag.wiee.rs/home-made/unoconv/)"
203 conv
='unoconv -o "$casp" "$1"'
206 if executable_p inkscape
&& test -z "$dc"; then
208 conv
='inkscape -z -A "$casp" "$1"'
210 missing rsvg-convert
"rsvg-convert"
211 conv
='rsvg-convert -f pdf -o "$casp"'
216 exec llpp
"$cachedir/fonts/text.html"
219 missing convert
"convert(http://www.imagemagick.org/script/convert.php)"
220 conv
='convert - pdf:"$casp"'
223 test -n "$dc" && die
"cannot convert compressed '$mime'"
225 missing dvipdf
"dvipdf(http://ghostscript.com/)"
226 conv
='dvipdf "$1" "$casp"'
229 missing pandoc
"pandoc(http://pandoc.org/)"
230 conv
='pandoc -t epub - -o "$casp"'
233 *) die
"unhandled filter type: '$type'";;
236 hash=$
(md5sum "$md5of") || die
"$hash"
237 casp
=$cachedir/${hash%% *}$caspsuf
239 { test -n "$force" ||
test ! -e "$casp"; } && eval "$filt" "$conv"
242 exec llpp
-origin $origin "$@" "$casp"