This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Converting man page references to links
- To: docbook-apps at lists dot oasis-open dot org
- Subject: DOCBOOK-APPS: Converting man page references to links
- From: Nik Clayton <nik at nothing-going-on dot demon dot co dot uk>
- Date: Mon, 24 Jul 2000 19:36:01 +0100
- Organization: Nik at home, where there's nothing going on
Hi guys,
Like many projects, we have a CGI script that converts man pages to HTML
for handy viewing in a browser.
Since DocBook can mark up man page references, I've just crufted together
the following DSSSL to automate generating links. Given
<citerefentry>
<refentrytitle>ls</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
it outputs
<a href="http://www.FreeBSD.org/cgi/man.cgi?ls(1)">ls(1)</a>
(in conjunction with Norm's stylesheets.
------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------
<!-- Convert <citerefentry> into links to man.cgi -->
(element citerefentry
(let ((ref (select-elements (descendants (current-node))
(normalize "refentrytitle")))
(vol (select-elements (descendants (current-node))
(normalize "manvolnum"))))
(make element gi: "a"
attributes: (list (list "href" (string-append
"http://www.FreeBSD.org/cgi/man.cgi?"
(data (node-list-first ref))
"("
(data (node-list-first vol)) ")")))
(process-children))))
------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------
A few things:
1. There are probably more elegant ways to achieve this. Not being a
DSSSL expert by any stretch of the imagination I welcome improvements.
2. Who else has manpage CGIs like this? How can we go about making this
a more general function?
Ideally, I'd envisage something whereby you'd do something like
(define $mancgi-template$ "http://www.FreeBSD.org/man.cgi?%s(%d)")
and the procedure would fill in %s and %d in the template. Each of the
various documentation projects (with their own CGI script and calling
conventions) would then just redefine $mancgi-template$ as necessary.
Thoughts?
N
--
Internet connection, $19.95 a month. Computer, $799.95. Modem, $149.95.
Telephone line, $24.95 a month. Software, free. USENET transmission,
hundreds if not thousands of dollars. Thinking before posting, priceless.
Somethings in life you can't buy. For everything else, there's MasterCard.
-- Graham Reed, in the Scary Devil Monastery