blob: 5348024d7970f92fd15e1fc34bd01073e268ba38 (
plain) (
blame)
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
|
#!/bin/sh
#
# Copyright (c) 2011 Alexandre Rostovtsev <tetromino@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
###
#
# Process the requested compressed source nroff file and output groff
# intermediate format.
#
filename=$1
if [ -z ${filename} ] ; then
echo "Usage: yelp-groff [FILE]" >&2
echo "Process a man FILE and output groff intermediate format."
exit 1
fi
# If "man -Z -Tutf8 -EUTF-8" works (i.e. if man is man-db), use that.
man -Z -Tutf8 -EUTF-8 ${filename} 2>/dev/null && exit 0
# Otherwise, manually uncompress the file ...
cat="cat"
case ${filename} in
*.bz2) cat="bzip2 -c -d" ;;
*.gz) cat="gunzip -c" ;;
*.lzma) cat="unlzma -c -d" ;;
*.xz) cat="unxz -c" ;;
*.Z) cat="zcat" ;;
esac
# ... and run groff to get the intermediate format; preprocess with tbl
# unless MANROFFSEQ is defined.
${cat} ${filename} | groff -${MANROFFSEQ:-t} -man -Z -Tutf8
|