groff-commit
[Top][All Lists]
Advanced

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

[groff] 08/09: an-ext.tmac: Fix hyphenation bug.


From: G. Branden Robinson
Subject: [groff] 08/09: an-ext.tmac: Fix hyphenation bug.
Date: Sat, 15 Aug 2020 13:15:55 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 618490dd26af4fc34f834f48296ec1352355ef6f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Aug 16 03:03:34 2020 +1000

    an-ext.tmac: Fix hyphenation bug.
    
    The UR/UE and MT/ME macros were much too aggressive about turning
    hyphenation off.  Disable it only when writing the actual URL or email
    address.
    
    * tmac/an-ext.tmac (.MT, .UR): Stop disabling hyphenation here.
      (.ME, .UE): Disable hyphenation right before output of URL/address;
      restore it right before output of supplementary arguments
      ("punctuation").
    
    * tmac/tests/an-ext_ME_punct_hyphenates.sh:
    * tmac/tests/an-ext_MT_body_hyphenates.sh:
    * tmac/tests/an-ext_UE_punct_hyphenates.sh:
    * tmac/tests/an-ext_UR_body_hyphenates.sh: Test behavior.
    
    * tmac/tmac.am: Run the tests.
---
 ChangeLog                                | 18 +++++++++++++++
 tmac/an-ext.tmac                         | 18 ++++++++-------
 tmac/tests/an-ext_ME_punct_hyphenates.sh | 38 ++++++++++++++++++++++++++++++++
 tmac/tests/an-ext_MT_body_hyphenates.sh  | 37 +++++++++++++++++++++++++++++++
 tmac/tests/an-ext_UE_punct_hyphenates.sh | 36 ++++++++++++++++++++++++++++++
 tmac/tests/an-ext_UR_body_hyphenates.sh  | 37 +++++++++++++++++++++++++++++++
 tmac/tmac.am                             |  4 ++++
 7 files changed, 180 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c579cee..589dad7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2020-08-15  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       Fix hyphenation bug.  The UR/UE and MT/ME macros were much too
+       aggressive about turning hyphenation off.  Disable it only when
+       writing the actual URL or email address.
+
+       * tmac/an-ext.tmac (.MT, .UR): Stop disabling hyphenation here.
+       (.ME, .UE): Disable hyphenation right before output of
+       URL/address; restore it right before output of supplementary
+       arguments ("punctuation").
+
+       * tmac/tests/an-ext_ME_punct_hyphenates.sh:
+       * tmac/tests/an-ext_MT_body_hyphenates.sh:
+       * tmac/tests/an-ext_UE_punct_hyphenates.sh:
+       * tmac/tests/an-ext_UR_body_hyphenates.sh: Test behavior.
+
+       * tmac/tmac.am: Run the tests.
+
+2020-08-15  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        Adapt to the fact that \: reënables hyphenation.  Rename
        "hyphenless [discretionary] break" to "non-printing break point"
        in documentation.
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index 9155b05..1fadb28 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -96,7 +96,6 @@
 .\" Start URL.
 .de UR
 .  ds m1 \\$1\"
