[comp.text] Preprocessor for General Text Processing

jes@eniac.seas.upenn.edu (Joe Smith) (08/21/87)

	I am preparing to write my thesis using troff and the 
other tools from the UNIX Documentors Work Bench (tbl, eqn
col) and some of the preprocessors from other sources (lbl,
bib,soelim ), but there is one nagging problem, I must constantly
remember essentially four languages ( troff, eqn, tbl and the macro
package (ME or MS, I haven't decided ).  I am wondering if there
is a preprocessor for the whole process that will allow me to say

	#define .sqroot. @what ever the eqn code is
	#define .ECOLI.  \fIE. coli\fP
	#include ...

	I am aware that .so exists and I am aware that

	 .DS EC "\fIE. coli\fP"

would work, but then in the text I would have to reference E. coli
in the text every time by saying \*(EC. Not very readable or
easy to write.  Does any one know of any public domain or cheap software
that would allow me to do this?  I saw a man page that said 

	SEE ALSO nrpp(1)

Is this what I am looking for?

Any responses to any of the addresses below!

Thanks in Advance!

 
 Frank Kolakowski
 
 ARPA:	kolakowski%c.chem.upenn.edu@cis.upenn.edu
 	bcooperman.kolakowski@bionet-20.arpa
 	jes@eniac.seas.upenn.edu ( borrowed account )
 AT&T:	215-898-2927
 POST:	Frank Kolakowski
 	University of Pennsylvania
 	231 South 34th Street
 	Phila, PA  19104
 
Joe Smith
jes@eniac.seas.upenn.edu

University of Pennsylvania
Department of Chemistry
231 S. 34th Street
Philadelphia, PA 19104
(215) 898-4797

romwa@utgpu.UUCP (08/23/87)

In article <1828@super.upenn.edu>, jes@eniac.seas.upenn.edu (Joe Smith) writes:
> 
> 	I am preparing to write my thesis using troff and the 
> other tools from the UNIX Documentors Work Bench (tbl, eqn
> col) and some of the preprocessors from other sources (lbl,
> bib,soelim ), but there is one nagging problem, I must constantly
> remember essentially four languages ( troff, eqn, tbl and the macro
> package (ME or MS, I haven't decided ).  I am wondering if there
> is a preprocessor for the whole process that will allow me to say
> 
> 	#define .sqroot. @what ever the eqn code is
> 	#define .ECOLI.  \fIE. coli\fP
> 	#include ...
> 
> 	I am aware that .so exists and I am aware that
> 
> 	 .DS EC "\fIE. coli\fP"
> 
> would work, but then in the text I would have to reference E. coli
> in the text every time by saying \*(EC. Not very readable or
> easy to write.  Does any one know of any public domain or cheap software
> that would allow me to do this?  I saw a man page that said 
> 
> 	SEE ALSO nrpp(1)
> 
> Is this what I am looking for?

A possible solution to this is to postprocess your document
with sed or awk or even global changes with ed.  (sed is
preferred).

Set up your sed script to look like:

s/.ECOLI./\\fIE. coli\\fP/   (syntax not guaranteed)
etc...
etc...

All you have to do is set up your "defines" with sed syntax,
and then you t/nroff run a command which looks like:

eqn file | troff -macro | lp

Mark T. Dornfeld
utgpu!romwa

romwa@utgpu.UUCP (08/23/87)

I goofed up the command line in my last reply.  It should look
like

eqn file | troff -macro | sed (sedscript) | lp

romwa@utgpu.UUCP (08/24/87)

In article <1987Aug22.180919.9252@gpu.utcs.toronto.edu>, romwa@gpu.utcs.toronto.edu (Mark Dornfeld) writes:
> In article <1828@super.upenn.edu>, jes@eniac.seas.upenn.edu (Joe Smith) writes:
> > 
> > 	I am preparing to write my thesis using troff and the 
> > other tools from the UNIX Documentors Work Bench (tbl, eqn
> > col) and some of the preprocessors from other sources (lbl,
> > bib,soelim ), but there is one nagging problem, I must constantly
> > remember essentially four languages ( troff, eqn, tbl and the macro
> > package (ME or MS, I haven't decided ).  I am wondering if there
> > is a preprocessor for the whole process that will allow me to say
> > 
> > 	#define .sqroot. @what ever the eqn code is
> > 	#define .ECOLI.  \fIE. coli\fP
> > 	#include ...
> > 
> > 	I am aware that .so exists and I am aware that
> > 
> > 	 .DS EC "\fIE. coli\fP"
> > 
> > would work, but then in the text I would have to reference E. coli
> > in the text every time by saying \*(EC. Not very readable or
> > easy to write.  Does any one know of any public domain or cheap software
> > that would allow me to do this?  I saw a man page that said 
> > 
> > 	SEE ALSO nrpp(1)
> > 
> > Is this what I am looking for?
> 
> A possible solution to this is to postprocess your document
> with sed or awk or even global changes with ed.  (sed is
> preferred).
> 
> Set up your sed script to look like:
> 
> s/.ECOLI./\\fIE. coli\\fP/   (syntax not guaranteed)
> etc...
> etc...
> 
> All you have to do is set up your "defines" with sed syntax,
> and then you t/nroff with a command which looks like:
> 
> eqn file | troff -macro | sed -f sedscript | lp
>
> Give the sed man pages a look for the proper format for a
> sedscript file.
> 
> Mark T. Dornfeld
> utgpu!romwa
> 

kathy@bakerst.UUCP (Kathy Vincent) (08/24/87)

In article <1987Aug22.181117.9322@gpu.utcs.toronto.edu>, romwa@gpu.utcs.toronto.edu (Mark Dornfeld) writes:
> 
> 
> I goofed up the command line in my last reply.  It should look
> like
> 
> eqn file | troff -macro | sed (sedscript) | lp



You still have your command line mixed up.  You want your
new "defines" in the text *before* you n/troff it.

	sed (sedscript) file | eqn | troff -macro | lp


Kathy Vincent ------> Home: {ihnp4|mtune|codas|ptsfa}!bakerst!kathy
              ------> AT&T: {ihnp4|mtune|burl}!wrcola!kathy

graham@hslrswi.UUCP (Graham Tritt) (08/25/87)

>> I am wondering if there
>> is a preprocessor for the whole process that will allow me to say
>> 	#define .sqroot. @what ever the eqn code is
>> 	#define .ECOLI.  \fIE. coli\fP
>> 	#include ...
>
>A possible solution to this is to postprocess your document
>with sed or awk or even global changes with ed.  (sed is preferred).
>
>Set up your sed script to look like:
>s/.ECOLI./\\fIE. coli\\fP/   (syntax not guaranteed)
>etc...
>etc...
>
>All you have to do is set up your "defines" with sed syntax,
>and then you t/nroff run a command which looks like:
>
>eqn file | troff -macro | sed ... | lp
>
>Mark T. Dornfeld
>utgpu!romwa

What you need is a pre-processor rather than a post-processor.
Or, for instance, your line lengths and justification set by
troff (in our case nroff) will be all screwed up.
Tell me if I am wrong.

We use several extra pre(pre)processors to make such substitutions.
For instance, for words in a file "listofstrings", to insert \fI \fR
bracketing, which is handy for manual pages containing lots of
command names.  Similarly for the expansion of abbreviations.
We find that sed is enough, and can be wrapped up in a friendly
(but slow) script.  Some of these are used once only followed
by manual checking. Some are automatically called everytime
(if needed, like lbl, tbl or col) in the script which intelligently
decides what has to be done and calls nroff in the appropriate pipe.
                                                             ____________
    Graham D. Tritt                                          |  ________|__
    P.O. Box 302, 3000 Berne 25, Switzerland                 |  |    _    |
                                                             |  |  _| |_  |
Telephone:    +41 31 63 39 25                                |  | |_ + _| |
X.400:      graham@hslrswi.hasler                            |__|   |_|   |
Bitnet:     graham%hslrswi.UUCP@cernvax.BITNET                  |_________|
Uucp:       ... {seismo,ukc, ... }!mcvax!cernvax!hslrswi!graham
***************************************************************************

romwa@utgpu.UUCP (08/25/87)

In article <870@bakerst.UUCP>, kathy@bakerst.UUCP (Kathy Vincent) writes:
> In article <1987Aug22.181117.9322@gpu.utcs.toronto.edu>, romwa@gpu.utcs.toronto.edu (Mark Dornfeld) writes:
> > 
> > 
> > I goofed up the command line in my last reply.  It should look
> > like
> > 
> > eqn file | troff -macro | sed (sedscript) | lp
> 
> 
> 
> You still have your command line mixed up.  You want your
> new "defines" in the text *before* you n/troff it.
> 
> 	sed (sedscript) file | eqn | troff -macro | lp
> 
> 
> Kathy Vincent ------> Home: {ihnp4|mtune|codas|ptsfa}!bakerst!kathy
>               ------> AT&T: {ihnp4|mtune|burl}!wrcola!kathy

Yup, I knew as soon as I sent that article off that I wrote
it in a daze.  You've got what I was thinking, but somehow the
pointers got all screwed up before I sent it.

Thanks

Mark T. Dornfeld
romwa@utgpu

gls@odyssey.UUCP (g.l.sicherman) (08/27/87)

Sure, "sed" will do it.  You can also use the UNIX* macro processor
M4, which seems more appropriate for this sort of work.

*UNIX is a registered trade mark of AT&T Bell Laboratories, as if
 you didn't know.
-- 
Col. G. L. Sicherman
...!ihnp4!odyssey!gls

romwa@utgpu.UUCP (08/29/87)

In article <705@hslrswi.UUCP>, graham@hslrswi.UUCP (Graham Tritt) writes:
> >> I am wondering if there
> >> is a preprocessor for the whole process that will allow me to say
> >> 	#define .sqroot. @what ever the eqn code is
> >> 	#define .ECOLI.  \fIE. coli\fP
> >> 	#include ...
> >
> >A possible solution to this is to postprocess your document
> >with sed or awk or even global changes with ed.  (sed is preferred).
> >
> >Set up your sed script to look like:
> >s/.ECOLI./\\fIE. coli\\fP/   (syntax not guaranteed)
> >etc...
> >etc...
> >
> >All you have to do is set up your "defines" with sed syntax,
> >and then you t/nroff run a command which looks like:
> >
> >eqn file | troff -macro | sed ... | lp
> >
> >Mark T. Dornfeld
> >utgpu!romwa
> 
> What you need is a pre-processor rather than a post-processor.
> Or, for instance, your line lengths and justification set by
> troff (in our case nroff) will be all screwed up.
> Tell me if I am wrong.
No, you're right, I was wrong.  Somehow my brain got switched
off when I wrote that reply.  I preprocess troff all the time.
Nothing like a little public humiliation to put one in one's
place :-).
> 
> We use several extra pre(pre)processors to make such substitutions.
> For instance, for words in a file "listofstrings", to insert \fI \fR
> bracketing, which is handy for manual pages containing lots of
> command names.  Similarly for the expansion of abbreviations.
> We find that sed is enough, and can be wrapped up in a friendly
> (but slow) script.  Some of these are used once only followed
> by manual checking. Some are automatically called everytime
> (if needed, like lbl, tbl or col) in the script which intelligently
> decides what has to be done and calls nroff in the appropriate pipe.