summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/googlecalendar.pm1
-rw-r--r--IkiWiki/Plugin/htmltidy.pm21
-rw-r--r--IkiWiki/Plugin/linkmap.pm29
-rw-r--r--IkiWiki/Plugin/rst.pm21
4 files changed, 29 insertions, 43 deletions
diff --git a/IkiWiki/Plugin/googlecalendar.pm b/IkiWiki/Plugin/googlecalendar.pm
index c6abeb717..dc0df0ad3 100644
--- a/IkiWiki/Plugin/googlecalendar.pm
+++ b/IkiWiki/Plugin/googlecalendar.pm
@@ -4,7 +4,6 @@ package IkiWiki::Plugin::googlecalendar;
use warnings;
use strict;
use IkiWiki;
-use IPC::Open2;
sub import { #{{{
hook(type => "preprocess", id => "googlecalendar",
diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm
index 906c677dc..0609e72c3 100644
--- a/IkiWiki/Plugin/htmltidy.pm
+++ b/IkiWiki/Plugin/htmltidy.pm
@@ -19,21 +19,13 @@ sub import { #{{{
sub sanitize (@) { #{{{
my %params=@_;
- my $tries=10;
my $pid;
- while (1) {
- eval {
- $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
- };
- last unless $@;
- $tries--;
- if ($tries < 1) {
- debug("failed to run tidy: $@");
- return $params{content};
- }
- }
+ my $sigpipe=0;
+ $SIG{PIPE}=sub { $sigpipe=1 };
+ $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
+
# open2 doesn't respect "use open ':utf8'"
- binmode (IN, ':utf8');
+ binmode (IN, ':utf8');
binmode (OUT, ':utf8');
print OUT $params{content};
@@ -44,6 +36,9 @@ sub sanitize (@) { #{{{
close IN;
waitpid $pid, 0;
+ return $params{content} if $sigpipe;
+ $SIG{PIPE}="DEFAULT";
+
return $ret;
} # }}}
diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm
index 6b1609744..497b1ef43 100644
--- a/IkiWiki/Plugin/linkmap.pm
+++ b/IkiWiki/Plugin/linkmap.pm
@@ -63,18 +63,11 @@ sub genmap ($) { #{{{
# TODO: should really add the png to renderedfiles and call
# check_overwrite, but currently renderedfiles
# only supports listing one file per page.
- my $tries=10;
my $pid;
- while (1) {
- eval {
- $pid=open2(*IN, *OUT, "dot -Tpng -o '$config{destdir}/$params{page}.png' -Tcmapx");
- };
- last unless $@;
- $tries--;
- if ($tries < 1) {
- return "failed to run dot: $@";
- }
- }
+ my $sigpipe=0;;
+ $SIG{PIPE}=sub { $sigpipe=1 };
+ $pid=open2(*IN, *OUT, "dot -Tpng -o '$config{destdir}/$params{page}.png' -Tcmapx");
+
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
@@ -96,12 +89,18 @@ sub genmap ($) { #{{{
local $/=undef;
my $ret="<object data=\"".
- IkiWiki::abs2rel("$params{page}.png", IkiWiki::dirname($params{page})).
- "\" type=\"image/png\" usemap=\"#linkmap$mapnum\">\n".
- <IN>.
- "</object>";
+ IkiWiki::abs2rel("$params{page}.png", IkiWiki::dirname($params{page})).
+ "\" type=\"image/png\" usemap=\"#linkmap$mapnum\">\n".
+ <IN>.
+ "</object>";
close IN;
+
waitpid $pid, 0;
+ $SIG{PIPE}="DEFAULT";
+ if ($sigpipe) {
+ return "[[linkmap failed to run dot]]";
+ }
+
return $ret;
} #}}}
diff --git a/IkiWiki/Plugin/rst.pm b/IkiWiki/Plugin/rst.pm
index 1fd13d1f5..afd60f668 100644
--- a/IkiWiki/Plugin/rst.pm
+++ b/IkiWiki/Plugin/rst.pm
@@ -43,21 +43,11 @@ sub htmlize (@) { #{{{
my %params=@_;
my $content=$params{content};
- my $tries=10;
my $pid;
- while (1) {
- eval {
- # Try to call python and run our command
- $pid=open2(*IN, *OUT, "python", "-c", $pyCmnd)
- or return $content;
- };
- last unless $@;
- $tries--;
- if ($tries < 1) {
- debug("failed to run python to convert rst: $@");
- return $content;
- }
- }
+ my $sigpipe=0;
+ $SIG{PIPE}=sub { $sigpipe=1 };
+ $pid=open2(*IN, *OUT, "python", "-c", $pyCmnd);
+
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
@@ -70,6 +60,9 @@ sub htmlize (@) { #{{{
close IN;
waitpid $pid, 0;
+ return $content if $sigpipe;
+ $SIG{PIPE}="DEFAULT";
+
return $ret;
} # }}}