-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathman2html
executable file
·88 lines (88 loc) · 1.65 KB
/
man2html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
# man2html: convert a man page to a pdf file
# syntax: man2html <manpage-name>
# [<directory>] (default: /Users/user/Desktop)
# o (open the document after creation)
#
#!/bin/bash
if [ -z "$1" ] ;
then
echo
echo 'You must specify a man page name ...'
echo
echo syntax: 'man2html <manpage-name> [<directory>] (default:' $HOME'/Desktop)'
echo
exit 1
else
manpage=$1
fi
if [ -z "$2" ] ;
then
dirout=.
openhtml=1
else
dirout=$2
fi
if [ -n "$3" ] ;
then
openhtml=1
fi
if [ ! -d "$dirout" ]
then
echo
echo "Volume or direcotry" \'$dirout\' does not exist...
echo
exit 1
fi
rm -f $dirout/$manpage.ps $dirout/$manpage.pdf $dirout/$manpage.html
man -t $manpage > $dirout/$manpage.ps 2> /dev/null
ret=$?
if [ $ret -gt 0 ] ;
then
echo
echo The \'$manpage\' man page not found: error $ret encountered ...
echo
exit 1
fi
ps2pdf $dirout/$manpage.ps $dirout/$manpage.pdf 2> /dev/null
if [ $? -gt 0 ] ;
then
echo 'ps2pdf' failed error $? ...
exit 1
else
rm -f $dirout/$manpage.ps
fi
#
# BUG: The "output" parameter causes an error if specified, so we default
#
pdf2htmlex $dirout/$manpage.pdf 2> /dev/null
ret=$?
if [ $ret -gt 1 ] ;
then
echo
echo 'pdf2htmlex' failed error $ret ...
echo
rm -f $dirout/$manpage.pdf
exit 1
fi
echo
echo $dirout/$manpage.html created ...
echo
rm -f $dirout/$manpage.pdf
#
# BUG: Because of the pdf2htmlex output file bug, we need to copy this if not "./"
#
if [ "$dirout" != "." ] ;
then
cp ./$manpage.html $dirout/.
rm -f ./$manpage.html
fi
if [ $openhtml ] ;
then
if [ $dirout == "." ] ;
then
open ./$manpage.html
else
open $dirout/$manpage.html
fi
fi