[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 35/39: [mdoc]: Support `IN` register.
From: |
G. Branden Robinson |
Subject: |
[groff] 35/39: [mdoc]: Support `IN` register. |
Date: |
Sat, 29 Oct 2022 15:00:00 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 2134257877b8da28b6d225d99a1c6d81592d9043
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Oct 29 12:09:26 2022 -0500
[mdoc]: Support `IN` register.
* tmac/doc.tmac: Recognize `IN` register if set on command line and use
groff man(7)-compatible defaults if it is not.
* tmac/mdoc/doc-common (Sh): Use this register instead of
`doc-paragraph-indentation`.
* tmac/mdoc/doc-ditroff:
* tmac/mdoc/doc-nroff: Stop setting pargraph indentation defaults here.
* tmac/groff_mdoc.7.man (Formatting with groff, troff, and nroff):
Document it.
* NEWS: Update item.
* tmac/tests/doc_Mt-works.sh:
* tmac/tests/doc_indents-correctly.sh: Update test expectations.
Fixes part of <https://savannah.gnu.org/bugs/?62926>.
---
ChangeLog | 21 +++++++++++++++++++++
NEWS | 4 ++--
tmac/doc.tmac | 9 ++++++++-
tmac/groff_mdoc.7.man | 10 +++++++++-
tmac/mdoc/doc-common | 2 +-
tmac/mdoc/doc-ditroff | 1 -
tmac/mdoc/doc-nroff | 1 -
tmac/tests/doc_Mt-works.sh | 11 ++++++-----
tmac/tests/doc_indents-correctly.sh | 8 ++++----
9 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 44da47956..2060a1a7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2022-10-29 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [mdoc]: Support `IN` register to configure paragraph
+ indentation.
+
+ * tmac/doc.tmac: Recognize `IN` register if set on command line
+ and use groff man(7)-compatible defaults if it is not.
+ * tmac/mdoc/doc-common (Sh): Use this register instead of
+ `doc-paragraph-indentation`.
+ * tmac/mdoc/doc-ditroff:
+ * tmac/mdoc/doc-nroff: Stop setting pargraph indentation
+ defaults here.
+ * tmac/groff_mdoc.7.man (Formatting with groff, troff, and
+ nroff): Document it.
+ * NEWS: Update item.
+
+ * tmac/tests/doc_Mt-works.sh:
+ * tmac/tests/doc_indents-correctly.sh: Update test expectations.
+
+ Fixes part of <https://savannah.gnu.org/bugs/?62926>.
+
2022-10-29 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/mdoc/doc-common (Sh): Fix code style nit. Set paragraph
diff --git a/NEWS b/NEWS
index ed9b4d9df..8e7f1f779 100644
--- a/NEWS
+++ b/NEWS
@@ -304,8 +304,8 @@ o The groff_man(7) man page documenting the groff
implementation of the
material supplemented with explanations, examples, and advice for the
reader who is not an expert in *roff systems or in writing man pages.
-o The doc (mdoc) macro package now honors the `C` and `HY` registers as
- the an (man) package does.
+o The doc (mdoc) macro package now honors the `C`, `HY`, and `IN`
+ registers as the an (man) package does.
o The e (me) macro package has changed its support for output line
numbering with the `n1` and `n2` macros to resolve several bugs in the
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index dabef5371..0894af9d0 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -116,7 +116,14 @@
.\" andoc.tmac and man(1); see \n[doc-hyphen-flags] in doc-common.
.if !r HY .nr HY 1
.
-.\" TODO: Implement IN register.
+.\" 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
+.\}
.
.\" LL and LT registers are handled by the doc-setup-page-layout macro.
.
diff --git a/tmac/groff_mdoc.7.man b/tmac/groff_mdoc.7.man
index 8218ea3fa..8988c079c 100644
--- a/tmac/groff_mdoc.7.man
+++ b/tmac/groff_mdoc.7.man
@@ -4668,6 +4668,15 @@ devices.
.
.
.Pp
+The paragraph indentation amount can be changed by setting the register
+.Ql \&IN .
+.
+.Dl groff \-Tutf8 \-rIN=5n \-mdoc foo.man | less \-R
+.
+The default is 7.2 ens on typesetters and 7 ens on terminals.
+.
+.
+.Pp
The line and title length can be changed by setting the registers
.Ql LL
and
@@ -4713,7 +4722,6 @@ and
.\" mis-handles them. Why this is not true of AD, cR, D, HF, HY, P, SN,
.\" or X is a mystery.
.Ql \&FT ,
-.Ql \&IN ,
.Ql P ,
.Ql SN ,
and
diff --git a/tmac/mdoc/doc-common b/tmac/mdoc/doc-common
index 4ce95c73b..d52983f3e 100644
--- a/tmac/mdoc/doc-common
+++ b/tmac/mdoc/doc-common
@@ -1440,7 +1440,7 @@
. if t \
. ss \n[doc-reg-Sh] \n[doc-reg-Sh1]
.
-. in \n[doc-paragraph-indentation]u
+. in \n[IN]u
. ns
.
. doc-check-depth
diff --git a/tmac/mdoc/doc-ditroff b/tmac/mdoc/doc-ditroff
index 463c57716..fa93fb4de 100644
--- a/tmac/mdoc/doc-ditroff
+++ b/tmac/mdoc/doc-ditroff
@@ -88,7 +88,6 @@
.tr *\[**]
.
.\" miscellaneous
-.nr doc-paragraph-indentation (\w'\f[CR],'u * 5u)
.nr doc-paragraph-space .4v
.
.nr doc-digit-width \w'\0'u
diff --git a/tmac/mdoc/doc-nroff b/tmac/mdoc/doc-nroff
index f301096a4..9649a194c 100644
--- a/tmac/mdoc/doc-nroff
+++ b/tmac/mdoc/doc-nroff
@@ -78,7 +78,6 @@
.ds doc-right-bracket \f[R]]\f[]
.
.\" miscellaneous
-.nr doc-paragraph-indentation .5i
.nr doc-paragraph-space 1v
.
.nr doc-digit-width \w'\0\0'u
diff --git a/tmac/tests/doc_Mt-works.sh b/tmac/tests/doc_Mt-works.sh
index a5c156302..d7790844d 100755
--- a/tmac/tests/doc_Mt-works.sh
+++ b/tmac/tests/doc_Mt-works.sh
@@ -25,8 +25,7 @@ set -e
#
# Ensure .Mt renders correctly.
-DOCUMENT=\
-'.Dd 2021-02-10
+input='.Dd 2021-02-10
.Dt mandoc 1
.Os groff test suite
.Sh Authors
@@ -38,10 +37,12 @@ utility was written by
and is maintained by
.An Ingo Schwarze Aq Mt schwarze@openbsd.org .'
-echo "$DOCUMENT" | "$groff" -Tascii -P-cbou -mdoc \
- | grep -Fq 'written by Kristaps Dzonsons <kristaps@bsd.lv> and'
+output=$(echo "$input" | "$groff" -Tascii -P-cbou -mdoc)
-echo "$DOCUMENT" | "$groff" -Tascii -P-cbou -mdoc \
+echo "$output" \
+ | grep -Fq 'written by Kristaps Dzonsons <kristaps@bsd.lv>'
+
+echo "$output" \
| grep -Fq 'is maintained by Ingo Schwarze <schwarze@openbsd.org>.'
# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tests/doc_indents-correctly.sh
b/tmac/tests/doc_indents-correctly.sh
index 7f35e8505..216e9c242 100755
--- a/tmac/tests/doc_indents-correctly.sh
+++ b/tmac/tests/doc_indents-correctly.sh
@@ -53,8 +53,8 @@ then
fi
# Verify that paragraph indentation after section heading is correct.
-# 5 spaces in string literal.
-if ! echo "$output" | grep -Eq '^ Discussion should be indented'
+# 7 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 +76,8 @@ then
fi
# Verify that paragraph indentation after subsection heading is correct.
-# 5 spaces in string literal.
-if ! echo "$output" | grep -Eq '^ Further discussion should be'
+# 7 spaces in string literal.
+if ! echo "$output" | grep -Eq '^ Further discussion should be'
then
fail=yes
echo "'Pp' indentation after 'Ss' check failed" >&2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 35/39: [mdoc]: Support `IN` register.,
G. Branden Robinson <=