X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=sweavealike.pm;h=4747b18c98e65e1fa8d6d46dfcf3212be1d5c479;hb=4ed794890c1071b0b9b521948a932cc48550d9e6;hp=ec6660c09e77e4d26dbb32b3129b8db073aacbc7;hpb=c0ca3e7a81d0efccde44e827671bf33e559f356d;p=ikiwiki_plugins.git diff --git a/sweavealike.pm b/sweavealike.pm index ec6660c..4747b18 100644 --- a/sweavealike.pm +++ b/sweavealike.pm @@ -58,7 +58,9 @@ sub preprocess { # we currently don't bother to support anything but outputing the # entire segment of code and its R output - if (not exists $param{code} or not defined $param{code}) { + if (not exists $param{code} + or not defined $param{code} + or not length $param{code}) { error("There wasn't any R code supplied"); } my $code_result; @@ -66,14 +68,14 @@ sub preprocess { $code_result = $pagestate{$param{page}}{$id}{R}->run($param{code}); }; if ($@) { - error($@); + error("code '$param{code}' produced error '$@'"); } - my $output = "sweave output\n\n"; + my $output; if (exists $param{verbatim}) { $output = $param{code}; $output =~ s/^/> /mg; } - $output .= $code_result; + $output .= "\n".$code_result; $output =~ s/^/ /mg; return($output); }