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

Re: groff warning: TE macro called with TW register undefined



Hi Branden,

On Wed, 16 Aug 2023 at 00:30, G. Branden Robinson wrote:
>
> Hi Hugh,
>
> I work on groff upstream.

Perfect :-)

> At 2023-08-15T22:46:30+1000, Hugh McMaster wrote:
> > groff-message an.tmac:<standard input>:66: warning: tbl preprocessor
> > failed, or it or soelim was not run; table(s) likely not rendered (TE
> > macro called with TW register undefined)
> >
> > It seems TW is not defined in the number register.
> >
> > While I can define TW by adding `.nr TW 0` before .TS, I don't know if
> > that's the correct solution.
>
> It is a bad idea.  The purpose of the `TW` register is defined in the
> tbl(1) man page.
>
>     The register TW stores the width of the table region in basic units;
>     it can’t be used within the region itself, but is defined before the
>     .TE token is output so that a groff macro named TE can make use of
>     it. [...]

Okay. I didn't think this approach was the solution.

> This information is necessary for macro packages that want to center
> tables, a common feature of packages _except_ those that render man
> pages.  Because forgetting to run the tbl preprocessor is a common
> error, during groff 1.23.0 development it occurred to me that I could
> use this register as an indicator.
>
> > Any ideas on fixing this warning, or is it best to ignore it for now?
>
> The diagnostic message is trying to warn you that you _probably_ forgot
> to run tbl.  But there are other causes.
>
> 1.  tbl crashed or aborted.
>
> 2.  The man(7) document embedded the beginning of table in a different
>     file that it "sourced" with the `so` request, but soelim(1) was not
>     run on the document.  This is valid, but not considered portable man
>     page composition style.[1]
>
> 3.  A `TE` macro call is in the man page with no `TS` preceding it.
>     This could arise due to clumsy editing, unfamiliarity with the
>     man(7) language, or bad luck combined with inexperience (an ordinary
>     text line happened to begin with `.TE` and the page author didn't
>     realize that *roff would attempt to interpret that as a macro call).
>
> I tried to cover these bases in the diagnostic, but might have failed.

This all seems promising. Unfortunately, the man page is hand-crafted,
not generated from another source, so groff is never invoked, and no
other documents are referenced in the file.

AFAICT, the syntax is correct, with .TS, table content, and .TE macros
all present.

> Can you tell me what part of the message was confusing?

I woudn't say it's confusing; the message clearly states the problem
is that TW is undefined.

For me, I see more of a "chicken and egg" problem. `groff -t` needs to
be invoked to register the TW value, but the file is hand-crafted, so
groff isn't run.

> Regards,
> Branden
>
> [1] Any *roff can handle this.  So can mandoc(1)--I just found that out.
>     This fact raises some interesting possibilities, since everything
>     that was ever called "man2html", the original motive for
>     groff_man(7)'s Portability section[2] has long gone to the dustbin.
>
> [2] In groff 1.23.0, this section is now in groff_man_style(7).


Reply to: