bug-groff
[Top][All Lists]
Advanced

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

[bug #61597] [tbl] make "|" column classifier output less ugly in nroff


From: G. Branden Robinson
Subject: [bug #61597] [tbl] make "|" column classifier output less ugly in nroff mode
Date: Wed, 1 Dec 2021 11:40:47 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

URL:
  <https://savannah.gnu.org/bugs/?61597>

                 Summary: [tbl] make "|" column classifier output less ugly in
nroff mode
                 Project: GNU troff
            Submitted by: gbranden
            Submitted on: Wed 01 Dec 2021 04:40:45 PM UTC
                Category: Preprocessor tbl
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

In principle, handling of the "|" column classifier in nroff mode should be
straightforward.  In practice, it's not: Unix V7 nroff, Heirloom Doctools
nroff, and GNU {n,t}roff all do different ugly things with simple applications
of it.

Input:

$ cat EXPERIMENTS/tbl-verticals.roff 
.TS
tab($);
|L|L|.
foo$bar
.TE
.TS
tab($);
|0L0L0|.
baz$qux
.TE


In the first table, were trying to just set a long table entry between
vertical bars, as if it were a boxed table missing its top and bottom borders.
 In the second example, we're trying to get rid of the "one en" of space that
GNU roff's tbl(1) page documents is placed after a leading and before a
trailing pipe in a row description.

Let's see what this produces.

Unix V7 output:

$  tbl vertlines.roff | nroff
 foo   bar
|
    |
          |
 bazqux
|
      |


The above appears to be completely broken.

What about Heirloom?


$ ./bin/tbl tbl-verticals.roff | nroff | cat -s
│ foo│  bar│
│ bazqu│



Considerably better, but the use of the zero column separation after the
interior line has unfortunate results.

And groff 1.22.4?


$ tbl EXPERIMENTS/tbl-verticals.roff | nroff | cat -s
tbl:EXPERIMENTS/tbl-verticals.roff:8: unrecognised format '0'
tbl:EXPERIMENTS/tbl-verticals.roff:8: giving up on this table
grotty:<standard input> (EXPERIMENTS/tbl-verticals.roff):22: character above
first line discarded
grotty:<standard input> (EXPERIMENTS/tbl-verticals.roff):26: character above
first line discarded
grotty:<standard input> (EXPERIMENTS/tbl-verticals.roff):30: character above
first line discarded
│foo │ bar │



For the first table ("foo bar"), the differences between Heirloom  and GNU are
interesting.  Heirloom appears to be militantly consistent: a vertical line
never gets a space before itself and always gets one after itself, even where
not necessary.  Observe the two spaces before "bar".

But with the second table, ("baz qux"), the GNU tbl parser gets angry; it
appears to not even expect any column modifiers after '|', which is not
documented by Lesk 1979 or by us.  That would even _almost_ make sense--were
it not for column separation.  You could try to argue for the modifiers 'u'
(row staggering) and 'w' to be applicable to them, but I wouldn't.

Worse, there are these howls about characters above the first input line. 
Let's add an .sp to the beginning of the file to see if we can spot what it's
trying to do.


$ tbl EXPERIMENTS/tbl-verticals-with-sp.roff | nroff | cat -s
tbl:EXPERIMENTS/tbl-verticals-with-sp.roff:9: unrecognised format '0'
tbl:EXPERIMENTS/tbl-verticals-with-sp.roff:9: giving up on this table
│    │     │
│foo │ bar │



GNU tbl has done this for a long time.  It is uglier than hell.  Perhaps it
arises from a simple rounding error that no one ever fixed.  (And that in turn
might be similar to one that makes GNU tbl's horizontal rules and box lines
eat 79 character cells when the line length is configured to 78n.)

But while those problems annoy me, for this bug I want to focus on the
vertical line/column separation interaction issue.

I propose that GNU tbl be changed so the "|" column classifier adds one en of
space after a leading occurrence on a table row.  I further propose that its
format parser accept, as a special case, a column width modifier of zero (and
only zero), which prevents the insertion of one en of space before or after
the vertical line.

I envision the following input/output.


.TS
tab($);
|L|L|.
foo$bar
.TE
.TS
tab($);
|0 L |0 L |0.
baz$qux
.TE
| foo | bar |
|baz|qux|


...with no diagnostics emitted.

The foregoing would approximate troff output of the tbl inputs shown above. 
We currently have to achieve this with dummy zero-width columns, documented in
our tbl(1) page for many years.


$ cat EXPERIMENTS/tbl-verticals-for-troff.roff
.TS
tab($);
|L|L|.
foo$bar
.TE
.TS
tab($);
L0|L0|L0|L.
\&$baz$qux$\&
.TE


Screenshot of GNU troff/grops 1.22.4 output attached.

Comments?





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 01 Dec 2021 04:40:45 PM UTC  Name: tbl_2021-12-02.png  Size: 5KiB  
By: gbranden

<http://savannah.gnu.org/bugs/download.php?file_id=52399>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61597>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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