use strict; use Test::Base tests => 13; use HTML::Split; filters { input => [ qw( chomp ) ], expected => [ qw( lines chomp array ) ], }; sub paginate { my $len = filter_arguments; return [ HTML::Split->split(html => $_, length => $len) ]; } sub paginate_extend { my $len = filter_arguments; # find extend tag # ex: [E:typhoon] return [ HTML::Split->split( html => $_, length => $len, extend_tags => [ { full => qr/\[E:[\w\-]+\]/, begin => qr/\[[^\]]*?/, end => qr/[^\]]+\]/, }, ]) ]; } run_compare; __END__ === Blocked html --- input paginate=10
www.sixapart.com
--- expectedwww.six
apart.com
=== Split in the middle of start tag --- input paginate=30www.sixapart.comsixapart
--- expectedwww.sixapart.com
sixapart
=== Split in the middle of end tag --- input paginate=25typepad
movabletype
--- expectedtypepad
movabletype
=== Plain text --- input paginate=10 abcdefghij0123456789ABCDEFGHIJ0123456789 --- expected abcdefghij 0123456789 ABCDEFGHIJ 0123456789 === Just limit plain text --- input paginate=20 abcdefghij0123456789 --- expected abcdefghij0123456789 === None tagged text at the end of text --- input paginate=15 typepad2.0sixapart --- expected typepad2.0 sixapart === Unclosed tag --- input paginate=10www.sixapart.com --- expected
www.six
apart.com
=== If split in the middle of 'a' element's text, append it current page. --- input paginate=50exampleexample.comtest
--- expectedexampleexample.com
test
=== Exclude empty element from start tag group --- input paginate=20foofoofoo
barbarbar
gazooo
test
foofoofoo
barbarbar
gazooo
test
=== 'A' element has text over limits chars per page --- input paginate=30 --- expectedfooooo
=== 'A' element has img over limits chars per page --- input paginate=30 --- expectedfooooo
=== 'A' element has img and text over limits chars per page --- input paginate=30 --- expectedfooooo
=== Split in the middle of typepad emoticon --- input paginate_extend=10 foobar[E:typhoon]あいうえお1234[E:sun]abcdefghi[test] --- expected foobar[E:typhoon] あいうえお1234[E:sun] abcdefghi[ test]