[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/03: [man,mdoc]: Make base paragraph indent 5n (1/2).
From: |
G. Branden Robinson |
Subject: |
[groff] 01/03: [man,mdoc]: Make base paragraph indent 5n (1/2). |
Date: |
Thu, 10 Aug 2023 02:33:33 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 5d2e49f8182afc9bf210b7f6dd18e465319fef7b
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Aug 9 19:41:31 2023 -0500
[man,mdoc]: Make base paragraph indent 5n (1/2).
Change base paragraph indentation to 5n. This corresponds to the amount
used by historical man(7) and mdoc(7) implementations going back to Unix
Version 7 and 4.3BSD-Reno, respectively.
* tmac/an.tmac: Introduce new interface register, `BP`, to control the
base paragraph indentation amount. Formerly, `IN` determined it _and_
the default relative inset amount.
(an-reset-margin-and-inset-level, SH, SS): Use it.
* tmac/doc.tmac: Introduce `BP` register, replacing `IN`.
* tmac/mdoc/doc-common (Sh): Use it.
* src/preproc/tbl/tests/save-and-restore-tab-stops.sh:
* tmac/tests/an-ext_SY-and-YS-work.sh:
* tmac/tests/an_TH-repairs-hy-damage.sh:
* tmac/tests/an_UE-breaks-before-long-URIs.sh:
* tmac/tests/an_adjust-link-text-correctly.sh:
* tmac/tests/an_link-macros-work-in-paragraph-tags.sh:
* tmac/tests/an_use-input-traps-correctly.sh:
* tmac/tests/andoc_flush-between-packages.sh:
* tmac/tests/doc_Mt-works.sh:
* tmac/tests/doc_indents-correctly.sh:
* tmac/tests/doc_synopsis_is_not_adjusted.sh: Update amount of
indentation expected in output.
Fixes <https://savannah.gnu.org/bugs/?64018>. Thanks to Thorsten Glaser
and Ingo Schwarze for the discussion.
ANNOUNCE: Credit Ingo and Thorsten.
---
ANNOUNCE | 2 ++
ChangeLog | 31 ++++++++++++++++++++++
.../tbl/tests/save-and-restore-tab-stops.sh | 22 ++++++++-------
tmac/an.tmac | 10 ++++---
tmac/doc.tmac | 10 ++-----
tmac/mdoc/doc-common | 2 +-
tmac/tests/an-ext_SY-and-YS-work.sh | 4 +--
tmac/tests/an_TH-repairs-hy-damage.sh | 18 +++++++------
tmac/tests/an_UE-breaks-before-long-URIs.sh | 6 ++---
tmac/tests/an_adjust-link-text-correctly.sh | 2 +-
.../tests/an_link-macros-work-in-paragraph-tags.sh | 9 ++++---
tmac/tests/an_use-input-traps-correctly.sh | 2 +-
tmac/tests/andoc_flush-between-packages.sh | 11 ++++----
tmac/tests/doc_Mt-works.sh | 6 ++++-
tmac/tests/doc_indents-correctly.sh | 10 ++++---
tmac/tests/doc_synopsis_is_not_adjusted.sh | 2 +-
16 files changed, 95 insertions(+), 52 deletions(-)
diff --git a/ANNOUNCE b/ANNOUNCE
index 0c71843b8..98a5f1a9b 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -183,10 +183,12 @@ Doug McIlroy
Eloi Montañés
Frederic Chartier
Heinz-Jürgen Oertel
+Ingo Schwarze
Lennart Jablonka
Michał Kruszewski
Mike Fulton
Nikita Ivanov
Peter Schaffter
Ralph Corderoy
+Thorsten Glaser
наб
diff --git a/ChangeLog b/ChangeLog
index b71cd2a15..10e9f778a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2023-08-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [man,mdoc]: Change base paragraph indentation to 5n. This
+ corresponds to the amount used by historical man(7) and mdoc(7)
+ implementations going back to Unix Version 7 and 4.3BSD-Reno,
+ respectively.
+
+ * tmac/an.tmac: Introduce new interface register, `BP`, to
+ control the base paragraph indentation amount. Formerly, `IN`
+ determined it _and_ the default relative inset amount.
+ (an-reset-margin-and-inset-level, SH, SS): Use it.
+
+ * tmac/doc.tmac: Introduce `BP` register, replacing `IN`.
+ * tmac/mdoc/doc-common (Sh): Use it.
+
+ * src/preproc/tbl/tests/save-and-restore-tab-stops.sh:
+ * tmac/tests/an-ext_SY-and-YS-work.sh:
+ * tmac/tests/an_TH-repairs-hy-damage.sh:
+ * tmac/tests/an_UE-breaks-before-long-URIs.sh:
+ * tmac/tests/an_adjust-link-text-correctly.sh:
+ * tmac/tests/an_link-macros-work-in-paragraph-tags.sh:
+ * tmac/tests/an_use-input-traps-correctly.sh:
+ * tmac/tests/andoc_flush-between-packages.sh:
+ * tmac/tests/doc_Mt-works.sh:
+ * tmac/tests/doc_indents-correctly.sh:
+ * tmac/tests/doc_synopsis_is_not_adjusted.sh: Update amount of
+ indentation expected in output.
+
+ Fixes <https://savannah.gnu.org/bugs/?64018>. Thanks to
+ Thorsten Glaser and Ingo Schwarze for the discussion.
+
2023-08-05 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Add paranoia to `token::description()`.
diff --git a/src/preproc/tbl/tests/save-and-restore-tab-stops.sh
b/src/preproc/tbl/tests/save-and-restore-tab-stops.sh
index b98922a3a..09e15c7c9 100755
--- a/src/preproc/tbl/tests/save-and-restore-tab-stops.sh
+++ b/src/preproc/tbl/tests/save-and-restore-tab-stops.sh
@@ -26,7 +26,7 @@ groff="${abs_top_builddir:-.}/test-groff"
#
# Based on an example by Bjarni Igni Gislason.
-EXAMPLE='.TH tbl\-tabs\-test 1 2020-10-20 "groff test suite"
+input='.TH tbl\-tabs\-test 1 2020-10-20 "groff test suite"
.SH Name
tbl\-tabs\-test \- see if tbl messes up the tab stops
.SH Description
@@ -58,27 +58,29 @@ case $#
esac
.EE'
-OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -t -man)
-FAIL=
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -t -man)
+echo "$output"
-if ! echo "$OUTPUT" | grep -Eq '^ {12}if foo$'
+fail=
+
+if ! echo "$output" | grep -Eq '^ {10}if foo$'
then
- FAIL=yes
+ fail=yes
echo "first tab stop is wrong" >&2
fi
-if ! echo "$OUTPUT" | grep -Eq '^ {17}bar$'
+if ! echo "$output" | grep -Eq '^ {15}bar$'
then
- FAIL=yes
+ fail=yes
echo "second tab stop is wrong" >&2
fi
-if ! echo "$OUTPUT" | grep -Eq '^ {22}qux$'
+if ! echo "$output" | grep -Eq '^ {20}qux$'
then
- FAIL=yes
+ fail=yes
echo "third tab stop is wrong" >&2
fi
-test -z "$FAIL"
+test -z "$fail"
# vim:set ai noet sw=4 ts=4 tw=72:
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 56d4a0e34..de9bbdcaa 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -170,7 +170,7 @@
.
.de an-reset-margin-and-inset-level
. nr an-inset-level 1
-. nr an-margin \\n[IN]
+. nr an-margin \\n[BP]
. nr an-saved-margin1 \\n[IN]
. nr an-prevailing-indent \\n[IN]
. nr an-saved-prevailing-indent1 \\n[IN]
@@ -681,7 +681,7 @@ contains unsupported escape sequence
. an-break-paragraph
. an-reset-margin-and-inset-level
. fi
-. in \\n[an-margin]u
+. in \\n[BP]u
. ti 0
. nr an-devtag-needs-end-of-heading 1
. DEVTAG-SH 1
@@ -708,7 +708,7 @@ contains unsupported escape sequence
. an-break-paragraph
. an-reset-margin-and-inset-level
. fi
-. in \\n[IN]u
+. in \\n[BP]u
. ti \\n[SN]u
. nr an-devtag-needs-end-of-heading 1
. DEVTAG-SH 2
@@ -1344,6 +1344,10 @@ contains unsupported escape sequence
. if !r PDFHREF.VIEW.LEADING .nr PDFHREF.VIEW.LEADING 10p
.\}
.
+.\" base paragraph indentation
+.if !r BP \
+. nr BP 5n
+.
.\" continuous rendering (one long page)
.if !r cR \{\
. ie n .nr cR 1
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index 6267d2a08..52ed73714 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -178,14 +178,8 @@
.\" via andoc.tmac and man(1); see \n[doc-hyphen-flags] in doc-common.
.if !r HY .nr HY 1
.
-.\" Use -rIN=<xxx> to set the paragraph indentation amount.
-.if !r IN \{\
-. \" We select an integer indentation value in nroff mode because this
-. \" value is used additively for multiple purposes; rounding of
-. \" accumulating fractions would produce inconsistent results.
-. ie t .nr IN 7.2n
-. el .nr IN 7n
-.\}
+.\" Use -rBP=<xxx> to set the paragraph indentation amount.
+.if !r BP .nr BP 5n
.
.\" LL and LT registers are handled by the doc-setup-page-layout macro.
.
diff --git a/tmac/mdoc/doc-common b/tmac/mdoc/doc-common
index d37b4c001..63f3a1fbd 100644
--- a/tmac/mdoc/doc-common
+++ b/tmac/mdoc/doc-common
@@ -1483,7 +1483,7 @@
. if t \
. ss \n[doc-reg-Sh] \n[doc-reg-Sh1]
.
-. in \n[IN]u
+. in \n[BP]u
. ns
.
. doc-check-depth
diff --git a/tmac/tests/an-ext_SY-and-YS-work.sh
b/tmac/tests/an-ext_SY-and-YS-work.sh
index 550322e2b..8b7856ee7 100755
--- a/tmac/tests/an-ext_SY-and-YS-work.sh
+++ b/tmac/tests/an-ext_SY-and-YS-work.sh
@@ -66,11 +66,11 @@ echo "$output" \
-e '}' \
| grep -q . || wail
-# 11 spaces in the spaceful sed expression below
+# 9 spaces in the spaceful sed expression below
echo 'checking for correct indentation of broken synopsis lines' >&2
echo "$output" \
| sed -n -e '/foo operand1/{' \
- -e 'n;/ operand7.*/p' \
+ -e 'n;/ operand7.*/p' \
-e '}' \
| grep -q . || wail
diff --git a/tmac/tests/an_TH-repairs-hy-damage.sh
b/tmac/tests/an_TH-repairs-hy-damage.sh
index 43f3471ec..5084e42f5 100755
--- a/tmac/tests/an_TH-repairs-hy-damage.sh
+++ b/tmac/tests/an_TH-repairs-hy-damage.sh
@@ -20,22 +20,24 @@
groff="${abs_top_builddir:-.}/test-groff"
-EXAMPLE='.TH mal 1 2020-08-21 "groff test suite"
+input='.TH mal 1 2020-08-21 "groff test suite"
.SH Name
mal \- malevolent man page
.SH Description
.nh
-Wicked page disables hyphenation.
-Wicked page disables hyphenation.
-Wicked page disables hyphenation.
+A wicked page disables hyphenation.
+A wicked page disables hyphenation.
+A wicked page disables hyphenation.
.TH ino 1 2020-08-21 "groff test suite"
.SH Name
ino \- innocent man page
.SH Description
-Innocent, unoffending man page enjoys hyphenation.
-Innocent, unoffending man page enjoys hyphenation.'
+An innocent, unoffending man page enjoys hyphenation.
+An innocent, unoffending man page enjoys hyphenation.'
-printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -man \
- | grep -qE 'unoffend-'
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man)
+echo "$output"
+
+echo "$output" | grep -qE 'unof-'
# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_UE-breaks-before-long-URIs.sh
b/tmac/tests/an_UE-breaks-before-long-URIs.sh
index 2ab81a742..e7eb0122c 100755
--- a/tmac/tests/an_UE-breaks-before-long-URIs.sh
+++ b/tmac/tests/an_UE-breaks-before-long-URIs.sh
@@ -56,9 +56,9 @@ error=$(printf "%s" "$input" \
echo "testing that no diagnostic messages are produced" >&2
test -z "$error" || wail
echo "testing that lines break where expected" >&2
-break1=$(echo "$output" | grep -x " *Commerce *<https.*devnet/")
-break2=$(echo "$output" | grep -x " *actionscript/.* transaction *in")
-break3=$(echo "$output" | grep -x " *<https.*612")
+break1=$(echo "$output" | grep -x " *Commerce *<https.*actionscript/")
+break2=$(echo "$output" | grep -x " *articles/.* transaction .* plun-")
+break3=$(echo "$output" | grep -x " *<https.*61234")
test -n "$break1" || wail "first break"
test -n "$break2" || wail "second break"
test -n "$break3" || wail "third break"
diff --git a/tmac/tests/an_adjust-link-text-correctly.sh
b/tmac/tests/an_adjust-link-text-correctly.sh
index da3359d56..b1221aee4 100755
--- a/tmac/tests/an_adjust-link-text-correctly.sh
+++ b/tmac/tests/an_adjust-link-text-correctly.sh
@@ -35,6 +35,6 @@ input='.TH foo 1 2022-11-08 "groff test suite"
output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -man -rU1)
echo "$output"
-echo "$output" | grep -q 'HP PCL/PJL Reference:.*Reference Manu-'
+echo "$output" | grep -q 'HP PCL/PJL Reference:.*Reference Manual'
# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
b/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
index c5aee64de..fb2d8986d 100755
--- a/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
+++ b/tmac/tests/an_link-macros-work-in-paragraph-tags.sh
@@ -42,14 +42,15 @@ uflag=-rU0
output=$(printf "%s" "$input" \
| "$groff" -bww -Tascii -P-cbou $uflag -man)
+echo "$output"
echo "checking for paragraph tag on line by itself ($uflag)" >&2
-echo "$output" | grep -qx ' Roff\.js' || wail # 7 spaces
+echo "$output" | grep -qx ' Roff\.js' || wail # 5 spaces
echo "checking for presence of typeset URI ($uflag)" >&2
echo "$output" \
- | grep -q '^ <https://github\.com/Alhadis/Roff\.js/>' \
- || wail # 14 spaces
+ | grep -q '^ <https://github\.com/Alhadis/Roff\.js/>' \
+ || wail # 12 spaces
output=$(printf "%s" "$input" \
| "$groff" -bww -Tascii -P-cbou -rU0 -rLL=130n -man)
@@ -65,7 +66,7 @@ output=$(printf "%s" "$input" \
| "$groff" -bww -Tutf8 -P-cbou $uflag -man)
echo "checking for paragraph tag on line by itself ($uflag)" >&2
-echo "$output" | grep -qx ' Roff\.js' || wail # 7 spaces
+echo "$output" | grep -qx ' Roff\.js' || wail # 5 spaces
# Hyperlinking paragraph tags was not supported in groff 1.22.4 and
# still isn't.
diff --git a/tmac/tests/an_use-input-traps-correctly.sh
b/tmac/tests/an_use-input-traps-correctly.sh
index 4ad76e64d..9704cbb90 100755
--- a/tmac/tests/an_use-input-traps-correctly.sh
+++ b/tmac/tests/an_use-input-traps-correctly.sh
@@ -106,7 +106,7 @@ input=".TH foo 1 2022-06-07 \"groff test suite\"
output=$(printf "%s\n" "$input" | "$groff" -man -Tascii -P-cbou 2>&1)
echo "checking that TP macro uses correct input trap 'itc'" >&2
-echo "$output" | grep -Fqx ' --bar[=baz]' || wail # 7 spaces
+echo "$output" | grep -Fqx ' --bar[=baz]' || wail # 5 spaces
test -z "$fail"
diff --git a/tmac/tests/andoc_flush-between-packages.sh
b/tmac/tests/andoc_flush-between-packages.sh
index 6b24f840f..853a010ff 100755
--- a/tmac/tests/andoc_flush-between-packages.sh
+++ b/tmac/tests/andoc_flush-between-packages.sh
@@ -26,7 +26,7 @@ groff="${abs_top_builddir:-.}/test-groff"
# flushed, and page footers written, before proceeding to the next
# document. Check going from man(7) to mdoc(7) documents and back.
-EXAMPLE=\
+input=\
'.TH man\-flush\-test 7 2020-10-11 "groff test page 1"
.SH Name
man\-flush-test \- a sanity test for groff_man(7)
@@ -49,22 +49,23 @@ man\-flush-test2 \- a second sanity test for groff_man(7)
This supernumerary loquacious sentence should end up with a
partially-collected output line.'
-OUTPUT=$(printf "%s\n" "$EXAMPLE" | "$groff" -Tascii -P-cbou -mandoc)
+output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mandoc)
+echo "$output"
FAIL=
# Strip blank lines from the output first; all we care about for this
# test is the presence, adjacency, and ordering of non-blank lines.
-if [ -z "$(echo "$OUTPUT" \
+if [ -z "$(echo "$output" \
| sed '/^$/d' \
- | sed -n '/collected/{N;/test page 1/p;}')" ]
+ | sed -n '/lected output line/{N;/test page 1/p;}')" ]
then
FAIL=yes
echo "man to mdoc transition failed" >&2
fi
-if [ -z "$(echo "$OUTPUT" \
+if [ -z "$(echo "$output" \
| sed '/^$/d' \
| sed -n '/partially-collected/{N;/test page 2/p;}')" ]
then
diff --git a/tmac/tests/doc_Mt-works.sh b/tmac/tests/doc_Mt-works.sh
index d7790844d..18d804849 100755
--- a/tmac/tests/doc_Mt-works.sh
+++ b/tmac/tests/doc_Mt-works.sh
@@ -26,8 +26,11 @@ set -e
# Ensure .Mt renders correctly.
input='.Dd 2021-02-10
-.Dt mandoc 1
+.Dt foo 1
.Os groff test suite
+.Sh Name
+.Nm foo
+.Nd frobnicate a bar
.Sh Authors
.An -nosplit
The
@@ -38,6 +41,7 @@ and is maintained by
.An Ingo Schwarze Aq Mt schwarze@openbsd.org .'
output=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
echo "$output" \
| grep -Fq 'written by Kristaps Dzonsons <kristaps@bsd.lv>'
diff --git a/tmac/tests/doc_indents-correctly.sh
b/tmac/tests/doc_indents-correctly.sh
index 216e9c242..f7505f599 100755
--- a/tmac/tests/doc_indents-correctly.sh
+++ b/tmac/tests/doc_indents-correctly.sh
@@ -37,6 +37,8 @@ Discussion should be indented as ordinary paragraph.
Further discussion should be indented as ordinary paragraph.'
output=$(printf "%s\n" "$input" | "$groff" -Tascii -P-cbou -mdoc)
+echo "$output"
+
fail=
# Verify that default `Sh` indentation is zero.
@@ -53,8 +55,8 @@ then
fi
# Verify that paragraph indentation after section heading is correct.
-# 7 spaces in string literal.
-if ! echo "$output" | grep -Eq '^ Discussion should be indented'
+# 5 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ Discussion should be indented'
then
fail=yes
echo "'Pp' indentation after 'Sh' check failed" >&2
@@ -76,8 +78,8 @@ then
fi
# Verify that paragraph indentation after subsection heading is correct.
-# 7 spaces in string literal.
-if ! echo "$output" | grep -Eq '^ Further discussion should be'
+# 5 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ Further discussion should be'
then
fail=yes
echo "'Pp' indentation after 'Ss' check failed" >&2
diff --git a/tmac/tests/doc_synopsis_is_not_adjusted.sh
b/tmac/tests/doc_synopsis_is_not_adjusted.sh
index e5ddde6ea..70d3002e5 100755
--- a/tmac/tests/doc_synopsis_is_not_adjusted.sh
+++ b/tmac/tests/doc_synopsis_is_not_adjusted.sh
@@ -43,7 +43,7 @@ to within a granularity of
output=$(echo "$input" | "$groff" -Tascii -mdoc -P-cbou)
echo "$output"
-str=' {7}timerdday\(struct-timespec \*earliest, struct-timespec \*latest,'
+str=' {5}timerdday\(struct-timespec \*earliest, struct-timespec \*latest,'
echo "$output" | grep -Eqx "$str"
# vim:set ai et sw=4 ts=4 tw=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/03: [man,mdoc]: Make base paragraph indent 5n (1/2).,
G. Branden Robinson <=