[Home]WikiPatches/FreeLinksWithAnchors

UseModWiki | WikiPatches | RecentChanges | Preferences

This allows you to have non-WikiWord FreeLinks with anchors. The source for such links will look like [[Foo#My_Anchor]].

Patch against 1.0.4

diff --git a/usemod/wiki.pl b/usemod/wiki.pl
--- a/usemod/wiki.pl
+++ b/usemod/wiki.pl
@@ -62,7 +62,7 @@
   $OpenPageName @KeptList @IndexList $IndexInit $TableMode
   $q $Now $UserID $TimeZoneOffset $ScriptName $BrowseCode $OtherCode
   $AnchoredLinkPattern @HeadingNumbers $TableOfContents $QuotedFullUrl
-  $ConfigError $UploadPattern );
+  $ConfigError $UploadPattern $AnchoredFreeLinkPattern );
 
 # == Configuration =====================================================
 $DataDir     = "D:/web/ModWikiData/TestWiki"; # Main wiki directory
@@ -283,7 +283,6 @@
     $LinkPattern = "($LpA)";
   }
   $QDelim = '(?:"")?';     # Optional quote delimiter (not in output)
-  $AnchoredLinkPattern = $LinkPattern . '#(\\w+)' . $QDelim if $NamedAnchors;
   $LinkPattern .= $QDelim;
   # Inter-site convention: sites must start with uppercase letter
   # (Uppercase letter avoids confusion with URLs)
@@ -306,6 +305,13 @@
     $FreeLinkPattern = "((?:(?:$AnyLetter+)?\\/)?$AnyLetter+)";
   }
   $FreeLinkPattern .= $QDelim;
+  
+  if ($NamedAnchors)
+  {
+    $AnchoredLinkPattern = $LinkPattern . '#(\\w+)' . $QDelim;
+    $AnchoredFreeLinkPattern = $FreeLinkPattern . '#(\\w+)' . $QDelim;
+  }
+  
   # Url-style links are delimited by one of:
   #   1.  Whitespace                           (kept in output)
   #   2.  Left or right angle-bracket (< or >) (kept in output)
@@ -1691,6 +1697,8 @@
       # Also, consider that one could write [[Bad Page|Good Page]]?
       s/\[\[$FreeLinkPattern\|([^\]]+)\]\]/&StorePageOrEditLink($1, $2)/geo;
       s/\[\[$FreeLinkPattern\]\]/&StorePageOrEditLink($1, "")/geo;
+      s/\[\[$AnchoredFreeLinkPattern\]\]/&StoreRaw(&GetPageOrEditAnchoredLink($1,
+                                         $2, ""))/geo if $NamedAnchors;
     }
     if ($BracketText) {  # Links like [URL text of link]
       s/\[$UrlPattern\s+([^\]]+?)\]/&StoreBracketUrl($1, $2, $useImage)/geos;

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited September 12, 2008 4:48 am by 75-172-25-86.tukw.qwest.net (diff)
Search: