You are here: Foswiki>Tasks Web>Item11231 (17 Dec 2011, GeorgeClark)Edit Attach

Item11231: TOC + WikiWord = bad anchor

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Engine
Component: FoswikiRender
Branches: Release01x01 trunk
Reported By: JayenAshar
Waiting For:
Last Change By: GeorgeClark

WikiWord

The href anchor in the TOC has the exclamation mark ('!'), but the name anchor does not.

-- JayenAshar - 02 Nov 2011

Hrm, that seems to not work on my 1.1.3. Let me see if I can reproduce it on this site. Sorry.

-- JayenAshar - 02 Nov 2011

WIKIWORD

-- JayenAshar - 02 Nov 2011

WIKIWORD in the TOC above does not link properly.

Although I now realise that WIKIWORD shouldn't need an exclamation mark ('!') in front of it. Probably another bug in how I'm using the wikiWordRegex in my version of the MediaWiki conversion script.

-- JayenAshar - 02 Nov 2011

Jayen, WIKIWORD would auto-link as an acronym if the topic exists, but not generate a "missing link" questionmark. Acronyms are a bit different in that they only link when the topic exists. So there is a case where WIKIWORD might be needed.

Ah... I see what you mean. The headings both use exclamation point escape - !WikiWord and !ACRONYM The first heading generates an anchor and reference without exclamation point. The 2nd heading encodes the Exclamation point into the anchor reference in the toc, #A_33WIKIWORD but not into the anchor itself, which is simply #WIKIWORD.

Confirmed. But just for the ACRONYM case.

-- GeorgeClark - 03 Nov 2011

I think there is a simple fix. Anchor.pm filters out escaped WikiWords but not Abbreviations. The following seems to fix it for me.

diff --git a/core/lib/Foswiki/Render/Anchors.pm b/core/lib/Foswiki/Render/Anchors.pm
index 13a8723..504822c 100644
--- a/core/lib/Foswiki/Render/Anchors.pm
+++ b/core/lib/Foswiki/Render/Anchors.pm
@@ -152,7 +152,7 @@ sub make {
     $text =~ s/&#?[a-zA-Z0-9]+;//g;
 
     # remove escape from escaped wikiWords
-    $text =~ s/!($Foswiki::regex{wikiWordRegex})/$1/go;
+    $text =~ s/!($Foswiki::regex{wikiWordRegex}|$Foswiki::regex{abbrevRegex})/$1/go;
 
     # remove spaces
     $text =~ s/\s+/_/g;

-- GeorgeClark - 03 Nov 2011

Committed a fix to both 1.1 and trunk. So this topic should now work correctly on trunk.foswiki.org.

-- GeorgeClark - 03 Nov 2011

Sorry my explanation was so vague. Glad you understood it.

Is it worth making a autoLinkRegex for WikiWord|ABBREV and use that in a bunch of places?

-- JayenAshar - 03 Nov 2011
 

ItemTemplate edit

Summary TOC + WikiWord = bad anchor
ReportedBy JayenAshar
Codebase 1.1.4 beta2, 1.1.4 beta1, 1.1.3
SVN Range
AppliesTo Engine
Component FoswikiRender
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:ad3607bfe3f2 distro:ad038bf36f78
TargetRelease patch
ReleasedIn 1.1.4
CheckinsOnBranches Release01x01 trunk
trunkCheckins distro:ad3607bfe3f2
Release01x01Checkins distro:ad038bf36f78
Topic revision: r8 - 17 Dec 2011, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy