summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/format.pm24
-rw-r--r--IkiWiki/Plugin/highlight.pm6
-rw-r--r--IkiWiki/Plugin/txt.pm38
-rw-r--r--debian/changelog6
4 files changed, 50 insertions, 24 deletions
diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm
index d54e71131..b596bc0a1 100644
--- a/IkiWiki/Plugin/format.pm
+++ b/IkiWiki/Plugin/format.pm
@@ -29,22 +29,24 @@ sub preprocess (@) {
if (! defined $format || ! defined $text) {
error(gettext("must specify format and text"));
}
+
+ # Other plugins can register htmlizeformat hooks to add support
+ # for page types not suitable for htmlize, or that need special
+ # processing when included via format. Try them until one succeeds.
+ my $ret;
+ IkiWiki::run_hooks(htmlizeformat => sub {
+ $ret=shift->($format, $text)
+ unless defined $ret;
+ });
+
+ if (defined $ret) {
+ return $ret;
+ }
elsif (exists $IkiWiki::hooks{htmlize}{$format}) {
return IkiWiki::htmlize($params{page}, $params{destpage},
$format, $text);
}
else {
- # Other plugins can register htmlizefallback
- # hooks to add support for page types
- # not suitable for htmlize. Try them until
- # one succeeds.
- my $ret;
- IkiWiki::run_hooks(htmlizefallback => sub {
- $ret=shift->($format, $text)
- unless defined $ret;
- });
- return $ret if defined $ret;
-
error(sprintf(gettext("unsupported page format %s"), $format));
}
}
diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index d4ade0a7b..5674f0b4a 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -10,8 +10,8 @@ sub import {
hook(type => "getsetup", id => "highlight", call => \&getsetup);
hook(type => "checkconfig", id => "highlight", call => \&checkconfig);
# this hook is used by the format plugin
- hook(type => "htmlizefallback", id => "highlight", call =>
- \&htmlizefallback);
+ hook(type => "htmlizeformat", id => "highlight", call =>
+ \&htmlizeformat);
}
sub getsetup () {
@@ -79,7 +79,7 @@ sub checkconfig () {
}
}
-sub htmlizefallback {
+sub htmlizeformat {
my $format=lc shift;
my $langfile=ext2langfile($format);
diff --git a/IkiWiki/Plugin/txt.pm b/IkiWiki/Plugin/txt.pm
index 0d9a0b35b..fcfb68be9 100644
--- a/IkiWiki/Plugin/txt.pm
+++ b/IkiWiki/Plugin/txt.pm
@@ -17,6 +17,7 @@ sub import {
hook(type => "getsetup", id => "txt", call => \&getsetup);
hook(type => "filter", id => "txt", call => \&filter);
hook(type => "htmlize", id => "txt", call => \&htmlize);
+ hook(type => "htmlizeformat", id => "txt", call => \&htmlizeformat);
eval q{use URI::Find};
if (! $@) {
@@ -46,25 +47,42 @@ sub filter (@) {
will_render($params{page}, 'robots.txt');
writefile('robots.txt', $config{destdir}, $content);
}
-
- encode_entities($content, "<>&");
- if ($findurl) {
- my $finder = URI::Find->new(sub {
- my ($uri, $orig_uri) = @_;
- return qq|<a href="$uri">$orig_uri</a>|;
- });
- $finder->find(\$content);
- }
- $content = "<pre>" . $content . "</pre>";
+ return txt2html($content);
}
return $content;
}
+sub txt2html ($) {
+ my $content=shift;
+
+ encode_entities($content, "<>&");
+ if ($findurl) {
+ my $finder = URI::Find->new(sub {
+ my ($uri, $orig_uri) = @_;
+ return qq|<a href="$uri">$orig_uri</a>|;
+ });
+ $finder->find(\$content);
+ }
+ return "<pre>" . $content . "</pre>";
+}
+
# We need this to register the .txt file extension
sub htmlize (@) {
my %params=@_;
return $params{content};
}
+sub htmlizeformat ($$) {
+ my $format=shift;
+ my $content=shift;
+
+ if ($format eq 'txt') {
+ return txt2html($content);
+ }
+ else {
+ return;
+ }
+}
+
1
diff --git a/debian/changelog b/debian/changelog
index b304e4b86..2857ec482 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ikiwiki (3.20101024) UNRELEASED; urgency=low
+
+ * txt: Fix display when used inside a format directive.
+
+ -- Joey Hess <joeyh@debian.org> Mon, 25 Oct 2010 22:30:29 -0400
+
ikiwiki (3.20101023) unstable; urgency=low
* Fix typo that broke anonymous git push.