Journal(2005) | Blog(2006) | RandomLink | WhoAmI | LiveBookmark | HomePage

<<Previous: Text::Textile  >>Next: ACL(access control list) 的部分实现

Kwiki Formatter

Category: Modules   Keywords: Kwiki

数几个小时前写了个 textile, 现在想写个 Kwiki 格式。

CPAN 中没有现成的 Kwiki 直接格式模块,但是有个实现了所有功能的模块 CGI::Kwiki::Formatter ,于是我就写了个继承这模块的子模块。

模块代码如下:

package Text::KwikiFormatter;

use strict;

use vars qw( $VERSION );
$VERSION = '0.01';

use base qw(CGI::Kwiki::Formatter);

sub new {
   my $class = shift;
   my $self = { @_ };
   bless $self, $class;
   return $self;
}

sub wiki_link_format {
   my ($self, $text) = @_;
   my $wiki_link = qq{<a href='$text.html'>$text</a>};
   return $wiki_link;
}

1;

代码很简单,除了要置换 wiki_link_format 这个格式是针对 wiki 内部词汇转换,我把它改为我自己所需要的 Eplanet 内部转换。

运用代码如下:

use Text::KwikiFormatter;
my $formatter = Text::KwikiFormatter->new();

print $formatter->process($text);

Have fun! Enjoy!

Refer

http://www.kwiki.org/index.cgi?KwikiFormattingRules

<<Previous: Text::Textile  >>Next: ACL(access control list) 的部分实现

Options: +Del.icio.us

Related items Created on 2005-04-14 22:42:55, Last modified on 2005-04-14 22:56:18
Copyright 2004-2005 All Rights Reserved. Powered by Eplanet && Catalyst 5.62.