]> git.donarmstrong.com Git - ikiwiki_plugins.git/blobdiff - sweavealike.pm
start the R process first
[ikiwiki_plugins.git] / sweavealike.pm
index 48c603c63a5f3e38339e0906f0ec377e690d0dd8..0dd0e1b5ed8260650c629908cf66b7c983f61a89 100644 (file)
@@ -119,6 +119,8 @@ sub preprocess {
        chdir($config{srcdir});
        $pagestate{$param{page}}{$id}{R} = Statistics::R->new(shared => 1)
            or error("Unable to create an R process");
+       $pagestate{$param{page}}{$id}{R}->start() or
+           error("Unable to start the R process");
        chdir($cur_dir);
     }
     # we currently don't bother to support anything but outputing the
@@ -172,7 +174,7 @@ sub preprocess {
        if ($@) {
            error("code 'dev.off()' (from internal figure handling) produced error '$@'");
        }
-       $fig_output = qq(\n<img class="sweavealike" src=").urlto($image_loc,$param{destpage}).qq(" />);
+       $fig_output = qq(\n\n<img class="sweavealike" src=").urlto($image_loc,$param{destpage}).qq(" />\n);
     }
     if (exists $param{nooutput}) {
        return($output.$fig_output);
@@ -191,7 +193,7 @@ sub preprocess {
        exists $param{results}) {
        $output =~ s/^/    /mg;
     }
-    return($output);
+    return($output.$fig_output);
 }
 
 # stop any started R processes here