An extended link function
•<citerefentry vendor=“xfree86”>
•  <refentrytitle>xdm</refentrytitle>
•  <manvolnum>1</manvolnum>
•</citerefentry>
•
•
•<![ %output.html; [                       <!-- HTML specific customisations -->
•      (define %refentry-xref-link% #t)
•
•      (define ($create-refentry-xref-link$ #!optional (n (current-node)))
•         (let* ((r (select-elements (children n) (normalize "refentrytitle")))
•                (m (select-elements (children n) (normalize "manvolnum")))
•                (v (attribute-string (normalize "vendor") n))
•                (u (string-append "http://www.FreeBSD.org/cgi/man.cgi?query="
•                        (data r) "&" "sektion=" (data m))))
•           (case v
•             (("xfree86") (string-append u "&" "manpath=XFree86+4.0.2"))
•             (("netbsd")  (string-append u "&" "manpath=NetBSD+1.5"))
•             (else u))))
•]]>
•
The FreeBSD man2html CGI also contains man pages from other groups, such as the XFree86 and NetBSD projects.  We wanted a way to refer to them as well in our documentation, and to have the links created, so we came up with this.

Essentially, we use the vendor attribute on the citerefentry element to select which group of man pages we’re interested in.  If we leave this blank then we want FreeBSD man pages.

The $create-refentry-xref-link$ function has been slightly updated.  First, it now collects the contents of the vendor attribute, if it exists, and puts it in the “v” variable.  It also creates the URL and puts it in the “u” variable, instead of returning it directly.  Finally, it looks at the value of “v”, and appends another CGI variable, “manpath” to the end of the URL, depending on the contents of the vendor string.

If $create-refentry-xref-link$ had taken just the name of the manpage and its section number, as I commented earlier, this change would have had a larger impact on all the customisation layers on top of this one.  But because the function was given the node as an argument, it could work everything else out for itself.