14 April 2005
This post may be outdated due to it was written on 2005. The links may be broken. The code may be not working anymore. Leave comments if needed.

数几个小时前写了个 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



blog comments powered by Disqus