gbranden pushed a commit to branch master
in repository groff.
commit b1a6d6beefb4bf9a0bc31d0fdb3b5f2955be2e7c
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jan 1 04:37:59 2026 -0600
[mm]: Improve page bottom layout.
...and revise page layout computations.
* contrib/mm/m.tmac: Add new register `pg*below-text-gap` to track the
size of the gap we want below the text area regardless of any other
material that follows (footnotes, bottom blocks, secondary footers, or
primary footers). Initialize it to `1v` (stealing this amount from
`ft*margin-below` when it is nonzero).
(hd@set-page): Compute `pg*foot-trap` using it, and report this
computation at appropriate debugging level.
(FE): Reduce `ft*margin-below` to 1v.
(ft@check-old): When a footnote is _not_ still pending after a page
break, set `ft*margin-below` back to zero and update trap locations.
(pg@header): Revise computation to include `pg*below-text-gap`. If a
page is insufficiently long, report how much the package needs.
* tests/short-pages-do-not-overflow-stack.sh: Update test expectations.
---
contrib/mm/ChangeLog | 21 ++++++++++++++++
contrib/mm/m.tmac | 29 ++++++++++++++++------
.../mm/tests/short-pages-do-not-overflow-stack.sh | 6 ++---
3 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index cd0317328..90a7a1932 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,24 @@
+2026-01-01 G. Branden Robinson <[email protected]>
+
+ Revise page layout computations.
+
+ * m.tmac: Add new register `pg*below-text-gap` to track the size
+ of the gap we want below the text area regardless of any other
+ material that follows (footnotes, bottom blocks, secondary
+ footers, or primary footers). Initialize it to `1v` (stealing
+ this amount from `ft*margin-below` when it is nonzero).
+ (hd@set-page): Compute `pg*foot-trap` using it, and report this
+ computation at appropriate debugging level.
+ (FE): Reduce `ft*margin-below` to 1v.
+ (ft@check-old): When a footnote is _not_ still pending after a
+ page break, set `ft*margin-below` back to zero and update trap
+ locations.
+ (pg@header): Revise computation to include `pg*below-text-gap`.
+ If a page is insufficiently long, report how much the package
+ needs.
+ * tests/short-pages-do-not-overflow-stack.sh: Update test
+ expectations.
+
2026-01-01 G. Branden Robinson <[email protected]>
* m.tmac: Put a two-vee margin between the footnote area and
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 0a4de64b7..3f7398b60 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -1377,6 +1377,7 @@ numeric; got '\\$1'
.\"
.nr pg*top-margin 0
.nr pg*foot-margin 0
+.nr pg*below-text-gap 1v
.nr pg*block-size 0
.nr pg*footer-size 6v\" 1v+footer+even/odd footer+3v
.nr pg*header-size 7v\" 3v+header+even/odd header+2v
@@ -1395,12 +1396,14 @@ numeric; got '\\$1'
.\"-------------------------
.\" footer TRAPS: set, enable and disable
.de pg@set-new-trap
-.nr pg*foot-trap \\n[@pl]u-(\\n[pg*block-size]u+\
+.nr pg*foot-trap \\n[@pl]u-(\
+\\n[pg*below-text-gap]u+\\n[pg*block-size]u+\
\\n[ft*note-size]u+\\n[ft*margin-below]u+\
\\n[pg*foot-margin]u+\\n[pg*footer-size]u+\
\\n[pg*extra-footer-size]u)
.\"
-.if \\n[D]>=6 .tm \\$0: pg*foot-trap=\\n[@pl]u-(\\n[pg*block-size]u+\
+.if \\n[D]>=6 .tm \\$0: pg*foot-trap=\
+\\n[pg*below-text-gap]u+\\n[pg*block-size]u+\
\\n[ft*note-size]u+\\n[ft*margin-below]u+\
\\n[pg*foot-margin]u+\\n[pg*footer-size]u+\
\\n[pg*extra-footer-size]u)=\\n[pg*foot-trap]u
@@ -1480,11 +1483,17 @@ numeric; got '\\$1'
.if \\n[D] .tm Page #\\n[%] (\\n[.F]:\\n[c.])
.\" Disable in HTML mode
.if !'\*[.T]'html' \{\
-. if (u;(\\n[pg*header-size] + \\n[pg*extra-header-size] \
- + \\n[pg*footer-size] + \\n[pg*extra-footer-size] \
- + \\n[.V]) >= \\n[.p]) \{\
+. \" We need room for all this plus one line of body text (`.V`).
+. nr pg*required-page-length \
+(u;\\n[pg*header-size] + \\n[pg*extra-header-size] \
+ + \\n[pg*footer-size] + \\n[pg*extra-footer-size] \
+ + \\n[pg*below-text-gap] + \\n[.V])
+. if (\\n[pg*required-page-length] > \\n[.p]) \{\
. pl \\n[nl]u
-. @error insufficient page length; aborting
+. ds pg*msg insufficient page length; need at least
+. as pg*msg " \\n[pg*required-page-length]u,
+. as pg*msg " have \\n[.p]u; aborting
+. @error \\*[pg*msg]
. \}
.\}
.ie \\n[Hy] .@enable-hyphenation
@@ -2102,7 +2111,7 @@ dn=\\n[dn]
. debug@emit ft*tmp-div
. debug@di
. nr ft*note-size +\\n[dn]
-. nr ft*margin-below 2v
+. nr ft*margin-below 1v
.\}
.rm ft*tmp-div
.ev
@@ -2126,7 +2135,7 @@ dn=\\n[dn]
.\"-----------------
.\" check if any pending footnotes, see pg@header
.de ft@check-old
-.if d ft*next-div \{\
+.ie d ft*next-div \{\
. ev ft*ev
. ft@init
. ft@init-footnote
@@ -2141,6 +2150,10 @@ dn=\\n[dn]
. nr ft*exist 0
. pg@move-trap
.\}
+.el \{\
+. nr ft*margin-below 0
+. pg@move-trap
+.\}
..
.\"########### module display ###################
.nr ds*wide 0\" >0 if wide displays wanted
diff --git a/contrib/mm/tests/short-pages-do-not-overflow-stack.sh
b/contrib/mm/tests/short-pages-do-not-overflow-stack.sh
index 953a3aa07..a802850f0 100755
--- a/contrib/mm/tests/short-pages-do-not-overflow-stack.sh
+++ b/contrib/mm/tests/short-pages-do-not-overflow-stack.sh
@@ -45,11 +45,11 @@ output=$(printf "%s\n" "$input" \
echo "$output"
test "$(echo "$output" | wc -l)" -eq 132 || wail # 66 lines * 2 pages
-echo "checking that sample document fits using -rL6v" >&2
+echo "checking that sample document fits using -rL15v" >&2
output=$(printf "%s\n" "$input" \
- | "$groff" -b -rL6v -mm -Tascii -P-cbou | nl -ba)
+ | "$groff" -b -rL15v -mm -Tascii -P-cbou | nl -ba)
echo "$output"
-test "$(echo "$output" | wc -l)" -eq 48 || wail # 6 lines * 8 pages
+test "$(echo "$output" | wc -l)" -eq 45 || wail # 15 lines * 3 pages
echo "checking that sample document fails gracefully using -rL5v" >&2
error=$(printf "%s\n" "$input" \
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit