sub get_utf8_text {
use 5.010;
use HTML::FromText;
use Path::Tiny;
use utf8;
use open OUT => ':utf8';
### Passing in
#reference to main data structure and directory for captions
my ( $rvars, $dir ) = (@_);
my %vars = %$rvars;
say "dir is $dir";
opendir my $eh, $dir or warn "can't open dir for utf8 captions $!\n";
while ( defined( $_ = readdir($eh) ) ) {
next if m/~$/;
next if -d;
if (m/txt$/) {
my $file = path( $dir, $_ );
my $guts = $file->slurp_utf8;
my $temp = text2html(
$guts,
lines => 1,
paras => 1,
);
# surround by divs
my $oitop = $vars{"oitop"};
my $oben = $oitop->slurp_utf8;
my $oibottom = $vars{"oibottom"};
my $unten = $oibottom->slurp_utf8;
my $text = $oben . $temp . $unten;
say "text is $text";
$content{$_} = $text;
}
}
closedir $eh;
#important to sort
my @return;
foreach my $key ( sort keys %content ) {
#print $content{$key} . "\n";
push @return, $content{$key};
}
return \@return;
}