## This file is auto-generated (at 2003-03-21T08:02:45Z).
## Do not edit by hand!

=head1 NAME

SuikaWiki::Plugin::WikiConst --- SuikaWiki: constance
<IW:SuikaWiki:SuikaWiki>


=cut

package SuikaWiki::Plugin::WikiConst;
use strict;
our $VERSION = q(2003.0321.0802);



sub import {
    my $self = shift;
    $self->SuikaWiki::Plugin::regist (qw/wikiformat/);
}

sub property ($;@) {
    shift;
    my %prop = (
                name     => q(SuikaWiki: constance),
                version  => $VERSION,
                uri      => q(IW:SuikaWiki:SuikaWiki),
                provide  => [qw/wikiformat/],
		partinfo => {
  q(wikiformat/SuikaWikiConst/0.9-to-HTML) => q(SuikaWikiConst/0.9 document format -> HTML),
},
    );
    if (scalar @_ == 0) {
        \%prop;
    } else {
        @prop{@_};
    }
}
sub load_formatter ($$%) {
    my $self = shift;
    my ($fmt, %q) = @_;
    unless ($q{type}) {
        #
    }
    elsif ($q{type} eq 'wikiformat') {
      $fmt->{q(SuikaWikiConst/0.9_to_HTML)} = sub { my ($r, $p, $o) = ('', @_);
my $data = to_hash ($o->{content});
for my $key (sort keys %$data) {
  if ($o->_database_exist ($key)) {
    $r .= qq(<dt>@{[$o->_html_wikilink ($key)]}</dt>\n);
  } else {
    $r .= qq(<dt>@{[$o->escape ($key)]}</dt>\n);
  }
  $r .= qq(	<dd>@{[$o->escape ($data->{$key})]}</dd>\n);
}
$r = qq(<dl class="SuikaWikiConst">$r</dl>) if $r;
$r };

    }
} # sub load_formatter

sub to_hash ($;$) {
  my $page = shift;
  my $h = shift || {};
  my $val;
  for my $line (split /\n/, $page) {
    next if $line =~ /^#/;
    $line =~ tr/\x0A\x0D//d;
    if ($val && $line =~ s/^\s+\\?//) {
      $h->{$val} .= length $h->{$val} ? "\n" . $line : $line;
    } elsif ($line =~ /^(.+):/) {
      $val = $1; $h->{$val} = '';
    }
  }
  $h;
}

=head1 LICENSE

Copyright 2003 Wakaba <w@suika.fam.cx>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

=cut

1;