App-sdview-Output-HTML
view release on metacpan or search on metacpan
t/01output-html.t view on Meta::CPAN
#!/usr/bin/perl
use v5.26;
use warnings;
use utf8;
use experimental 'signatures';
use Test2::V0;
# We don't have a "HTML" input, but we can input from POD or Markdown and test
# that we get some expected output
use App::sdview::Parser::Pod 0.13;
use App::sdview::Parser::Markdown 0.13;
use App::sdview::Output::HTML;
sub dotest ( $name, $format, $in, $out_html )
{
my $parserclass = "App::sdview::Parser::" . ucfirst($format);
my @p = $parserclass->new->parse_string( $in );
my $output = App::sdview::Output::HTML->new;
my $html = $output->generate( @p );
is( $html, $out_html, "Generated HTML for $name" );
}
dotest "Headings", pod => <<"EOPOD",
=head1 Head1
=head2 Head2
Contents here
EOPOD
<<"EOHTML";
<h1>Head1</h1>
<h2>Head2</h2>
<p>Contents here</p>
EOHTML
dotest "Formatting (from Pod)", pod => <<"EOPOD",
=pod
B<bold> B<< <bold> >>
I<italic>
C<code> C<< code->with->arrows >>
L<link|target://> L<Module::Here>
U<underline>
EOPOD
<<"EOHTML";
<p><strong>bold</strong> <strong><bold></strong></p>
<p><em>italic</em></p>
<p><tt>code</tt> <tt>code->with->arrows</tt></p>
<p><a href="target://">link</a> <a href="https://metacpan.org/pod/Module::Here">Module::Here</a></p>
<p><u>underline</u></p>
EOHTML
# POD can't do strikethrough so we'll ask Markdown
dotest "Formatting (from Markdown)", markdown => <<"EOMARKDOWN",
~~strikethrough~~
EOMARKDOWN
<<"EOHTML";
<p><s>strikethrough</s></p>
EOHTML
dotest "Verbatim", pod => <<"EOPOD",
=head1 EXAMPLE
use v5.14;
use warnings;
say "Hello, world";
EOPOD
<<"EOHTML";
<h1>EXAMPLE</h1>
<pre>
use v5.14;
use warnings;
say "Hello, world";</pre>
EOHTML
dotest "Bullet lists", pod => <<"EOPOD",
=over 4
=item *
First
=item *
Second
=item *
Third
=back
EOPOD
<<"EOHTML";
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
EOHTML
dotest "Numbered lists", pod => <<"EOPOD",
=over 4
=item 1.
First
( run in 0.974 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )