[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 05/08: [mdoc]: Add support for CS and CT registers.
From: |
G. Branden Robinson |
Subject: |
[groff] 05/08: [mdoc]: Add support for CS and CT registers. |
Date: |
Sat, 31 Oct 2020 23:48:22 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 9fa2aed4facae1c94cc339b891aca25c57074551
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Nov 1 12:45:23 2020 +1100
[mdoc]: Add support for CS and CT registers.
...just like in man(7), from a year ago.
* tmac/doc.tmac-u (doc-print-recursive): Call .stringup on each argument
if register doc-do-capitalize is true.
* tmac/mdoc/doc-common-u (Dt): Call .stringup on doc-document-title if
\n[CT] is true.
(Sh): Set doc-do-capitalize to value of \n[CS]. Set doc-do-capitalize
false before returning.
* tmac/mdoc/doc-ditroff-u:
* tmac/mdoc/doc-nroff-u: Set CS and CT registers to 0 (false) if the
user has not defined them.
* NEWS:
* tmac/groff_mdoc.7.man (Formatting with groff, troff, and nroff):
Document it.
* tmac/tests/doc-CS_works.sh:
* tmac/tests/doc-CT_works.sh: Test it.
* tmac/tmac.am (tmac_TESTS): Run tests.
---
ChangeLog | 22 ++++++++++++++++++++++
NEWS | 20 ++++++++++----------
tmac/doc.tmac-u | 2 ++
tmac/groff_mdoc.7.man | 20 ++++++++++++++++++++
tmac/mdoc/doc-common-u | 9 +++++++++
tmac/mdoc/doc-ditroff-u | 6 ++++++
tmac/mdoc/doc-nroff-u | 6 ++++++
7 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 42202c1..dc8aada 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2020-10-31 G. Branden Robinson <g.branden.robinson@gmail.com>
+ Add support for CS and CT registers to mdoc(7), just like in
+ man(7), from a year ago.
+
+ * tmac/doc.tmac-u (doc-print-recursive): Call .stringup on each
+ argument if register doc-do-capitalize is true.
+ * tmac/mdoc/doc-common-u (Dt): Call .stringup on
+ doc-document-title if \n[CT] is true.
+ (Sh): Set doc-do-capitalize to value of \n[CS]. Set
+ doc-do-capitalize false before returning.
+ * tmac/mdoc/doc-ditroff-u:
+ * tmac/mdoc/doc-nroff-u: Set CS and CT registers to 0 (false)
+ if the user has not defined them.
+
+ * tmac/groff_mdoc.7.man \
+ (Formatting with groff, troff, and nroff): Document it.
+
+ * tmac/tests/doc-CS_works.sh:
+ * tmac/tests/doc-CT_works.sh: Test it.
+ * tmac/tmac.am (tmac_TESTS): Run tests.
+
+2020-10-31 G. Branden Robinson <g.branden.robinson@gmail.com>
+
* src/roff/troff/input.cpp (do_overstrike, do_bracket,
do_name_test, do_expr_test, do_zero_width, do_width, do_special,
do_if_request, read_color_draw_note): Improve diagnostic
diff --git a/NEWS b/NEWS
index 35d7722..2e90b09 100644
--- a/NEWS
+++ b/NEWS
@@ -81,16 +81,16 @@ o The an (man) macro package supports a new AD string to
put the default
adjustment mode under user control. The default is 'b' (adjust lines
to both margins) as has been the Unix man practice since 1979.
-o The an (man) macro package supports new CS and CT number registers to
- control rendering of man page section headings and titles,
- respectively, in full capitals. These default off (with no visible
- effect on pages which already fully capitalize these strings in man
- page sources). The rationale is to encourage man page authors to
- preserve case distinction information in (or restore it to) their
- titles and section headings, while giving users (including system
- administrators, distributors, integrators, and maintainers of man(1)
- implementations) a way to view the rendered page elements in full
- capitals if desired.
+o The an (man) and doc (mdoc) macro packages support new CS and CT
+ registers to control rendering of man page section headings and titles
+ (seen in the page header), respectively, in full capitals. These
+ default off (with no visible effect on pages which already fully
+ capitalize these strings in man page sources). The rationale is to
+ encourage man page authors to preserve case distinction information in
+ (or restore it to) their titles and section headings, while giving
+ users (including system administrators, distributors, integrators, and
+ maintainers of man(1) implementations) a way to view the rendered page
+ elements in full capitals if desired.
o The an (man) macro package no longer honors an .ll request to set the
line length in nroff devices prior to processing a man page. This was
diff --git a/tmac/doc.tmac-u b/tmac/doc.tmac-u
index fcd042f..a5fd82d 100644
--- a/tmac/doc.tmac-u
+++ b/tmac/doc.tmac-u
@@ -479,6 +479,8 @@
. nr doc-reg-dpr1 \n[doc-type\n[doc-arg-ptr]]
. ds doc-str-dpr "\*[doc-arg\n[doc-arg-ptr]]
.
+. if \n[doc-do-capitalize] .stringup doc-str-dpr
+.
. ie (\n[doc-reg-dpr1] == 1) \{\
. nop \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]\c
. \*[doc-str-dpr]
diff --git a/tmac/groff_mdoc.7.man b/tmac/groff_mdoc.7.man
index 65d0468..bac1238 100644
--- a/tmac/groff_mdoc.7.man
+++ b/tmac/groff_mdoc.7.man
@@ -4181,6 +4181,26 @@ to zero while calling
resulting in multiple pages instead of a single, very long page:
.Pp
.Dl groff \-Tlatin1 \-rcR=0 \-mdoc foo.man > foo.txt
+.
+.
+.Pp
+Section headings
+(defined with
+.Ql .Sh )
+and page titles in headers
+(defined with
+.Ql .Dt )
+can be presented in full capitals by setting the registers
+.Ql CS
+and
+.Ql CT ,
+respectively,
+to 1.
+.
+These transformations are off by default because they discard case
+distinction information.
+.
+.
.Pp
For double-sided printing, set register
.Ql D
diff --git a/tmac/mdoc/doc-common-u b/tmac/mdoc/doc-common-u
index 1c83ff7..4aab7d0 100644
--- a/tmac/mdoc/doc-common-u
+++ b/tmac/mdoc/doc-common-u
@@ -354,6 +354,9 @@
. if !"\$1"" \
. ds doc-document-title "\$1
.
+. if \n[CT] \
+. stringup doc-document-title
+.
. if !"\$2"" \{\
. ds doc-section \$2
. ie \B\$2 \{\
@@ -1178,6 +1181,9 @@
.ds doc-section-authors Authors\"
.
.de Sh
+. \" Tell doc-print-recursive whether to force capitalization.
+. nr doc-do-capitalize \n[CS]
+.
. ie \n[doc-arg-limit] \{\
. \" we only allow 'Sh' within 'Sh'; it will change the font back to
. \" 'doc-Sh-font'
@@ -1282,6 +1288,9 @@
.
. doc-check-depth
. \}
+.
+. \" Don't let doc-print-recursive force caps on anything else.
+. nr doc-do-capitalize 0
..
.
.
diff --git a/tmac/mdoc/doc-ditroff-u b/tmac/mdoc/doc-ditroff-u
index 092ea8f..0e33cb9 100644
--- a/tmac/mdoc/doc-ditroff-u
+++ b/tmac/mdoc/doc-ditroff-u
@@ -39,6 +39,12 @@
.\" \*[AD] is recognized for groff_man(7) compatibility, but ignored.
.if !d AD .ds AD \" empty
.
+.\" Use -rCS=1 to force capitalization of section headings.
+.if !r CS .nr CS 0
+.
+.\" Use -rCT=1 to force capitalization of page titles in headers.
+.if !r CT .nr CT 0
+.
.\" use -rD=1 for double-sided printing
.if !r D .nr D 0
.
diff --git a/tmac/mdoc/doc-nroff-u b/tmac/mdoc/doc-nroff-u
index bd101c4..9d17fe4 100644
--- a/tmac/mdoc/doc-nroff-u
+++ b/tmac/mdoc/doc-nroff-u
@@ -39,6 +39,12 @@
.\" \*[AD] is recognized for groff_man(7) compatibility, but ignored.
.if !d AD .ds AD \" empty
.
+.\" Use -rCS=1 to force capitalization of section headings.
+.if !r CS .nr CS 0
+.
+.\" Use -rCT=1 to force capitalization of page titles in headers.
+.if !r CT .nr CT 0
+.
.\" use -rD=1 for double-sided printing
.if !r D .nr D 0
.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 05/08: [mdoc]: Add support for CS and CT registers.,
G. Branden Robinson <=