bugGNU roff - Bugs: bug #61597, [tbl] support "0"...

 
 

bug #61597: [tbl] support "0" modifier for "|" column classifier

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Wed 01 Dec 2021 04:40:45 PM UTC
   
 
Category:  Preprocessor tbl Severity:  3 - Normal
Item Group:  Feature change Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 20 Aug 2023 04:11:50 AM UTC, comment #7: 

Supporting a modifier where we didn't before is a feature change.

G. Branden Robinson <gbranden>
Group administrator
Thu 16 Mar 2023 09:26:19 PM UTC, comment #6: 

As part of this we should decide upon and document the semantics of combining the | classifier (with and without the "0" modifier) when it interacts with manually-specified column widths.

Consider the following input.


$ cat ATTIC/specbox.roff
.nf
1234567890123456789012345678901234567890123456789012345678901234567890
.TS
tab(@);
Lw10 Lw10.
WWWWWWWWWW@XXXXXXXXXX
.TE
.sp
.TS
tab(@);
Lw10 0 Lw10.
YYYYYYYYYY@ZZZZZZZZZZ
.TE
.sp
.TS
tab(@);
Lw10 |0 Lw10.
one@two
.TE
.sp
.TS
tab(@) allbox;
Cw(2.5i) | Cw(2.5i)
Lw(2.5i) | Lw(2.5i).
Make@Model
Gibson@Les Paul
Fender@Stratocaster
.TE
.pl \n(nlu


And observe the output.


$ ./build/test-groff -t -Tascii ATTIC/specbox.roff
1234567890123456789012345678901234567890123456789012345678901234567890
WWWWWWWWWW   XXXXXXXXXX

YYYYYYYYYYZZZZZZZZZZ

          |
one       two

+---------------------------+---------------------------+
|           Make            |           Model           |
+---------------------------+---------------------------+
| Gibson                    | Les Paul                  |
+---------------------------+---------------------------+
| Fender                    | Stratocaster              |
+---------------------------+---------------------------+


(This is from my working copy, but groff 1.22.4 produces the same output except for bug #63449, which hides the vertical space that should be observable above the "one two" table, and commit 8f066786ea.)

The issue to note here is that the "t" in "two" overprints the vertical rule between columns.  That's ugly.

G. Branden Robinson <gbranden>
Group administrator
Sat 04 Feb 2023 06:18:02 AM UTC, comment #5: 

I'm reducing the scope of this ticket to just the modifier support now, because of the following recent commit.


commit 8f066786ea3cb5e1dbade1149e7d50ae978da202
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Fri Feb 3 02:22:02 2023 -0600

    [tbl]: Improve symmetry of tables in nroff mode.

    * src/preproc/tbl/table.cpp (table::compute_column_positions): If a
      table has "left separation" (it is boxed, or has a vertical rule on
      the left-hand side), increase the first column's start register value
      by 1n, for symmetry with the right-hand size.

    * src/preproc/tbl/tests/check-horizontal-line-length.sh:
    * src/preproc/tbl/tests/check-line-intersections.sh:
    * src/preproc/tbl/tests/check-vertical-line-length.sh: Update output
      expectations.

    * src/preproc/tbl/tbl.am (tbl_XFAIL_TESTS): Remove now-passing test.

    Before:

    +--+---+---+
    |a | b | c |
    +--+---+---+
    |d | e | f |
    +--+---+---+
    |g | h | i |
    +--+---+---+

    After:

    +---+---+---+
    | a | b | c |
    +---+---+---+
    | d | e | f |
    +---+---+---+
    | g | h | i |
    +---+---+---+


G. Branden Robinson <gbranden>
Group administrator
Tue 10 Jan 2023 06:03:38 PM UTC, comment #4: 

As a slight expansion of the restriction I asserted in comment #4, a region option to apply the elision of border-adjacent space from boxed table might be worthwhile, and, I expect, not difficult to implement once the "|0" infrastructure is in place.

G. Branden Robinson <gbranden>
Group administrator
Tue 29 Nov 2022 11:47:18 AM UTC, comment #3: 

See bug #62471 for the general problem with horizontal and vertical rules being drawn too wide/tall in nroff mode.

I want to restrict this ticket to the issue I took my time getting around to in comment #0.

> 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.


This should eliminate the need for the dummy column hack documented in tbl(1), and enable a closer resemblance between typesetter and terminal output.

G. Branden Robinson <gbranden>
Group administrator
Tue 11 Jan 2022 10:13:37 PM UTC, comment #2: 

There appears to be no "standard" nroff handling of this table format (see comment #0 for how badly Unix V7 nroff and Heirloom Doctools nroff handle it), so it is neither incorrect behavior relative to some other implementation nor it is really a feature change.  I'm putting it into the "Rendering/Cosmetics" group.

G. Branden Robinson <gbranden>
Group administrator
Wed 01 Dec 2021 05:19:09 PM UTC, comment #1: 


original submission:

> were trying to just set a long table entry between vertical bars,


That should read:

"we are trying to set a pair of table entries between vertical bars"

(I ended up elaborating my input while writing the report, and forgot to edit this bit.)

G. Branden Robinson <gbranden>
Group administrator
Wed 01 Dec 2021 04:40:45 PM UTC, original submission:  

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?


G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52399:  tbl_2021-12-02.png added by gbranden (5KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-08-20 gbranden Item GroupRendering/Cosmetics Feature change
    2023-02-04 gbranden Summary[tbl] change spacing applied to &quot;|&quot; column classifier and support &quot;0&quot; modifier [tbl] support "0" modifier for "|" column classifier
    2022-11-29 gbranden Summary[tbl] make &quot;|&quot; column classifier output less ugly in nroff mode [tbl] change spacing applied to "|" column classifier and support "0" modifier
    2022-01-11 gbranden Item GroupIncorrect behaviour Rendering/Cosmetics
    2021-12-01 gbranden Attached File- Added tbl_2021-12-02.png, #52399

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code