Aozora2Epub

 view release on metacpan or  search on metacpan

t/files.t  view on Meta::CPAN

use strict;
use warnings;
use utf8;
use Test::More;
use Test::Base;
use Aozora2Epub;
use Aozora2Epub::Gensym;
use lib qw/./;
use t::Util;

plan tests => 1 * blocks;

sub drop_nlsp {
    my $s = shift;
    $s =~ s/\n *//sg;
    $s =~ s/\n$//sg;
    $s;
}

filters {
    html => 'chomp',
    expected => 'yaml',
};

run {
    my $block = shift;
    Aozora2Epub::Gensym->reset_counter;
    
    my $doc = Aozora2Epub->new($block->html, no_fetch_assets=>1);
    my $got = [ map { $_->as_html } @{$doc->files} ];
    is_deeply($got,
              [ map { drop_nlsp($_) } @{$block->expected} ],
              $block->name);
};

__DATA__

=== beginning br
--- html
<br/><br />あいうえお
--- expected
- あいうえお
--- note
本の先頭の<br/>の連続は削除される。

=== o-midashi
--- html
あ<br/>
<h3 class="o-midashi">
  <a class="midashi_anchor" id="midashi001">見出し</a>
</h3>
あいう
--- expected
- あ
- <br /><h3 class="o-midashi" id="midashi001">見出し</h3> あいう

=== naka-midashi
--- html
あ<br/>
<h4 class="naka-midashi">
  <a class="midashi_anchor" id="midashi001">見出し</a>
</h4>
あいう



( run in 1.915 second using v1.01-cache-2.11-cpan-5a3173703d6 )