TIVI-153: add as dependency for iputils
[profile/ivi/docbook-utils.git] / backends / txt
1 # Backend to convert something into ASCII text
2 # Send any comments to Eric Bischoff <eric@caldera.de>
3 # This program is under GPL license. See LICENSE file for details.
4
5 if [ -x /usr/bin/lynx ]
6 then
7   CONVERT=/usr/bin/lynx
8   ARGS="-force_html -dump -nolist -width=72"
9 elif [ -x /usr/bin/links ]
10 then
11   CONVERT=/usr/bin/links
12   ARGS="-dump"
13 elif [ -x /usr/bin/w3m ]
14 then
15   CONVERT=/usr/bin/w3m
16   ARGS="-dump"
17 else
18   echo >&2 "No way to convert HTML to text found."
19   exit 1
20 fi
21
22 HTML=$(mktemp /tmp/html-XXXXXX) || exit 1
23 trap 'rm -f "$HTML"; exit' 0 1 2 3 7 13 15
24
25 # Convert to HTML
26 $SGML_JADE -V nochunks -t sgml ${SGML_ARGUMENTS} >${HTML}
27 if [ $? -ne 0 ]
28 then exit 1
29 fi
30
31 # Convert from HTML to ASCII
32 ${CONVERT} ${ARGS} ${HTML} > "${SGML_FILE_NAME}.txt"
33 if [ $? -ne 0 ]
34 then
35   exit 2
36 fi
37
38 exit 0