groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Groff] How to view 'preprocessed' groff files


From: Ted Harding
Subject: RE: [Groff] How to view 'preprocessed' groff files
Date: Tue, 29 May 2001 18:49:23 +0100 (BST)

On 29-May-01 Christoph Kaegi wrote:
> Is it possible to look at the preprocessed files, 
> after all macros are replaced, but before troff
> is run?
> 
> I couldn't find an option in the groff(1) and troff(1)
> man pages. The -Z option produces already troff-processed
> output.

You may be confusing two things here. To one of them, the
answer is "Yes"; to the other, "No".

As far as the input to troff is concerned, after the original
source file has been processed by the various preprocessors
(such as eqn, pic, tbl) but before it begins to be processed
by troff, you can do something like

  tbl source.file | pic | eqn > preprocessed.file

or

  tbl source.file | pic | eqn | tee preprocessed.file | troff

if you also want to run troff on it at the same time. In this way
you can find out what the preprocessed file contains, after it has
been seen by all the preprocessors, but before it starts to be
handled by troff.

However, this will leave all macros (explicit and implicit)
"unreplaced". Only troff replaces macros by what they evaluate
to (and only troff reads in standard macro packages, such as
tmac.s if you evoke as "troff -ms", and the PostScript macros
if you evoke as "troff -Tps", etc.). So there is no way to
find out what happens to macros, or even to find out which
standard macros are read in prior to troff processing, without
running troff. Even if you explicitly insert

  .so macro.package

this will still not happen until troff is run. (A slight but
trivial exception to the above: if you actually know the names of
the macro packages which troff will read in, and in what order,
then of course you could "paste" them in explicitly with your
test editor. Then you would be able to see these macros. But you
still would not know what the macros evaluate to.)

Incidentally, the notion of "after all macros are replaced, but
before troff is run" doesn't make much sense anyway. Troff does
not initially expand all macros and then run itself on the
resulting file; it evaluates them as and when it comes to them.
Indeed, "initially expanding all macros" does not make much sense,
since most macros involve arguments or troff registers or
diversions whose values or contents may well change throughout
the processing of the document. Even the definition of a macro
may be changed dynamically.

However, if what you really mean is "what did the macros evaluate
to prior to generating the formatted output?", then I'm afraid the
anwer is still "No", since in troff the formatting is not done
after the whole file has been read and all the macros have been
expanded: the formatted line is output as soon as troff knows enough
about it to put it into final form. In any case, the evaluation
of certain macros will depend on the results of formatting (e.g.
on the distance to the end of the page).

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 284 7749
Date: 29-May-01                                       Time: 18:49:23
------------------------------ XFMail ------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]