-.  nh
 .  if \\n(mH \{\
 .    \" Start diversion in a new environment.
 .    do ev URL-div
@@ -126,17 +125,18 @@
 \&\\$*\"
 .  \}
 .  el \{\
-.    ie \n(.g \\*(la\\*(m1\\*(ra\\$*\"
-.    el \\*(la\\*(m1\\*(ra\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9\"
+.    nh
+\\*(la\\*(m1\\*(ra\c
+.    hy \\n(HY
+.    ie \n(.g \\$*\"
+.    el \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9\"
 .  \}
-.  hy \\n(HY
 ..
 .
 .
 .\" Start email address.
 .de MT
 .  ds m1 \\$1\"
-.  nh
 .  if \\n(mH \{\
 .    \" Start diversion in a new environment.
 .    do ev URL-div
@@ -166,10 +166,12 @@
 \&\\$*\"
 .  \}
 .  el \{\
-.    ie \n(.g \\*(la\\*(m1\\*(ra\\$*\"
-.    el \\*(la\\*(m1\\*(ra\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9\"
+.    nh
+\\*(la\\*(m1\\*(ra\c
+.    hy \\n(HY
+.    ie \n(.g \\$*\"
+.    el \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9\"
 .  \}
-.  hy \\n(HY
 ..
 .
 .
diff --git a/tmac/tests/an-ext_ME_punct_hyphenates.sh 
b/tmac/tests/an-ext_ME_punct_hyphenates.sh
new file mode 100755
index 0000000..17a0ecc
--- /dev/null
+++ b/tmac/tests/an-ext_ME_punct_hyphenates.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+EXAMPLE='.TH me\-punct 1 2020-08-15 "groff test suite"
+.SH Name
+me\-punct \- mailto: trailing material is subject to hyphenation
+.SH Description
+Do not try to
+.MT groff+morestuff@gnu.org
+hyphenate a ridiculous word* without machine assistance
+.ME (*pneumonoultramicroscopicsilicovolcanoconiosis).'
+
+# Turn off break warnings; we expect an adjustment problem.
+# I kind of wish adjustment warnings were a different category from
+# break warnings.
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -Wbreak -P-cbou -man \
+    | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an-ext_MT_body_hyphenates.sh 
b/tmac/tests/an-ext_MT_body_hyphenates.sh
new file mode 100755
index 0000000..d5e98dc
--- /dev/null
+++ b/tmac/tests/an-ext_MT_body_hyphenates.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+EXAMPLE='.TH mt\-body 1 2020-08-15 "groff test suite"
+.SH Name
+mt\-body \- mailto: link text is subject to hyphenation
+.SH Description
+Do not try to
+.MT groff@gnu.org
+hyphenate the word
+pneumonoultramicroscopicsilicovolcanoconiosis
+without machine assistance
+.ME .'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
+    | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an-ext_UE_punct_hyphenates.sh 
b/tmac/tests/an-ext_UE_punct_hyphenates.sh
new file mode 100755
index 0000000..86a5412
--- /dev/null
+++ b/tmac/tests/an-ext_UE_punct_hyphenates.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+EXAMPLE='.TH ue\-punct 1 2020-08-15 "groff test suite"
+.SH Name
+ue\-punct \- URL trailing material is subject to hyphenation
+.SH Description
+Do not try to
+.UR https://www.gnu.org/software/groff/
+hyphenate a ridiculous word* without machine assistance
+.UE (*pneumonoultramicroscopicsilicovolcanoconiosis).'
+
+# Turn off break warnings; we expect an adjustment problem.
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -Wbreak -P-cbou -man \
+    | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an-ext_UR_body_hyphenates.sh 
b/tmac/tests/an-ext_UR_body_hyphenates.sh
new file mode 100755
index 0000000..ecc57b6
--- /dev/null
+++ b/tmac/tests/an-ext_UR_body_hyphenates.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+EXAMPLE='.TH ur\-body 1 2020-08-15 "groff test suite"
+.SH Name
+ur\-body \- URL link text is subject to hyphenation
+.SH Description
+Do not try to
+.UR https://www.gnu.org/software/groff/
+hyphenate the word
+pneumonoultramicroscopicsilicovolcanoconiosis
+without machine assistance
+.UE .'
+
+printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
+    | grep -qE 'pn.*-'
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index 277b850..1a67205 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -141,6 +141,10 @@ EXTRA_DIST += \
   tmac/www.tmac.in
 
 tmac_TESTS = \
+  tmac/tests/an-ext_ME_punct_hyphenates.sh \
+  tmac/tests/an-ext_MT_body_hyphenates.sh \
+  tmac/tests/an-ext_UE_punct_hyphenates.sh \
+  tmac/tests/an-ext_UR_body_hyphenates.sh \
   tmac/tests/an-old_AT_and_UC_footer_saved_and_restored.sh \
   tmac/tests/an-old_CS_register_off.sh \
   tmac/tests/an-old_CS_register_on.sh \



reply via email to

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