gbranden pushed a commit to branch master
in repository groff.
commit 792fb6634177db3c5ed87c64729abc93dda9a3e5
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Feb 21 22:05:59 2024 -0600
[man]: Fix PDF hyperlinks when no link text.
* tmac/an.tmac (an*end-hyperlink): Fix bug: when no link text was
supplied, the fallback link text (the hyperlink itself) was not
appearing in PDF output. This bug was masked by another: the "no link
text supplied" branch was never being taken because the wrong
diversion dimension register was being tested. Test register `dl`
instead of `dn` and annotate the reasoning. Emit the trailing text in
two places in the logic, since the `pdfhref` macro takes over this
function with its `-A` parameter (which we now use), but wasn't
designed to accommodate the use case where we start the mark with one
call and close it with another, which we use for the "no link text
supplied" case.
---
ChangeLog | 14 ++++++++++++++
tmac/an.tmac | 11 +++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8896335af..9b49cc27f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-02-21 G. Branden Robinson <[email protected]>
+
+ * tmac/an.tmac (an*end-hyperlink): Fix bug: when no link text
+ was supplied, the fallback link text (the hyperlink itself) was
+ not appearing in PDF output. This bug was masked by another:
+ the "no link text supplied" branch was never being taken because
+ the wrong diversion dimension register was being tested. Test
+ register `dl` instead of `dn` and annotate the reasoning. Emit
+ the trailing text in two places in the logic, since the
+ `pdfhref` macro takes over this function with its `-A` parameter
+ {which we now use}, but wasn't designed to accommodate the use
+ case where we start the mark with one call and close it with
+ another, which we use for the "no link text supplied" case.
+
2024-02-21 G. Branden Robinson <[email protected]>
* tmac/tests/an_UR-works.sh: Add tests of PDF output, using
diff --git a/tmac/an.tmac b/tmac/an.tmac
index bc521b1a3..06b53b8aa 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -1159,8 +1159,8 @@ contains unsupported escape sequence
. di
. ev
. nr an*is-in-link-text-diversion 0
-. \" Was any link text present?
-. ie \\n[dn] \{\
+. \" If the diversion width is zero, assume there was link text.
+. ie \\n[dl] \{\
. if '\*[.T]'html' \
. nop \X'html:<a href="\\*[an*hyperlink]">'\c
. if '\*[.T]'pdf' \{\
@@ -1178,6 +1178,7 @@ contains unsupported escape sequence
. if \\n[an*is-output-terminal] \
. nop \X'tty: link'\c
. if '\*[.T]'pdf' \X'pdf: markend'\m[default]\c
+. nop \&\\*[an*trailing-text]\"
. \}
. \" If there was no link text, format URI as its own link text. We
. \" don't add angle brackets here.
@@ -1186,12 +1187,14 @@ contains unsupported escape sequence
. nop \X'html:<a href="\\*[an*hyperlink]">\
\\*[an*visible-hyperlink]</a>'\c
. if '\*[.T]'pdf' \
-. pdfhref W -D \\*[an*hyperlink] -- \\*[an*visible-hyperlink]\c
+. pdfhref W -D \\*[an*hyperlink] -A "\\*[an*trailing-text]" \
+-- \\*[an*visible-hyperlink]\c
. if \\n[an*is-output-terminal] \
. nop \X'tty: link \\*[an*hyperlink]'\
\\*[an*visible-hyperlink]\X'tty: link'\c
+. if !'\*[.T]'pdf' \
+. nop \&\\*[an*trailing-text]\"
. \}
-. nop \&\\*[an*trailing-text]\"
. \}
. \" If not hyperlinking, format URI in angle brackets. There was no
. \" diversion, so the link text has already been formatted normally.
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit