groff-commit
[Top][All Lists]
Advanced

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

[groff] 11/20: [tbl]: Improve symmetry of tables in nroff mode.


From: G. Branden Robinson
Subject: [groff] 11/20: [tbl]: Improve symmetry of tables in nroff mode.
Date: Fri, 3 Feb 2023 16:47:54 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 8f066786ea3cb5e1dbade1149e7d50ae978da202
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: 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 |
    +---+---+---+
---
 ChangeLog                                             | 15 +++++++++++++++
 src/preproc/tbl/table.cpp                             |  2 ++
 src/preproc/tbl/tbl.am                                |  1 -
 src/preproc/tbl/tests/check-horizontal-line-length.sh |  8 ++++----
 src/preproc/tbl/tests/check-line-intersections.sh     |  2 +-
 src/preproc/tbl/tests/check-vertical-line-length.sh   |  2 +-
 6 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2427e45a8..ad6dbf631 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,21 @@
        * src/preproc/tbl/tbl.am (tbl_TESTS): Run tests.
        (tbl_XFAIL_TESTS): Add; future changes will resolve these.
 
+2023-02-02  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * 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.
+
 2023-02-02  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/tbl/table.cpp (table::compute_total_separation):
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 126f1c2d2..0d1b13186 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -2287,6 +2287,8 @@ void table::compute_column_positions()
   printfs(".nr %1 %2*\\n[" SEPARATION_FACTOR_REG "]\n",
          column_start_reg(0),
          as_string(left_separation));
+  if (left_separation)
+    printfs(".if n .nr %1 +1n\n", column_start_reg(0));
   int i;
   for (i = 1;; i++) {
     printfs(".nr %1 \\n[%2]+\\n[%3]\n",
diff --git a/src/preproc/tbl/tbl.am b/src/preproc/tbl/tbl.am
index 8de8da607..4333b732a 100644
--- a/src/preproc/tbl/tbl.am
+++ b/src/preproc/tbl/tbl.am
@@ -48,7 +48,6 @@ TESTS += $(tbl_TESTS)
 EXTRA_DIST += $(tbl_TESTS)
 
 tbl_XFAIL_TESTS = \
-  src/preproc/tbl/tests/boxes-and-vertical-rules.sh \
   src/preproc/tbl/tests/expand-region-option-works.sh \
   src/preproc/tbl/tests/table-lacks-spurious-top-border.sh \
   src/preproc/tbl/tests/x-column-modifier-works.sh
diff --git a/src/preproc/tbl/tests/check-horizontal-line-length.sh 
b/src/preproc/tbl/tests/check-horizontal-line-length.sh
index eeb49133e..3d5e2a23c 100755
--- a/src/preproc/tbl/tests/check-horizontal-line-length.sh
+++ b/src/preproc/tbl/tests/check-horizontal-line-length.sh
@@ -56,8 +56,8 @@ _
 
 echo "checking intersection of vertical and horizontal rules" >&2
 output=$(printf "%s" "$input" | "$groff" -Tascii -t)
-echo "$output" | sed -n '1p' | grep -Eqx '\+-{11}\+' || wail
-echo "$output" | sed -n '3p' | grep -Eqx '\+-{11}\+' || wail
+echo "$output" | sed -n '1p' | grep -Eqx '\+-{12}\+' || wail
+echo "$output" | sed -n '3p' | grep -Eqx '\+-{12}\+' || wail
 
 input='.ll 12n
 .TS
@@ -70,8 +70,8 @@ L.
 
 echo "checking width of boxed table" >&2
 output=$(printf "%s" "$input" | "$groff" -Tascii -t)
-echo "$output" | sed -n '1p' | grep -Eqx '\+-{11}\+' || wail
-echo "$output" | sed -n '3p' | grep -Eqx '\+-{11}\+' || wail
+echo "$output" | sed -n '1p' | grep -Eqx '\+-{12}\+' || wail
+echo "$output" | sed -n '3p' | grep -Eqx '\+-{12}\+' || wail
 
 test -z "$fail"
 
diff --git a/src/preproc/tbl/tests/check-line-intersections.sh 
b/src/preproc/tbl/tests/check-line-intersections.sh
index 98f803639..2012bebaf 100755
--- a/src/preproc/tbl/tests/check-line-intersections.sh
+++ b/src/preproc/tbl/tests/check-line-intersections.sh
@@ -42,7 +42,7 @@ echo "$output"
 for l in 1 3 5 7
 do
     echo "checking intersections on line $l"
-    echo "$output" | sed -n ${l}p | grep -Fqx '+--+---+---+' || wail
+    echo "$output" | sed -n ${l}p | grep -Fqx '+---+---+---+' || wail
 done
 
 # TODO: Check `-Tutf8` output for correct crossing glyph identities.
diff --git a/src/preproc/tbl/tests/check-vertical-line-length.sh 
b/src/preproc/tbl/tests/check-vertical-line-length.sh
index 9b08dcb68..1aafd0913 100755
--- a/src/preproc/tbl/tests/check-vertical-line-length.sh
+++ b/src/preproc/tbl/tests/check-vertical-line-length.sh
@@ -42,7 +42,7 @@ _
 
 echo "checking length of plain vertical rule" >&2
 output=$(printf "%s" "$input" | "$groff" -Tascii -t)
-echo "$output" | sed -n '2p' | grep -Fqx -- '|1234567890 |' || wail
+echo "$output" | sed -n '2p' | grep -Fqx -- '| 1234567890 |' || wail
 
 test -z "$fail"
 



reply via email to

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