|
|
|
The FreeBSD
manpage to HTML CGI script expects a query string with 2 parameters. The first, query, is the name of the man
page; in other words, the contents of the refentrytitle element. The second parameter, sektion (yes, with
that spelling, the author of the script is German) is equivalent to the
contents of the manvolnum element.
All we have to do is write a function that can turn these two pieces
of information in to the URL.
|
|
|
|
This is quite a
simple function to write. However,
I’ve made it a little more complex to try and be a bit more futureproof. It would be simple to write a function
that took two strings as arguments and pasted them in to the URL. However, suppose you then want to extend
this function to do something else (I’ll give an example of ‘something else’
later on). If the function needed any
more information to do its job you would have to not only rewrite this
function, but you would also need to rewrite the citerefentry code in
layer-2.dsl (which might cause problems for any other customisations built on
top of it).
|
|
|
|
So, instead,
this function takes a node as its argument (conceptually, you can think of
the node as being the current element that’s being processed). If no node is passed in then the function
works out what the current node is, and uses that instead.
|
|
|
|
The first line
of the function deals with the argument passing, and calls the node it’s
using “n”. Remember, we expect “n” to
correspond to the citerefentry element we’re currently dealing with.
|
|
|
|
We set up two
variables; “r” is the node (or element) that corresponds with the
refentrytitle that is a child of “n”.
Similarly, “m” corresponds to the manvolnum node.
|
|
|
|
Then all we do
is construct a string, using string-append.
You can see that the string is a combination of static strings, and
the contents of the “r” and “m” nodes, where the contents of a node are
extracted by the “data” function.
|
|
|
|
Simple eh?
|