#! /bin/sh
# rcshow - show a recipe
#
# This shell script extracts a recipe from an alt.gourmand netnews article and 
# nroffs it for display on the screen. This differs slightly from "rcnroff"
# in that it is not page-oriented. Actually, this program is almost too slow
# to use, because it has to run nroff every time.
#
# Brian Reid, November 1985
# Copyright (C) 1986, USENET Community Trust
#
# If you don't have "less", you will want to 
# add "ul" to the pipeline to get the underlines right.

TROFF="nroff -man"
PAGER="less"

PATH=:$HOME:.:/usr/users/kiravuo/bin:/usr/hut/bin:/usr/ucb:/bin:/usr/bin:/usr/local/bin:/usr/games:/oppilaat/bin:/etc
export PATH
TMPFILE=/tmp/xart.$$
TMAC=/tmp/tmac.$$
trap "rm -f $TMPFILE $TMAC; exit" 0 1 2 3 15
METFLAG="-rM1"

cat > $TMPFILE << 'extractor.awk'
BEGIN {Seen = 0}
/^\.RH MOD\.RECIPES/ {Seen = 1}
/^-- *$/ {Seen = 0}
Seen == 1 {print $0}
extractor.awk
cat > $TMAC << 'tmac.recip'
.de RH
.ie '\\$5'' .ds YR 1985
.el .ds YR \\$5
.ie n .ds YC Copyright \\*(YR USENET
.el .ds YC Copyright \(co \\*(YR USENET Community Trust
.ie n .TH \\$2 "\\$3" "\\$4" " " "USENET Cookbook"
.el .TH \\$2 "\\$3" "alt.gourmand \\$4" " " "USENET Cookbook"
.ds ]H \\$2
..
.de RZ
.SH \\s14\\$1
.rs
.ie n .sp 1
.el   .sp 6p
\\*(]H \- \\$2
.fi
.PP
..
.de IG
.ds =1 \\$1
.ds =2 \\$2
.if \\n(.$>2 .if  \\nM .ds =1 \\$3
.TP 10
\&\\*(=1
.I \\*(=2
..
.de SK
.IP "(\\$1)" 5n
..
.de IH
.ds =1 \\$1
.if \\n(.$>1 .if \\nM .ds =1 \\$2
.SH INGREDIENTS (\\*(=1)
.fi
.PD 0
..
.de PH
.PD
.ie '\\$1'' .SH PROCEDURE
.el .SH PROCEDURE \\$1
.RS 5
..
.de TE
.ds =2
.if \\n($>2 .ds =2 \\$3
.ie n .ds =1 \\$1 deg. F
.el .ds =1 \\$1\(deF
.ie n .if \\n(.$>1 .if \\nM .ds =1 \\$2 deg. C
.el .if \\n(.$>1 .if \\nM .ds =1 \\$2\(deC
\\*(=1\\*(=2
..
.de AB
.ds =1 \\$1
.if \\nM .ds =1 \\$2
.ds =2
.if \\n($>2 .ds =2 \\$3
\\*(=1\\*(=2
..
.de NX
.PD
.SH NOTES
..
.de WR
.RE 5
.PD
.SH CONTRIBUTOR
.nf
..
.de CS  \" do the fancy "go into cs mode right" guy
.   ie \\n(.z .cs \\$1 \\$2 \\$3
.   el              \!.CS \\$1 \\$2 \\$3
..
.de FW \" Go into fixed-width mode: put both italic and bold fonts in it
.   CS B 21 \\(.s
.   CS I 21 \\(.s
.   ss 24
.   lg 0
..
.de Fw \" Leave fixed-width mode
.   CS B
.   CS I
.   ss 12
.   lg 1
..
tmac.recip
awk -f $TMPFILE |\
  sed -e 's/\([0-9a-zA-Z]\)\(\\([1-3]\)/\1 \2/g' \
	 -e 's|\\(12|1/2|' -e 's|\\(14|1/4|' -e 's|\\(34|3/4|' \
	 -e 's|``|"|'      -e "s|''|\"|" |\
  $TROFF $METFLAG  $TMAC - | $PAGER
# if you don't have "less", you will probably want to change the above line
# into $TROFF $TMAC - | ul | $PAGER
