Fixed a bug that caused broken links in some TOCs.
This change affects the code for generating links in HTML output.
It adds a new optional "toc.context" parameter to the href.target
template, and based on the value of that parameter, handles
link-generation in TOCs differently under a certain condition.
The gory details:
The code now checks to see if the output dir of any file being
linked to in a particular TOC is different from the output dir
the TOC is written to. If it is different, we do not call the
trim.common.uri.paths[1] template.
The reason is that, given the following case:
1. we are chunking into separate dirs
2. output for the TOC is written to current dir, but the file
being linked to is written to some subdir "foo".
For that case, links to that file in that TOC did not show
the correct path - they omitted the "foo".
The cause of that problem was that the trim.common.uri.paths
template was being called under all conditions. But it's
apparent that we don't want to call trim.common.uri.paths in
the case where a linked file is being written to a different
directory than the TOC that contains the link, because doing
so will cause a necessary (not redundant) directory-name
part of the link to get inadvertently trimmed, resulting in
a broken link to that file.
Thus, the conditional check was added to catch this case and to
handle it differently
[1] The purpose of the trim.common.uri.paths template is to
prevent cases where, if we didn't call it, we end up with
unnecessary, redundant directory names getting output; for
example, "foo/foo/refname.html".