HTML-FormatExternal
view release on metacpan or search on metacpan
devel/run.pl view on Meta::CPAN
require HTML::FormatText::Links;
print "Links _have_html_margin(): ",
(HTML::FormatText::Links->_have_html_margin() ? "yes" : "no"),"\n";
require HTML::FormatText::Vilistextum;
print "Vilistextum _have_multibyte(): ",
(HTML::FormatText::Vilistextum->_have_multibyte() ? "yes" : "no"),"\n";
exit 0;
}
{
# IPC::Run in taint mode
# $ENV{PATH} = '/bin:/usr/bin';
my $str;
require IPC::Run;
IPC::Run::run(['echo','hello'], '>',\$str);
# IPC::Run::run(['cat'], '<', \'hello', '>', \$str);
### $str
exit 0;
}
{
# taintedness of program_version()
$ENV{PATH} = '/bin:/usr/bin';
require HTML::FormatText::W3m;
my $str = HTML::FormatText::W3m->program_full_version;
require Scalar::Util;
print "tainted ",(Scalar::Util::tainted($str) ? 'yes' : 'no'), "\n";
exit 0;
}
{
# format_file() with output_wide
require HTML::FormatText::W3m;
my $str = HTML::FormatText::W3m->format_file
('devel/base.html', output_wide => 1);
$Data::Dumper::Useqq=1;
print Dumper(\$str);
print "utf8 flag ",(utf8::is_utf8($str) ? 'yes' : 'no'), "\n";
exit 0;
}
{
# format_file() with base
require HTML::FormatText::Elinks;
my $str = HTML::FormatText::Elinks->format_file
('devel/base.html', base => 'http://localhost');
exit 0;
}
{
# BOM on input
# lynx recognises automatically
my $html = "<html><body><p>Hello world</p></body></html>\n";
require Encode;
$html = Encode::encode('utf-32',$html); # with BOM
# $html = "\xFF\xFE\x00\x00" . Encode::encode('utf-32le',$html); # with BOM
$html = ("\x20\x00\x00\x00" x 8) . $html; # BE spaces
print "HTML input string:\n";
IPC::Run::run(['hd'],'<',\$html, '>','/tmp/hd.txt');
IPC::Run::run(['cat'],'<','/tmp/hd.txt');
require HTML::FormatText::Lynx;
my $text = HTML::FormatText::Lynx->format_string ($html,
input_charset=>'UTF-32',
# output_charset=>'UTF-8',
output_wide => 1,
# base => 'http://localhost',
);
print "Text output:\n";
print $text;
IPC::Run::run(['hd'],'<',\$text, '>','/tmp/hd.txt');
IPC::Run::run(['cat'],'<','/tmp/hd.txt');
for my $i (0 .. length($text)-1) {
my $c = substr($text,$i,1);
if (ord($c) >= 128) {
printf "0x%X\n", ord($c);
}
}
exit 0;
}
{
# entities
POSIX::setlocale (POSIX::LC_CTYPE(), "C");
foreach my $class ('HTML::FormatText::Netrik',
'HTML::FormatText::Links',
'HTML::FormatText::Html2text',
'HTML::FormatText::Lynx',
'HTML::FormatText::Elinks',
'HTML::FormatText::W3m',
'HTML::FormatText::Vilistextum',
) {
print "--------------------\n$class\n";
Module::Load::load ($class);
my $html = "
<html>
<head>
<meta http-equiv=Content-Type content='text/html; charset=iso-8859-1'>
</head>
<body>
<p>
\xA2 ☺ ◖
</p>
</body>
</html>";
my $str = $class->format_string
($html
# input_charset => $input_charset,
# output_charset => $output_charset,
);
( run in 0.511 second using v1.01-cache-2.11-cpan-e1769b4cff6 )