gbranden pushed a commit to branch master
in repository groff.

commit 45e76a78ef23cad03893b3125fa05a45e1cf7e4d
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Wed Jul 16 11:09:45 2025 -0500

    [mdoc]: Refactor to simplify hyphenation handling.
    
    * tmac/mdoc/doc-common (doc-reset-hyphenation-mode): Refactor to
      simplify.  Now that continuous rendering mode is handled via a
      humongous page length, it's no longer necessary for this macro package
      to use a different hyphenation mode in continuous rendering mode.  (It
      formerly was, because the [invisible] bottom of each output page had
      what our documentation terms an "implicit page trap", causing
      hyphenation to be suppressed on some output lines for no obvious
      reason.)  We no longer have to dance around that: kill the logic for
      it.
    
    * tmac/tests/localization-works.sh: Add test cases for use of mdoc with
      every locale supported by groff.
---
 ChangeLog                        | 17 ++++++++
 tmac/mdoc/doc-common             |  8 +---
 tmac/tests/localization-works.sh | 91 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d0184bb5c..8fc2d63ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2025-07-16  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [mdoc]: Refactor to simplify hyphenation handling.
+
+       * tmac/mdoc/doc-common (doc-reset-hyphenation-mode): Refactor to
+       simplify.  Now that continuous rendering mode is handled via a
+       humongous page length, it's no longer necessary for this macro
+       package to use a different hyphenation mode in continuous
+       rendering mode.  (It formerly was, because the [invisible]
+       bottom of each output page had what our documentation terms an
+       "implicit page trap", causing hyphenation to be suppressed on
+       some output lines for no obvious reason.)  We no longer have to
+       dance around that: kill the logic for it.
+
+       * tmac/tests/localization-works.sh: Add test cases for use of
+       mdoc with every locale supported by groff.
+
 2025-07-16  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [mdoc]: Refactor hyphenation mode handling.
diff --git a/tmac/mdoc/doc-common b/tmac/mdoc/doc-common
index dea488c5a..304a46874 100644
--- a/tmac/mdoc/doc-common
+++ b/tmac/mdoc/doc-common
@@ -1134,12 +1134,8 @@
 .de doc-reset-hyphenation-mode
 .  nr doc-want-hyphenation 1
 .  if r HY .ie !\n[HY] .nr doc-want-hyphenation 0
-.  ie \n[doc-want-hyphenation] \{\
-.    ie \n[cR] \
-.      nr doc-hyphenation-mode \n[\*[locale]*hyphenation-mode-base]
-.    el \
-.      nr doc-hyphenation-mode \n[\*[locale]*hyphenation-mode-trap]
-.  \}
+.  ie \n[doc-want-hyphenation] \
+.    nr doc-hyphenation-mode \n[\*[locale]*hyphenation-mode-trap]
 .  el .nr doc-hyphenation-mode 0
 .  hy \n[doc-hyphenation-mode]
 .  rr doc-want-hyphenation
diff --git a/tmac/tests/localization-works.sh b/tmac/tests/localization-works.sh
index 0ec8742fd..6f0da8910 100755
--- a/tmac/tests/localization-works.sh
+++ b/tmac/tests/localization-works.sh
@@ -196,6 +196,97 @@ output=$(printf "%s\n" "$input" | "$groff" -K utf8 -Tutf8 
-P-cbou \
 echo 'checking -man with -mzh -men' >&2
 echo "$output" | grep -Fqx '.hy=6' || wail
 
+input='.
+.Dd 2025-07-16
+.Dt foo 1
+.Os "groff test suite"
+.tm .hy=\n[.hy]
+.'
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mcs 2>&1)
+echo 'checking -mdoc with -mcs' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mde 2>&1)
+echo 'checking -mdoc with -mde' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -men 2>&1)
+echo 'checking -mdoc with -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mes 2>&1)
+echo 'checking -mdoc with -mes' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mfr 2>&1)
+echo 'checking -mdoc with -mfr' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mit 2>&1)
+echo 'checking -mdoc with -mit' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -mru 2>&1)
+echo 'checking -mdoc with -mru' >&2
+echo "$output" | grep -Fqx '.hy=2' || wail
+
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc -msv 2>&1)
+echo 'checking -mdoc with -msv' >&2
+echo "$output" | grep -Fqx '.hy=34' || wail
+
+# Ensure that the 'trap bit' (hyphenation value 2, which has nothing to
+# do with any language) is preserved when switching locales back from a
+# CJK language, since those languages' modes unconditionally clear it.
+
+input='.
+.Dd 2025-07-16
+.Dt foo 1
+.Os "groff test suite"
+.Sh 名前
+.Nm foo
+.Nd APT 用選択制御ファイル
+.mso en.tmac
+.Dd 2025-07-16
+.Dt bar 1
+.Os "groff test suite"
+.Sh Name
+.Nm bar
+.Nd three subjects walk into this
+.\".Sh Description
+.\"Stuff.
+.tm .hy=\n[.hy]
+.'
+
+output=$(printf "%s\n" "$input" | "$groff" -K utf8 -Tutf8 -P-cbou \
+  -mdoc -mja -men 2>&1)
+echo 'checking -mdoc with -mja -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
+input='.
+.Dd 2025-07-16
+.Dt foo 1
+.Os "groff test suite"
+.Sh 名称
+.Nm foo
+.Nd 解析 mdoc 手册页的头部信息
+.mso en.tmac
+.Dd 2025-07-16
+.Dt bar 1
+.Os "groff test suite"
+.Sh Name
+.Nm bar
+.Nd three subjects walk into this
+.\".Sh Description
+.\"Stuff.
+.tm .hy=\n[.hy]
+.'
+
+output=$(printf "%s\n" "$input" | "$groff" -K utf8 -Tutf8 -P-cbou \
+  -mdoc -mzh -men 2>&1)
+echo 'checking -mdoc with -mzh -men' >&2
+echo "$output" | grep -Fqx '.hy=6' || wail
+
 test -z "$fail"
 
 # vim:set ai et sw=4 ts=4 tw=72:

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to