Skip to content

Commit

Permalink
better pod_to_html test
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 9, 2015
1 parent 964145d commit 8b9f7e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -4,6 +4,8 @@
Mojo::Transaction::WebSocket.
- Improved finish and send methods in Mojolicious::Controller to
automatically establish the WebSocket connection if necessary.
- Improved pod_to_html helper in Mojolicious::Plugin::PODRenderer to unindent
verbatim blocks. (OlegG)

6.07 2015-04-07
- Fixed Windows bug in "daemon.t".
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojolicious/Plugin/PODRenderer.pm
Expand Up @@ -5,7 +5,7 @@ use Mojo::Asset::File;
use Mojo::ByteStream 'b';
use Mojo::DOM;
use Mojo::URL;
use Mojo::Util qw(slurp);
use Mojo::Util 'slurp';
use Pod::Simple::XHTML;
use Pod::Simple::Search;

Expand Down Expand Up @@ -96,11 +96,7 @@ sub _pod_to_html {
my $parser = Pod::Simple::XHTML->new;
$parser->perldoc_url_prefix('https://metacpan.org/pod/');
$parser->$_('') for qw(html_header html_footer);
$parser->strip_verbatim_indent(sub {
my $lines = shift;
my ($indent) = $lines->[0] =~ /^(\s+)/;
return $indent;
});
$parser->strip_verbatim_indent(sub { my ($i) = $_[0][0] =~ /^(\s+)/; $i });
$parser->output_string(\(my $output));
return $@ unless eval { $parser->parse_string_document("$pod"); 1 };

Expand Down
6 changes: 4 additions & 2 deletions t/mojolicious/pod_renderer_lite_app.t
Expand Up @@ -39,7 +39,7 @@ $t->post_ok('/')->status_is(200)->content_like(qr!test123<h1 id="A">A</h1>!)
# POD filter
$t->post_ok('/block')->status_is(200)
->content_like(qr!test321<h2 id="lalala">lalala</h2>!)
->content_like(qr!<pre><code>foo\(bar, bazz\)</code></pre>!)
->content_like(qr!<pre><code>\{\n foo\(\);\n\}</code></pre>!)
->content_like(qr!<p><code>test</code></p>!)->content_like(qr/Gray/);

# Empty
Expand Down Expand Up @@ -101,6 +101,8 @@ test123<%= pod_to_html "=head1 A\n\n=head1 B\n\nC<test>"%>
@@ block.html.ep
test321<%= pod_to_html begin %>=head2 lalala
foo(bar, bazz)
{
foo();
}
C<test><% end %>

0 comments on commit 8b9f7e4

Please sign in to comment.