# --------------------------------------------------------------------------- # Wiki Format tag # A Plugin for Movable Type # # Release 0.2 # August 18, 2002 # # From l.m.orchard # http://www.decafbad.com # --------------------------------------------------------------------------- # This software is provided as-is. # You may use it for commercial or personal use. # If you distribute it, please keep this notice intact. # # Copyright (c) 2002 l.m.orchard # --------------------------------------------------------------------------- use strict; use MT::Template::Context; use Text::WikiFormat; MT::Template::Context->add_container_tag(WikiFormat => \&WikiFormat); sub WikiFormat { my ($ctx, $args) = @_; ### Tag args, corresponding to Text::WikiFormat args my $remove_whitespace = defined($args->{remove_whitespace}) ? $args->{'remove_whitespace'} : 1; my $prefix = $args->{prefix}; my $extended = $args->{extended}; ### Build out any child tags. my $tokens = $ctx->stash('tokens'); my $builder = $ctx->stash('builder'); defined(my $raw = $builder->build($ctx, $tokens)) or return $ctx->error($builder->errstr); ### Remove whitespace before and after text. if ($remove_whitespace) { $raw =~ s/^(\s+)//; $raw =~ s/(\s+)$//; } my $out = Text::WikiFormat::format ( $raw, { }, { prefix => $prefix, extended => $extended, } ); return $out; }