#! /bin/sh # rctypeset - typeset a recipe # # This shell script extracts a recipe from an alt.gourmand netnews article and # typesets it with troff. It first strips all communication headers # (such as netnews or mail or notesfile headers) from the front and back # of the recipe. # # Brian Reid, November 1985 # Copyright (C) 1986, USENET Community Trust # #test-000.ps groff man macros with att-style rctypeset/recipe file # -C==max att compat., -i==read input after command line # pipe to grops (no options) to generate ps file #test-000a.ps as test-000 but grops -pletter option #TROFF="troff -man -C -i " #test-000b.ps as test-000a but redo setup for call of TH from RH #TROFF="troff -man -C -i " TROFF="troff -b -man -C -i -rC1 -U " PATH=:../bin:$PATH export PATH TMPFILE=/tmp/xart.$$ TITLE="Test Cookbook" FRACTIONS=1 TMAC=/tmp/tmac.$$ METFLAG="-rM0" VERBATIM=0 trap "rm -f $TMPFILE $TMAC; exit" 0 1 2 3 15 while [ $# -gt 0 ]; do case $1 in -t) TFLAG="$1";; -v) VERBATIM=1;; -m) METFLAG="-rM1";; -M) METFLAG="-rM0";; -f) FRACTIONS=0;; -*) echo $0: Unknown option $1 1>&2 ; exit;; esac shift done # today's date information in flexible format # Thu Mar 27 22:56:49 PST 1986 TODAY=`date +"%d %b %Y"` #alternative # set `date` # YEAR="$6" # YR=`expr $YEAR - 2000` # TODAY="$3 $2 $YEAR" cat > $TMPFILE << 'extractor.awk' BEGIN {Seen = 0} /^\.RH MOD\.RECIPES/ {Seen = 1} /^-- *$/ {Seen = 0} /^\/\* End of text from/ {Seen = 0} Seen == 1 {print $0} extractor.awk cat << 'tmac.recip' | sed -e "s/REPLACE-TODAY/\"${TODAY}\"/" -e "s/REPLACE-TITLE/${TITLE}/" -e "/^[ ]*$/d" -e '/^\.\\"./d' -e "/^\.ig/,/^\.\./d" > $TMAC .\" read in alt.gourmand recipe macros, modified minimally .\" Macro package Copyright (C) 1986 USENET Community Trust .\" tmac.recip version 3, June 1986 .\" .\" French stuff - THIS MAY NOY BE NEEDED WITH (EXTENDED) GROFF CHARSET .\" and a proper-name o' from alt.gourmand .ds A` A\h'-.5'\v'-.2m'\(ga\v'.2m'\h'.25' .ds E' E\h'-.5'\v'-.2m'\(aa\v'.2m'\h'.25' .ds E` E\h'-.5'\v'-.2m'\(ga\v'.2m'\h'.25' .ds U^ U\h'-.55'\v'-.2m'^\v'.2m'\h'.25' .ds E^ E\h'-.45'\v'-.2m'^\v'.2m'\h'.15' .ds A^ A\h'-.55'\v'-.2m'^\v'.2m'\h'.25' .ds O^ O\h'-.55'\v'-.2m'^\v'.2m'\h'.25' .\" .ds C, \o'C\(,a' .ds C, \(,C .ds a` \o'a\(ga' .ds e' \o'e\(aa' .ds e` \o'e\(ga' .ds u^ \o'u^' .ds e^ \o'e^' .ds a^ \o'a^' .ds o^ \o'o^' .\" .ds c, \o'c\(,a' .ds c, \(,c .ds o' \o'o\(aa' .\" .\" # Recipe Heading .de RH .ie '\\$5'' .ds YR 1985 .el .ds YR \\$5 .ie n .ds YC Copyright \\*(YR Nemo .el .ds YC Copyright \(co \\*(YR Nemo .ie n .TH \\$2 "\\$3" "" REPLACE-TODAY "REPLACE-TITLE (\\$4)" .el .TH \\$2 "\\$3" "" REPLACE-TODAY "REPLACE-TITLE (\\$4)" .ds ]H \\$2 .. .de RZ .SH \\s14\\$1 .rs .ie n .sp 1 .el .sp 6p .in \\n[IN] \" this is a hack - better to use nr register??? \\*(]H \- \\$2 .fi .PP .. .\" # Ingredient .de IG .ds =1 \\$1 .ds =2 \\$2 .if \\n(.$>2 .if \\nM .ds =1 \\$3 .TP 10 \&\\*(=1 .I \\*(=2 .. .\" # Step .de SK .IP "(\\$1)" 5n .. .\" # Ingredient header .de IH .ds =1 \\$1 .if \\n(.$>1 .if \\nM .ds =1 \\$2 .SH INGREDIENTS (\\*(=1) .fi .PD 0 .. .\" # Procedure header .de PH .PD .ie '\\$1'' .SH PROCEDURE .el .SH PROCEDURE \\$1 .RS 5 .. .\" # Temperature value .de To .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 .. .\" # inline value selector .de AB .ds =1 \\$1 .if \\nM .ds =1 \\$2 .ds =2 .if \\n($>2 .ds =2 \\$3 \\*(=1\\*(=2 .. .\" # Notes .de NX .PD .SH NOTES .. .\" # Wrapup .de WR .RE 5 .PD .SH CONTRIBUTOR .nf .. .\" these CS macros courtesy of Bernie Cosell and Matt Bishop .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 case $FRACTIONS in 1) cat ;; *) 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|''|\"|" ;; esac | # strip comments and .ig sections sed -e "/^\.ig/,/^\.\./d" -e "/^\.\\\"/d" | case $VERBATIM in 0) awk -f $TMPFILE;; 1) awk '{print}';; esac | # switch alt.gourmand use of .TE -> .To, to avoid table conflict awk '/^\.TE / {if (NF > 1) sub("\.TE", ".To")}; {print}' | # conversions for special French characters as in alt.gourmand # and a proper-name o' also from alt.gourmand sed -e "s/\\\\z\\\(aae/\\\*\(e\'/g" \ -e "s/\\\\z\\\(aao/\\\*\(o\'/g" \ -e "s/\\\\z\\\(gaa/\\\*\(a\`/g" | tbl |\ eqn -Tps |\ $TROFF $TFLAG $METFLAG $TMAC - echo "DONE: cat stdin | case fractions | case verbatim | alt.gourmand-conv | tbl | eqn -Tps | $TROFF $TFLAG $METFLAG $TMAC -" 1>&2 exit