����������̏����㏢�������¹���������������»�����я�¡������������­�����������¹��¡򏪴���¼��ҏ�����¼��ҡ�������������Ώ����я�������¡�����������������µ­��������¹\���­�����Ώ����ď��������������¹��¡�livedoor blog������������\µ\����¼\������¹���������돢�������������������¹���«����������������

������������������µ­�������폢�½������ Text::Livedoor::Wiki������

Text::Livedoor::Wikiµ­����������»�����𡯏��м�����������¡�����������������µ­�������������������������������ޏ�����\µ\����¼\������������­�����������������Ï����я�������������������¡�\��\���\��\���\��я�돫��������Ð���������������������ޏ�������������¡�

Text::Livedoor::Wiki::PluginX::Block::Hatena

�����������������������������Ώ����ď����������³����̏��������������­�����ď���������\������¼\���\��я��������������쏪��̏����ӏ��������������������Ԣ����¹��������ď����ӏ����я�����������������µ��������ҏ��������ޏ���������

package Text::Livedoor::Wiki::PluginX::Block::Hatena;

use strict;
use warnings;
use base qw(Text::Livedoor::Wiki::Plugin::Block);
use Text::Hatena;
our $VERSION = '0.01';

__PACKAGE__->trigger({ 
     start=> '^__HATENA__$' , 
     end  => '^__HATENA__$' , 
     escape => 1 });

sub check {
    my $class        = shift;
    my $line        = shift;
    my $args        = shift;
    my $on_next     = $args->{on_next};
    my $id          = $args->{id};
    my $scratchpad  = $Text::Livedoor::Wiki::scratchpad;
    my $row;
    my $option_str;
    my $processing = $scratchpad->{block}{$id}{processing};

    # header
    if (( ( $row, $option_str ) = $line =~ /^__HATENA__$/) 
     && !$processing  && !$on_next ){
        my $res = { id => $id };
        $scratchpad->{block}{$id}{processing} = 1;
        return $res;
    }
    # end box
    elsif( $line =~ /^__HATENA__$/ && $processing 
     && !$on_next ) {
        $scratchpad->{block}{$id}{processing} = 0;
        return { line => '' } ;
    }
    # finalize
    elsif( $on_next && !$processing ) {
        return ;
    }
    # processing
    elsif( $processing ) {
        return { line => $line  };
    }
    # not much
    return;
}
sub get {
    my $class = shift;
    my $block = shift;
    my $inline = shift;
    my $items = shift;
    my $meta = shift @{$items};
    my $id         = $meta->{id};
    my $data = '';
    $data .= $_->{line} . "\n" for @$items;
    $data =~ s/\n$//;
    return Text::Hatena->parse( $data );
}

»���������������

''������������������µ­����������������������������������''
__HATENA__
*������������������µ­����������������
>||
������������������µ­�����������¹���¼�����Џ��¼���ߏ�����������������
||<
__HATENA__

½Ð����

���³�����я��������������������������С�¹���µ����������������������������

<div class="user-area">
<b>������������������µ­����������������������������������</b><div class="section">
<h3>������������������µ­����������������</h3>
<pre>
������������������µ­�����������¹���¼�����Џ��¼���ߏ�����������������
</pre>
</div>
</div>

test

use Test::Base qw/no_plan/;
use Text::Livedoor::Wiki;
my $parser = Text::Livedoor::Wiki->new({ 
    block_plugins =>
     [qw/Text::Livedoor::Wiki::PluginX::Block::Hatena/] });

run {
    my $block = shift;
    my $html = $parser->parse( $block->wiki );
    is( $html, $block->html , $block->name );
}

__DATA__

=== basic
--- wiki
''������������������µ­����������������������������������''
__HATENA__
*������������������µ­����������������
>||
������������������µ­�����������¹���¼�����Џ��¼���ߏ�����������������
||<
__HATENA__
--- html
<div class="user-area">
<b>������������������µ­����������������������������������</b><div class="section">
<h3>������������������µ­����������������</h3>
<pre>
������������������µ­�����������¹���¼�����Џ��¼���ߏ�����������������
</pre>
</div>
</div>

������������������

���������졭�������ޏ��������·���������� ���µ������ Let's cpan insatll Text::Livedoor::Wiki !!