jhv@houxu.UUCP (01/16/87)
In article <595@cubsvax.UUCP>, peters@cubsvax.UUCP (Peter S. Shenkin) writes: > First I put this alias in my .login: > alias roff 'sed -e 1s/\.\.// -e 1s/@/!*/ -e 2,\$d !* | sh &' > Then I begin each troff source file with a line like: > ..eqn @ | ltroff -me My approach is to use the shell's "here-document" capability, putting the command line to format the document as the first line of the document, and executing the file when I need processed output, for example (to include tbl, eqn, and pic preprocessors and to print the output on an Imagen printer): tbl <<!EOF | eqn | pic | troff -mm | ipr -ltroff ... !EOF Then either make the file executable with chmod, or type sh filename to get the formatted output.
ken@rochester.UUCP (01/17/87)
That is fine for a small document, like a resume, but after a certain size, number of included diagrams, index building, etc, make is the way to go. Also makes it easy for people to customize the pipes to their local environment. Every laser printer mfr puts out Yet Another *roff command! Ken
gwyn@brl-smoke.ARPA (Doug Gwyn ) (01/20/87)
In article <920@houxu.UUCP> jhv@houxu.UUCP (James Van Ornum) writes: > tbl <<!EOF | eqn | pic | troff -mm | ipr -ltroff > ... > !EOF That's pretty cute, but it assumes there is only one way the document will ever be formatted/typeset. In case anyone wants to pursue this subject, I enclose an extension of the "doctype" command described in Kernighan & Pike; followups should go to some other newsgroup, or if you have improvements please send them to me <Gwyn@BRL.ARPA>: #!/usr/5bin/sh # doctype -- synthesize proper command line for troff # adapted from Kernighan & Pike # last edit: 86/08/25 D A Gwyn # SCCS ID: @(#)doctype.sh 1.8 PATH=/usr/5bin:/bin:/usr/bin if pdp11 then MACDIR=/usr/lib/tmac else MACDIR=/usr/5lib/tmac # BRL System V emulation fi eopt= macs= opts= topt= for i do case "$i" in -e) eopt="$i"; shift;; -m*) macs="$macs $i"; shift;; -T*) topt=" $i"; shift;; --) shift; break;; -) break;; -*) opts="$opts $i"; shift;; *) break;; esac done if [ $# -gt 0 ] then s="cat $* | " else s= fi t=`cat $* | egrep '^\.(EQ|TS|\[|P|G1|IS)' | sort -u | awk ' /^\.P$/ { mm++ } /^\.PP/ { ms++ } /^\.EQ/ { eqn++ } /^\.TS/ { tbl++ } /^\.PS/ { pic++ } /^\.G1/ { grap++ } /^\.IS/ { ideal++ } /^\.\[/ { refer++ } END { if (refer > 0) printf "refer | " if (grap > 0) printf "grap | " if (grap > 0 || pic > 0) printf "_PIC_ | " if (ideal > 0) printf "ideal | " if (tbl > 0) printf "tbl | " if (eqn > 0) printf "_EQN_ | " printf "_TROFF_" if (grap > 0 || pic > 0) printf " -mpic" if (mm > 0) printf " -mm" if (ms > 0 && mm == 0) printf " -ms" printf " -\n" } ' | sed -e s/_PIC_/"pic$topt"/ -e s/_EQN_/"eqn$topt"/ \ -e s/_TROFF_/"troff$topt$opts$macs"/ -e s%' -m'%" $MACDIR/tmac."%g` if [ -n "$eopt" ] then eval "$s$t" else echo $s$t fi
garyp@cognos.UUCP (Gary Puckering) (01/21/87)
In article <920@houxu.UUCP> jhv@houxu.UUCP writes: >My approach is to use the shell's "here-document" capability, putting the >command line to format the document as the first line of the document, and >executing the file when I need processed output, for example (to include >tbl, eqn, and pic preprocessors and to print the output on an Imagen >printer): > tbl <<!EOF | eqn | pic | troff -mm | ipr -ltroff > ... > !EOF >Then either make the file executable with chmod, or type sh filename to get >the formatted output. Neat idea. I like it. One problem though -- how do you allow for both printed output and terminal output. So, I fiddled for awhile and got this to work: if test "$1" = -p then roff="ptroff -ms" else roff="nroff -ms | more" fi echo $roff eval $roff <<!EOF ... !EOF Run this through sh and it will nroff to the terminal. Add the -p parameter and it will ptroff to the printer. -- Gary Puckering 3755 Riverside Dr. Cognos Incorporated Ottawa, Ontario (613) 738-1440 CANADA K1G 3N3