]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/toc.pm
web commit by http://jeremie.koenig.myopenid.com/
[git.ikiwiki.info.git] / IkiWiki / Plugin / toc.pm
index 797bfc6bd526b7489e98046dd2ce752d4f85a0cd..070c07b0e96093b4c82c3bb9e6c8751dcb7ed414 100644 (file)
@@ -17,13 +17,20 @@ my %tocpages;
 sub preprocess (@) { #{{{
        my %params=@_;
 
-       $params{levels}=1 unless exists $params{levels};
+       if ($params{page} eq $params{destpage}) {
+               $params{levels}=1 unless exists $params{levels};
 
-       # It's too early to generate the toc here, so just record the
-       # info.
-       $tocpages{$params{destpage}}=\%params;
+               # It's too early to generate the toc here, so just record the
+               # info.
+               $tocpages{$params{destpage}}=\%params;
 
-       return "\n<div class=\"toc\"></div>\n";
+               return "\n<div class=\"toc\"></div>\n";
+       }
+       else {
+               # Don't generate toc in an inlined page, doesn't work
+               # right.
+               return "";
+       }
 } # }}}
 
 sub format (@) { #{{{
@@ -47,7 +54,7 @@ sub format (@) { #{{{
                if ($tagname =~ /^h(\d+)$/i) {
                        my $level=$1;
                        my $anchor="index".++$anchors{$level}."h$level";
-                       $page.="$text<a name=\"$anchor\" />";
+                       $page.="$text<a name=\"$anchor\"></a>";
        
                        # Take the first header level seen as the topmost level,
                        # even if there are higher levels seen later on.