| Hatena-Formatter documentation | view source | Contained in the Hatena-Formatter distribution. |
Hatena::Formatter - converts text into html with almost Hatena style.
use Hatena::Formatter;
my $formatter = Hatena::Formatter->new(
text_config => {}, # set the Text::Hatena options.
keyword_config => {}, # set the Hatena::Keyword options.
);
$formatter->process($text);
print $formatter->html;
Text::Hatena used generates html string with Hatena Style. and Hatena::Keyword used allows you to mark up a text as HTML with the Hatena keywords. When you want to adjust the option of Text::Hatena and Hatena::Keyword, it can be done.
In the process of each processing, it is also possible to do original processing hooking to process converted HTML.
$formatter = Hatena::Formatter->new(
text_config => { hatenaid_href => '?id=%s' },
keyword_config => {},
);
creates an instance of Hatena::Formatter.
text_config is option that Text::Hatena uses.
When this option is omitted, the processing of Text::Hatena is not executed.
hatenaid_href is Enhancing for Hatena::Formatter.
The format of link href used by the id notation of Hatena is specified. id is substituted
for %s. (It is possible to omit it. )
keyword_config is option that Hatena::Keyword uses.
When this option is omitted, the processing of Hatena::Keyword is not executed.
$formatter2->register( hook => 'text_finalize', callback => sub { my($context, $option) = @_; } , option => {});
callback to do the hook in process is registered.
$formatter->process($text);
conversion processing.
$html = $formatter->html;
returns html string generated.
Kazuhiro Osawa <ko@yappo.ne.jp>
TransFreeBSD, Naoya Ito, otsune, tokuhirom
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Hatena-Formatter documentation | view source | Contained in the Hatena-Formatter distribution. |