groff-commit
[Top][All Lists]
Advanced

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

[groff] 35/35: [man]: Fix problem with hyphenation of link text.


From: G. Branden Robinson
Subject: [groff] 35/35: [man]: Fix problem with hyphenation of link text.
Date: Tue, 21 Jun 2022 14:26:32 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 21e79bcdf2780449f6f4ce094ce03b1bd4a1e3b4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Jun 21 06:44:15 2022 -0500

    [man]: Fix problem with hyphenation of link text.
    
    * tmac/an-ext.tmac (UR, MT): Fix problem with hyphenation occuring
      before the end of the line when the line length was not the device
      default (common for man pages at the terminal) and hyperlinks were
      enabled.  The issue is that the new environment we created inherits
      the default environment's line length (its state at troff
      initialization, prior to macro package loading and configuration).
      This latent issue was exposed by post-groff 1.22.4 changes to enable
      the hyphenation of link text and add the hyperlink feature.  Fix it by
      copying the line length at the time the macro is called, which is
      necessarily after man(7) sets up the line length, to the new
      environment.
    
    In the following, bear in mind that the default line length for groff's
    terminal devices is 72n, but man(7) uses 78n by default.  In the before
    case, see how the hyphenation and break is perfect for 72n.
    
    Before:
    
    $ ./build/test-groff -Tutf8 -man -rU1 EXPERIMENTS/long-link-text.man
    long-link-text(1)           General Commands Manual          
long-link-text(1)
    
    Description
           long-link-text - an illustration of long link text
    
    See also
           PostScript  Language  Document Structuring Conventions Specifica‐ 
tion
    
    groff test suite                  2022‐06‐21                 
long-link-text(1)
    
    After:
    
    $ ./build/test-groff -Tutf8 -man -rU1 EXPERIMENTS/long-link-text.man
    long-link-text(1)           General Commands Manual          
long-link-text(1)
    
    Description
           long-link-text - an illustration of long link text
    
    See also
           PostScript Language Document Structuring Conventions Specification
    
    groff test suite                  2022‐06‐21                 
long-link-text(1)
---
 ChangeLog        | 14 ++++++++++++++
 tmac/an-ext.tmac | 12 ++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 3346fa03..59db0d13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-06-21  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/an-ext.tmac (UR, MT): Fix problem with hyphenation
+       occuring before the end of the line when the line length was not
+       the device default (common for man pages at the terminal) and
+       hyperlinks were enabled.  The issue is that the new environment
+       we created inherits the default environment's line length (its
+       state at troff initialization, prior to macro package loading
+       and configuration).  This latent issue was exposed by post-groff
+       1.22.4 changes to enable the hyphenation of link text and add
+       the hyperlink feature.  Fix it by copying the line length at the
+       time the macro is called, which is necessarily after man(7)
+       sets up the line length, to the new environment.
+
 2022-06-21  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/devices/grops/psrm.cpp (resource_manager::output_prolog):
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index 0c31551d..80534469 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -102,14 +102,20 @@
 .\" Start URL.
 .de UR
 .  ds m1 \\$1\"
+.  \" Save the line length, which may not be the default, so we can use
+.  \" it in the link text environment.  (groff's `evc` request copies
+.  \" too much, like the indentation amount.)
+.  nr mK \\n(.l
 .  \" We can only hyperlink if we're not in a diversion.
 .  nr mD 0
 .  if '\\n(.z'' .nr mD 1
 .  if \\n(mD&\\nU&\\n(mU \{\
 .    \" Start diversion in a new environment.
 .    do ev link-text-env
+.    do ll \\n(mK
 .    do di link-text-div
 .  \}
+.  rr mK
 ..
 .
 .
@@ -158,14 +164,20 @@
 .\" Start email address.
 .de MT
 .  ds m1 \\$1\"
+.  \" Save the line length, which may not be the default, so we can use
+.  \" it in the link text environment.  (groff's `evc` request copies
+.  \" too much, like the indentation amount.)
+.  nr mK \\n(.l
 .  \" We can only hyperlink if we're not in a diversion.
 .  nr mD 0
 .  if '\\n(.z'' .nr mD 1
 .  if \\n(mD&\\nU&\\n(mU \{\
 .    \" Start diversion in a new environment.
 .    do ev link-text-env
+.    do ll \\n(mK
 .    do di link-text-div
 .  \}
+.  rr mK
 ..
 .
 .



reply via email to

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