[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 12/14: [man,mdoc]: Slightly refactor (HTML detection).
|
From: |
G. Branden Robinson |
|
Subject: |
[groff] 12/14: [man,mdoc]: Slightly refactor (HTML detection). |
|
Date: |
Sun, 28 Jan 2024 19:55:05 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 983853cf234d236c0a5d0e7e03cd6e2d96491427
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Jan 28 15:50:14 2024 -0600
[man,mdoc]: Slightly refactor (HTML detection).
* tmac/an.tmac:
* tmac/doc.tmac: Slightly refactor. Make the `an*is-output-html` and
`doc-is-output-html` registers the sole determinant (within each
package) of behavior tailed for HTML output. Annotate why we use each
instead of testing `.T` string.
---
ChangeLog | 14 ++++++++++++++
tmac/an.tmac | 23 ++++++++++++-----------
tmac/doc.tmac | 14 ++++++++------
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 023a05cc3..8ebc8ac0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-01-28 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * tmac/an.tmac:
+ * tmac/doc.tmac: Slightly refactor. Make the
+ `an*is-output-html` and `doc-is-output-html` registers the
+ {nearly} sole determinant (within each package) of behavior
+ tailed for HTML output. Annotate why we use each instead of
+ testing `.T` string.
+
+ * tmac/an.tmac (an*end-hyperlink, MR): Apply exceptions to the
+ above rule when explicitly issuing device control escape
+ sequences to embed HTML elements; only grohtml(1) can interpret
+ these, not grops(1) when executed by pre-grohtml(1).
+
2024-01-28 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/tests/doc_Lk-works.sh: Add unit test.
diff --git a/tmac/an.tmac b/tmac/an.tmac
index 3bb60087a..78f217bfa 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -1145,7 +1145,7 @@ contains unsupported escape sequence
.
. \" Was any link text present?
. ie \\n[dn] \{\
-. if \\n[an*is-output-html] \
+. if '\*[.T]'html' \
. nop \X^html:<a href="\\*[an*prefix]\\*[an*hyperlink]">^\c
. if '\*[.T]'pdf' \{\
. pdfhref W -D \\*[an*prefix]\\*[an*hyperlink] -- "|"
@@ -1156,7 +1156,7 @@ contains unsupported escape sequence
. chop an*link-text-div
. an*link-text-div
\c\" XXX: If we .nop this, HTML output is corrupted (Savannah #63470).
-. if \\n[an*is-output-html] \
+. if '\*[.T]'html' \
. nop \X^html:</a>^\c
. if \\n[an*is-output-terminal] \
. nop \X^tty: link^\c
@@ -1166,7 +1166,7 @@ contains unsupported escape sequence
. \" If there was no link text, format URI as its own link text. We
. \" don't add angle brackets here.
. el \{\
-. if \\n[an*is-output-html] \
+. if '\*[.T]'html' \
. nop \X^html:<a href="\\*[an*prefix]\\*[an*hyperlink]">\
\\*[an*hyperlink]</a>^\c
. if '\*[.T]'pdf' \
@@ -1244,14 +1244,14 @@ contains unsupported escape sequence
. ds an*url x-man-doc://\\$2/\\$1\" ManOpen (Mac OS X pre-2005)
. nh
. if \\n[an*do-hyperlink] \{\
-. if \\n[an*is-output-html] \
+. if '\*[.T]'html' \
. nop \X^html:<a href="\\*[an*url]">^\c
. if \\n[an*is-output-terminal] \
. nop \X^tty: link \\*[an*url]^\c
. \}
. nop \&\\*[an-lic]\f[\\*[MF]]\\$1\\*[an-ic]\f[R](\\$2)\c
. if \\n[an*do-hyperlink] \{\
-. if \\n[an*is-output-html] \
+. if '\*[.T]'html' \
. nop \X^html:</a>^\c
. if \\n[an*is-output-terminal] \
. nop \X^tty: link^\c
@@ -1344,8 +1344,13 @@ contains unsupported escape sequence
.\" page.
.nr an*need-titles-reset 0
.
+.\" We don't have to worry about "xhtml" (it's mapped to "html"), but we
+.\" do need to account for pre-grohtml(1)'s use of "groff -Tps".
.nr an*is-output-html 0
.if '\*[.T]'html' .nr an*is-output-html 1
+.if r ps4html .nr an*is-output-html 1
+.
+.\" For most purposes, we treat the nroff devices equivalently.
.nr an*is-output-terminal 0
.if '\*(.T'ascii' .nr an*is-output-terminal 1
.if '\*(.T'cp1047' .nr an*is-output-terminal 1
@@ -1404,8 +1409,7 @@ contains unsupported escape sequence
.\"
.\" We must use consecutive page numbers when using PostScript to
.\" generate HTML images; we must not reset the page number at the
-.\" beginning of each document (the 'ps4html' register is automatically
-.\" added to the command line by the pre-HTML preprocessor).
+.\" beginning of each document.
.ie !r C \
. nr C 0
.el \
@@ -1416,8 +1420,6 @@ contains unsupported escape sequence
. \}
.if \n[an*is-output-html] \
. nr C 1
-.if r ps4html \
-. nr C 1
.
.\" diagnostics desired for man page style problems
.if !r CHECKSTYLE \
@@ -1536,7 +1538,7 @@ contains unsupported escape sequence
.\" and whose state is shared with mdoc (and andoc.tmac, if necessary).
.\"
.\" Also, we can't use the `P` register with grohtml at all.
-.ie r ps4html \{\
+.ie \n[an*is-output-html] \{\
. if r P \{\
. tm \*[an]: ignoring starting page number in HTML output
. rr P
@@ -1640,7 +1642,6 @@ contains unsupported escape sequence
.\" If rendering HTML, suppress headers and footers.
.nr an-suppress-header-and-footer 0
.if \n[an*is-output-html] .nr an-suppress-header-and-footer 1
-.if r ps4html .nr an-suppress-header-and-footer 1
.
.cp \n[*groff_an_tmac_C]
.do rr *groff_an_tmac_C
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index c10eb752b..4c500ff4f 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -63,8 +63,13 @@
.
.\" Handle most rendering options.
.
+.\" We don't have to worry about "xhtml" (it's mapped to "html"), but we
+.\" do need to account for pre-grohtml(1)'s use of "groff -Tps".
.nr doc-is-output-html 0
-.if '\*[.T]'html' .nr doc-is-output-html 1
+.if '\*[.T]'html' \
+. nr doc-is-output-html 1
+.if r ps4html \
+. nr doc-is-output-html 1
.
.\" Use -dAD to set the adjustment mode for ordinary body text.
.if !d AD \
@@ -74,8 +79,7 @@
.\"
.\" We must use consecutive page numbers when using PostScript to
.\" generate HTML images; we must not reset the page number at the
-.\" beginning of each document (the 'ps4html' register is automatically
-.\" added to the command line by the pre-HTML preprocessor).
+.\" beginning of each document.
.ie !r C \
. nr C 0
.el \
@@ -86,8 +90,6 @@
. \}
.if \n[doc-is-output-html] \
. nr C 1
-.if r ps4html \
-. nr C 1
.
.\" Use -rCS=1 to force capitalization of section headings.
.if !r CS .nr CS 0
@@ -217,7 +219,7 @@
.\" and whose state is shared with man (and andoc.tmac, if necessary).
.\"
.\" Also, we can't use the `P` register with grohtml at all.
-.ie r ps4html \{\
+.ie \n[doc-is-output-html] \{\
. if r P \{\
. tm mdoc: ignoring starting page number in HTML output
. rr P
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 12/14: [man,mdoc]: Slightly refactor (HTML detection).,
G. Branden Robinson <=