[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 14/46: [man]: Support undocumented `mG` register.
From: |
G. Branden Robinson |
Subject: |
[groff] 14/46: [man]: Support undocumented `mG` register. |
Date: |
Wed, 7 Dec 2022 04:32:31 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit b7951b50439db6fea1e6af25bcb71c503bd6db4f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Dec 2 03:50:13 2022 -0600
[man]: Support undocumented `mG` register.
* tmac/an-ext.tmac: Support `mG` register: clear it to force the loading
of this file's macros even if they have an implementation in
tmac/an.tmac and the formatter claims groff compatibility. This is to
ease these macros' testing under groff and keep the implementations
here simple.
* tmac/an.tmac: Initialize `mG` register to 0 if not set on command
line.
("mG" roughly means "use groff-enhanced versions of extension macros".)
---
ChangeLog | 10 ++++++
tmac/an-ext.tmac | 9 ++++--
tmac/an-tmp.tmac | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tmac/an.tmac | 4 +++
4 files changed, 117 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 051e3abff..bd2f5e439 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-12-02 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * tmac/an-ext.tmac: Support `mG` register: clear it to force the
+ loading of this file's macros even if they have an
+ implementation in tmac/an.tmac and the formatter claims groff
+ compatibility. This is to ease these macros' testing under
+ groff and keep the implementations here simple.
+ * tmac/an.tmac: Initialize `mG` register to 1 if not set on
+ command line.
+
2022-12-02 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/an-ext.tmac: Initialize `mX` register.
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index 533ee0176..2487e2ab4 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -207,7 +207,7 @@
.
.\" Set a man page cross reference.
.\" .MR page-topic page-section [trailing-text]
-.if \n(.g .ig
+.if \n(.g-\n(mG \{\
.de MR
. nh
. ie \\n(.$=1 \
@@ -216,6 +216,7 @@
. IR \\$1 (\\$2)\\$3
. hy \\n(mJ
..
+.\}
.
.
.\" Continuation line for .TP header.
@@ -227,7 +228,7 @@
.
.
.\" Start example.
-.if \n(.g .ig
+.if \n(.g-\n(mG \{\
.de EX
. br
. if !\\n(mX \{\
@@ -239,10 +240,11 @@
. nr mX 1
. \}
..
+.\}
.
.
.\" End example.
-.if \n(.g .ig
+.if \n(.g-\n(mG \{\
.de EE
. br
. if \\n(mX \{\
@@ -252,6 +254,7 @@
. nr mX 0
. \}
..
+.\}
.
.
.\" Start display.
diff --git a/tmac/an-tmp.tmac b/tmac/an-tmp.tmac
new file mode 100644
index 000000000..1077f7e3a
--- /dev/null
+++ b/tmac/an-tmp.tmac
@@ -0,0 +1,97 @@
+.
+.
+.\" Check if we're using grohtml or grotty, and therefore support URIs.
+.nr mH 0
+.nr mY 0
+.nr mU 0
+.if \n(.g \{\
+. if '\*(.T'html' \
+. nr mH 1
+. if '\*(.T'ascii' \
+. nr mY 1
+. if '\*(.T'cp1047' \
+. nr mY 1
+. if '\*(.T'latin1' \
+. nr mY 1
+. if '\*(.T'utf8' \
+. nr mY 1
+. nr mU \n(mH+\n(mY
+.\}
+.
+.
+.\" Prepare link text for mail/web hyperlinks. `MT` and `UR` call this.
+.de mV
+. ds m1 \\$1\"
+. \" Save the indentation and line length. We want the diversion to
+. \" format as if it has an indentation of zero (that comes for free
+. \" when we switch environments), but we want the line length reduced
+. \" by the amount of indentation that obtains when we output it.
+. nr mK \\n(.l
+. nr mI \\n(.i
+. \" We can only hyperlink if we're not in a diversion.
+. nr mD 0
+. if '\\n(.z'' .nr mD 1
+. if \\n(mD&\\nU&\\n(mU \{\
+. \" Start diversion in a new environment.
+. do ev link-text-env
+. do di link-text-div
+. ll (\\n(mKu-\\n(mIu)
+. \}
+. rr mI
+. rr mK
+..
+.
+.
+.\" Emit hyperlink. The first argument prefixes a URI scheme and colon
+.\" (e.g., "mailto:") but since Web URLs generally supply their own,
+.\" it is not used for those (but must be present to keep the argument
+.\" count consistent). An optional second argument supplies trailing
+.\" punctuation after link text. `ME` and `UE` call this.
+.de mQ
+. ds mO mailto:\"
+. if !'\\$1'\\*(mO' \
+. ds mO \" empty
+.
+. ie \\n(mD&\\nU&\\n(mU \{\
+. br
+. di
+. ev
+.
+. \" Has there been at least one input line of hyperlinked text?
+. ie \\n(dn \{\
+. if \\n(mH \
+\X^html:<a href="\\*(mO\\*(m1">^\c
+. if \\n(mY \
+\X^tty: link \\*(mO\\*(m1^\c
+. \" Strip off the final newline of the diversion and emit it.
+. do chop link-text-div
+. do link-text-div
+\c
+. if \\n(mH \
+\X^html:</a>^\c
+. if \\n(mY \
+\X^tty: link^\c
+. \}
+. \" If there was no link text, format and link the URI.
+. el \{\
+. if \\n(mH \
+\X^html:<a href="\\*(mO\\*(m1">\\*(m1</a>^\c
+. if \\n(mY \
+\X^tty: link \\*(mO\\*(m1^\\*(m1\X^tty: link^\c
+. \}
+. do shift
+\&\\$*\"
+. \}
+. \" If no link support, format URI in angle brackets. (The link text
+. \" was already formatted normally by `mV`.)
+. el \{\
+. nh
+\\*(mL\\*(m1\\*(mR\\$2
+. do shift 2
+. ie \n(.g .if \\n(.$ \&\\$*\"
+. el .if \\n(.$>2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9\"
+. hy \\n(mJ
+. \}
+. rr mD
+. rm mO
+..
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 122d1db52..74397da21 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -1173,6 +1173,10 @@ contains unsupported escape sequence
. ftr CBI BI
.\}
.
+.\" undocumented register; unset to test an-ext.tmac extension macros
+.if !r mG \
+. nr mG 1
+.
.\" Load man macro extensions.
.mso an-ext.tmac
.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 14/46: [man]: Support undocumented `mG` register.,
G. Branden Robinson <=