Priority: Normal
Current State: Closed
Released In: 1.0.10
Target Release: patch
Applies To: Engine
Component: Render.pm
Branches:
When a local anchor is used:
#AnchorName
and then later it is referred to like this [[#AnchorName][Click Here]]
Click Here
the rendered output prefixes the anchor with the web and topic names.
<a href="/Tasks/Item8556#AnchorName" class="foswikiCurrentTopicLink">Click Here</a>
Rather than (the desired):
<a href="#AnchorName" class="foswikiCurrentTopicLink">Click Here</a>
If the page is published to PDF with htmldoc, for example, the anchors will point back to the web site that generated the page rather to PDF anchors inside the published document.
In Render.pm:
sub _renderExistingWikiWord {
...snip...
my $currentTopic = '';
$currentTopic = 'foswikiCurrentTopicLink'
if ( ( $web eq $this->{session}->{webName} )
&& ( $topic eq $this->{session}->{topicName} ) );
my @attrs;
my $href = $this->{session}->getScriptUrl( 0, 'view', $web, $topic );
if ($anchor) {
$anchor = $this->makeAnchorName($anchor);
# Following modified by RCL to leave local anchors alone
$href = ($currentTopic eq 'foswikiCurrentTopicLink') ? "#$anchor" : "$href#$anchor";
}
--
RaymondLutz - 17 Feb 2010
The code change seems reasonable.
Even though
$href = $currentTopic ? "#$anchor" : "$href#$anchor";
could probably do it since currentTopic is only set if the topic is the current.
But then again. There is often one thing that breaks when you fix something else.
Often I have found myself placing links to the same topic in a topic with the purpose to ensure that when I later copy the text into an email, all links point back to the wiki and not to nowhere.
We need to think through if this does not not goof up other situations.
But the spec is correct. If the user has put only #AnchorName in a square bracket link the result should be just that.
--
KennethLavrsen - 18 Feb 2010
I tried the different combinations I was concerned about and I have no problems for the moment.
I remember 2-3 years ago in the old project that we had an issue related to anchors but I cannot remember what it was which is why I hesitate. But I think the code change is safe. I will try and run with it for a while and see.
--
KennethLavrsen - 18 Feb 2010
I have implemented a fix in both release branch and trunk
--
KennethLavrsen - 18 Mar 2010