[Home]WikiPatches/WikiTOCDivTag

UseModWiki | WikiPatches | RecentChanges | Preferences

This simple patch includes separate div for TOC (Table of Content). Otherwise it's under wikitext div for TOC.

See also WikiPatches/DivTags.

Patch 1

As nested div with wikitext

 sub WikiToHTML {
 ...
   while (@HeadingNumbers) {
     pop @HeadingNumbers;
     $TableOfContents .= "</dd></dl>\n\n";
   }
   - $pageText =~ s/<toc>/$TableOfContents/gi;
   + $IniToc =  '<div class=wikitoc>';
   + $EndToc =  '</div>'; 
   + $pageText =~ s/<toc>/$IniToc$TableOfContents$EndToc/gi;
   if ($LateRules ne '') {
     $pageText = &EvalLocalRules($LateRules, $pageText, 0);
   }
 ...

Patch 2

As separate div with wikitext:

sub BrowsePage {
...
$revision, $newText);
    $fullHtml .= "<hr class=wikilinediff>\n";
  }
  - $fullHtml .= '<div class=wikitext>';
  $fullHtml .= &WikiToHTML($Text{'text'});
  $fullHtml .= '</div>';
...

sub WikiToHTML {
...
  while (@HeadingNumbers) {
    pop @HeadingNumbers;
    $TableOfContents .= "</dd></dl>\n\n";
  }
  - $pageText =~ s/<toc>/$TableOfContents/gi;
  + $IniToc =  '<div class=wikitoc>';
  + $EndToc =  '</div><div class=wikitext>';
  + $pageText =~ s/<toc>/$IniToc$TableOfContents$EndToc/gi;
  if ($LateRules ne '') {
    $pageText = &EvalLocalRules($LateRules, $pageText, 0);
   }
  + if  (!$TableOfContents ) { 
    + return '<div class=wikitext>'.&RestoreSavedText($pageText);
  + } else {      
  return &RestoreSavedText($pageText);
  + }
}


sub DoEdit {
...
    print "<h2>", T('Preview only, not yet saved'), "</h2>\n";
    print '</div>';
    + print '</div>'; # closed div wikitext if WikiPatches/WikiTOCDivTag applied
  }
  print $q->endform;
  if (!&GetParam('embed', $EmbedWiki)) {
    print '<div class=wikifooter>';
 ...

In both pacths:

<tt> # Other global variables:</tt>
<pre>
 use vars qw(
 ...
 $IniToc $EndToc
 ...

I prefer the second one. --JuanmaMP


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 16, 2009 8:55 pm by JuanmaMP (diff)
Search: