Text-Hatena

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- added HTMLFilter and sanitizing HTML process.
	- added texthandler callback.
	- removed "use 5.00.." in Makefile.PL
	- rewrited authors of Text::Hatena Syntax

0.04  Thu Nov 10
	- added syntax samples
	- escape strings in suprepre node

0.03  Wed Nov 9
	- added taglines node, tag node, cdata node.
	- added Text::Hatena Syntax description.
	- fixed pre node ("|<" at line end become works). 

0.02  Fri Oct 8
	- fixed typo.

0.01  Wed Aug 31 10:07:25 2005
	- original version

lib/Text/Hatena.pm  view on Meta::CPAN

    section    : h3(?) block(s?)
    # Block Elements
    block      : h5
               | h4
               | blockquote
               | dl
               | list
               | super_pre
               | pre
               | table
               | cdata
               | p
    h3         : "\n*" inline(s)
    h4         : "\n**" inline(s)
    h5         : "\n***" inline(s)
    blockquote : "\n>" http(?) ">" block(s) "\n<<" ..."\n"
    dl         : dl_item(s)
    dl_item    : "\n:" inline[term => ':'](s) ':' inline(s)
    list       : list_item[level => $arg{level} || 1](s)
    list_item  : "\n" /[+-]{$arg{level}}/ inline(s) list[level => $arg{level} + 1](?)
    super_pre  : /\n>\|(\w*)\|/o text_line(s) "\n||<" ..."\n"
    text_line  : ...!"\n||<\n" "\n" /[^\n]*/o
    pre        : "\n>|" pre_line(s) "\n|<" ..."\n"
    pre_line   : ...!"\n|<" "\n" inline(s?)
    table      : table_row(s)
    table_row  : "\n|" td(s /\|/) '|'
    td         : /\*?/o inline[term => '\|'](s)
    cdata      : "\n><" /.+?(?=><\n)/so "><" ..."\n"
    p          : ...!p_terminal "\n" inline(s?)
    p_terminal : h3 | "\n<<\n"
    # Inline Elements
    inline     : /[^\n$arg{term}]+/
    http       : /https?:\/\/[A-Za-z0-9~\/._\?\&=\-%#\+:\;,\@\']+(?::title=[^\]]+)?/
);

sub parse {
    my $class = shift;
    my $text = shift or return;

lib/Text/Hatena.pm  view on Meta::CPAN

}

sub td {
    my $class = shift;
    my $items = shift->{items};
    my $tag = $items->[0] ? 'th' : 'td';
    my $inlines = $class->expand($items->[1]);
    return "<$tag>$inlines</$tag>\n";
}

sub cdata {
    my $class = shift;
    my $items = shift->{items};
    my $data = $items->[1];
    return "<$data>\n";
}

sub p {
    my $class = shift;
    my $items = shift->{items};
    my $inlines = $class->expand($items->[2]);

t/01_module.t  view on Meta::CPAN

	  <th>Lang</th>
	  <th>Module</th>
	</tr>
	<tr>
	  <td>Perl</td>
	  <td>Text::Hatena</td>
	</tr>
  </table>
</div>

=== cdata
--- text
><div>no paragraph line</div><
paragraph line
--- html
<div class="section">
	<div>no paragraph line</div>
	<p>paragraph line</p>
</div>

=== cdata2
--- text
><blockquote>
<p>Hello I am writing HTML tags by myself</p>
</blockquote><
--- html
<div class="section">
  <blockquote>
	<p>Hello I am writing HTML tags by myself</p>
  </blockquote>
</div>

=== cdata3
--- text
><blockquote><
Please add p tags for me.
It's candy blockquote.
></blockquote><
--- html
<div class="section">
  <blockquote>
	<p>Please add p tags for me.</p>
	<p>It's candy blockquote.</p>



( run in 0.629 second using v1.01-cache-2.11-cpan-454fe037f31 )