Text::Hatena 0.20 released.

jkondo on 2007-02-27T21:58:42

I uploaded Text::Hatena 0.20. It's quite new version of Text::Hatena.

I rewrote the whole code using Parse::RecDescent and Regexp::Assemble. Number of modules were reduced to 2 from 47 files. Line of codes where changed from 2600 lines to 600 lines. My benchmark marked 300-400% higher performance than ver.0.16.

I also removed some syntaxes which were specific to Hatena Diary.

Now, API for parsing text were changed too. Please be careful to upgrade your Text::Hatena to version 0.20+.

You can use Text::Hatena simply as below.

my $html = Text::Hatena->parse($text);

And, you can extend your parser like this. You can easily make your original parser which can handle some other format.

package MyParser; use strict; use warnings; use base qw(Text::Hatena);

__PACKAGE__->syntax(q| h3 : "\n*" timestamp(?) inline(s) timestamp : /\d{9,10}/ '*' |);

sub h3 { my $class = shift; my $items = shift->{items}; my $title = $class->expand($items->[2]); return if $title =~ /^\*/; my $ret = "

$title"; if (my $time = $items->[1]->[0]) { $ret .= qq|$time|; } $ret .= "

\n"; }

sub timestamp { my $class = shift; my $items = shift->{items}; return $items->[0]; }

1;

You can also extend inline elements like this.

Text::Hatena::AutoLink->syntax({ 'id:([\w-]+)' => sub { my $mvar = shift; my $name = $mvar->[1]; return qq|id:$name|; }, 'd:id:([\w-]+)' => sub { my $mvar = shift; my $name = $mvar->[1]; return qq|d:id:$name|; }, });

I'd like to get your feedback.


Class::Data::Inheritable is required

ysano on 2007-02-28T10:17:01

Hi,

Class::Data::Inheritable is required to install Text::Hatena 0.20.

You should add Class::Data::Inheritable entry to 'PREREQ_PM' in Makefile.PL, I think.

I hope this could help you.