[Home]WikiPatches/ClassMarkup

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch adds the following Wiki markup:

 @@classname@text@@

where classname is the name of a formatting block type and "text" is the text to be included in the block. The text can include line breaks, and other wiki markup is processed within the block.

It's up to the site's CSS stylesheet to format the block; otherwise it will look like normal text.

Usage

Classes are defined in the %ClassMarkup? hash in the form:
 "classname" => "HTML"

Two placeholders are available in the HTML:

Class examples

I've implemented so far:
Class
declaration of class's position in the Object tree on the Unreal Wiki site
Array
code array. The numbering should start at zero but only Opera complies with this CSS so far
Code
code listing
Quote
quote from an external source
Zip
box, image and link to a zip file.

Patch

Variables

 # tarquin: classbox markup
 use vars qw( %ClassMarkup? );

This next section should go into config. The content of the hash is just an example.

 # temp settting
 %ClassMarkup? = ( 
  "class" => "<div class=\"class\">%text%</div>",
  "array" => "<div class=\"code\">%text%</div>",
  "code"  => "<div class=\"code\"><nowiki><pre>%text%</pre></nowiki></div>",
  "quote" => "<div class=\"quote\">%text%</div>",
  "zip"   => "<div class=\"zip\"><a href=\"%text%\">%text%</a></div>"
  );

WikiToHTML

Beneath the line:
  $pageText = &QuoteHtml?($pageText);
add the following block:

  #####################
  # tarq: classbox markup
  { 
    my $allkeys = join '|', map quotemeta, keys %ClassMarkup?;
    # $allkeys = join '|', map quotemeta, keys %ClassMarkup?;
    #$text =~ s[\@\@($allkeys)\@(.*)\@] [$ClassMarkup?{$1}]eg; 
    $pageText =~ s[\@\@($allkeys)\@(.*?)\@\@] {
      my $replacement = $ClassMarkup?{$1};
      my $blocktext = $2;
      $replacement =~ s[%text\%] [$blocktext]eg; 
      # process %nowiki% placeholder. 
      # This allows some classes to specify PRE themselves
      $replacement =~ s[%nowiki%] [\<nowiki\>]g;
      $replacement =~ s[%/nowiki%] [\<\/nowiki\>]g;
      $replacement
      }seg;
  }


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited March 28, 2002 9:48 am by Tarquin (diff)
Search: