Fix source forge bug 803693
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 16 Mar 2004 14:25:09 +0000 (14:25 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 16 Mar 2004 14:25:09 +0000 (14:25 +0000)
When a title is given in a == == headline, the html was incorectly generated as:
<a name="sectionname"></a><a class="internal">link</a>

It now generates:

<a class="internal" name="sectioname">link</a>

includes/Parser.php

index 5e5a7d9..39cbff5 100644 (file)
@@ -1289,13 +1289,22 @@ class Parser
                                $head[$c].=$sk->editSectionLink($c+1);
                        }
                        
-                       // Put it all together
                        
-                       $head[$c].="<h".$level.$matches[2][$c]
-                        ."<a name=\"".$anchor."\">"
-                        .$headline
-                        ."</a>"
-                        ."</h".$level.">";
+                       // the headline might have a link
+                       if(preg_match("/(.*)<a(.*)/",$headline, $headlinematches))
+                       { 
+                               // if so give an anchor name to the already existent link
+                               $headline = $headlinematches[1]
+                                           ."<a name=\"".$anchor."\" ".$headlinematches[2];
+                       } else {
+                               // else create an anchor link for the headline
+                               $headline = "<a name=\"".$anchor."\">"
+                                           .$headline
+                                           ."</a>";
+                       }
+                               
+                       // give headline the correct <h#> tag
+                       $head[$c].="<h".$level.$matches[2][$c] .$headline."</h".$level.">";
                        
                        // Add the edit section link