diff --git a/Makefile.PL b/Makefile.PL index 9c8f66f..b324098 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -19,6 +19,7 @@ test_requires 'Test::More' => '0.42'; test_requires 'Test::Exception' => undef; test_requires 'List::MoreUtils' => undef; test_requires 'Test::Differences' => undef; +test_requires 'Test::NoWarnings' => undef; test_requires 'FindBin' => undef; if ($Module::Install::AUTHOR) { diff --git a/lib/Text/Markdown.pm b/lib/Text/Markdown.pm index 1c1f93e..1821315 100644 --- a/lib/Text/Markdown.pm +++ b/lib/Text/Markdown.pm @@ -266,6 +266,9 @@ sub urls { sub _CleanUpDoc { my ($self, $text) = @_; + # An empty file can end up getting passed as undef. + return "\n\n" unless defined $text; + # Standardize line endings: $text =~ s{\r\n}{\n}g; # DOS to Unix $text =~ s{\r}{\n}g; # Mac to Unix diff --git a/t/05empty_markdown.t b/t/05empty_markdown.t new file mode 100644 index 0000000..b3aaf72 --- /dev/null +++ b/t/05empty_markdown.t @@ -0,0 +1,9 @@ +use strict; +use warnings; +use Test::More tests => 3; +use Text::Markdown; +use Test::NoWarnings; + +my $m = Text::Markdown->new; +ok $m->markdown(''), 'Parse empty string'; +ok $m->markdown(undef), 'Parse undef';