groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 10/15: [mdoc]: Handle "internal" `Xr` link targets.


From: G. Branden Robinson
Subject: [groff] 10/15: [mdoc]: Handle "internal" `Xr` link targets.
Date: Sun, 17 Mar 2024 17:59:38 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 4c59005ba0b7ca784f926921a8edbeb459dff61d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Mar 16 12:18:49 2024 -0500

    [mdoc]: Handle "internal" `Xr` link targets.
    
    * tmac/doc.tmac (Xr): When formatting PDF, automatically attempt lookups
      of `Xr` destinations as internal bookmark tags.  If lookup succeeds,
      link to the within-document destination rather than an "external" URL
      like "man:foobar(1)".
    
    For example, this enables "outbound" links from the groff_mdoc(7) page
    to the other ~60 documents collected in "groff-man-pages.pdf".
---
 ChangeLog     | 11 +++++++++++
 tmac/doc.tmac | 13 ++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a77eee43b..5f93ce7b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-03-16  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/doc.tmac (Xr): When formatting PDF, automatically attempt
+       lookups of `Xr` destinations as internal bookmark tags.  If
+       lookup succeeds, link to the within-document destination rather
+       than an "external" URL like "man:foobar(1)".
+
+       For example, this enables "outbound" links from the
+       groff_mdoc(7) page to the other ~60 documents collected in
+       "groff-man-pages.pdf".
+
 2024-03-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/mdoc/doc-common (Os): When formatting PDF, automatically
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index 9bb8ec012..e69a55393 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -4637,6 +4637,7 @@ arguments
 .\" NS   doc-macro-name
 .\" NS
 .\" NS local variables:
+.\" NS   doc-destination-bookmark-tag-Xr
 .\" NS   doc-has-section-Xr
 .\" NS   doc-lasttext-Xr
 .\" NS   doc-next-arg-ptr-Xr
@@ -4724,7 +4725,17 @@ arguments
 .    if (\n[doc*Xr-URL-format] = 4) \
 .      ds doc-target-uri-Xr \
          x-man-doc://\*[doc-target-section-Xr]/\*[doc-target-identifier-Xr]\"
-.    doc-begin-hyperlink-\*[.T] \*[doc-target-uri-Xr]
+.    ie '\*[.T]'pdf' \{\
+.      ds doc-destination-bookmark-tag-Xr \
+"\*[doc-target-identifier-Xr](\*[doc-target-section-Xr])
+.      pdf:lookup \*[doc-destination-bookmark-tag-Xr]
+.      ie !'\\*[pdf:lookup-result]'' \
+.        pdfhref L -S -D \*[doc-destination-bookmark-tag-Xr]
+.      el \
+.        doc-begin-hyperlink-\*[.T] \*[doc-target-uri-Xr]
+.    \}
+.    el \
+.      doc-begin-hyperlink-\*[.T] \*[doc-target-uri-Xr]
 .  \}
 .
 .  nr doc-curr-font \n[.f]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]