aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-28 18:17:59 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-08-28 18:17:59 +0000
commit4895955ceaf264c5f17b10c4009e1ab1afcc55ee (patch)
tree4f8553a9007b263e0b44afd0b9d0cbe8b5cf7b88 /IkiWiki/Plugin
parente3a6ff004474cacb3e7a69a37696a65ebf1e2fcd (diff)
downloadikiwiki-4895955ceaf264c5f17b10c4009e1ab1afcc55ee.tar
ikiwiki-4895955ceaf264c5f17b10c4009e1ab1afcc55ee.tar.gz
* Change htmlize, format, and sanitize hooks to use named parameters.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/html.pm9
-rw-r--r--IkiWiki/Plugin/htmlscrubber.pm5
-rw-r--r--IkiWiki/Plugin/htmltidy.pm8
-rw-r--r--IkiWiki/Plugin/inline.pm2
-rw-r--r--IkiWiki/Plugin/mdwn.pm5
-rw-r--r--IkiWiki/Plugin/otl.pm8
-rw-r--r--IkiWiki/Plugin/rst.pm5
-rw-r--r--IkiWiki/Plugin/sidebar.pm2
-rw-r--r--IkiWiki/Plugin/skeleton.pm18
-rw-r--r--IkiWiki/Plugin/toc.pm20
-rw-r--r--IkiWiki/Plugin/wikitext.pm5
11 files changed, 49 insertions, 38 deletions
diff --git a/IkiWiki/Plugin/html.pm b/IkiWiki/Plugin/html.pm
index 8d3187a71..83720b4b5 100644
--- a/IkiWiki/Plugin/html.pm
+++ b/IkiWiki/Plugin/html.pm
@@ -7,12 +7,17 @@ use strict;
use IkiWiki;
sub import { #{{{
- IkiWiki::hook(type => "htmlize", id => "html", call => sub { shift });
- IkiWiki::hook(type => "htmlize", id => "htm", call => sub { shift });
+ IkiWiki::hook(type => "htmlize", id => "html", call => \&htmlize);
+ IkiWiki::hook(type => "htmlize", id => "htm", call => \&htmlize);
# ikiwiki defaults to skipping .html files as a security measure;
# make it process them so this plugin can take effect
$IkiWiki::config{wiki_file_prune_regexp} =~ s/\|\\\.x\?html\?\$//;
} # }}}
+sub htmlize (@) { #{{{
+ my %params=@_;
+ return $params{content};
+} #}}}
+
1
diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm
index 8e8391817..d77ab809b 100644
--- a/IkiWiki/Plugin/htmlscrubber.pm
+++ b/IkiWiki/Plugin/htmlscrubber.pm
@@ -10,8 +10,9 @@ sub import { #{{{
call => \&sanitize);
} # }}}
-sub sanitize ($) { #{{{
- return scrubber()->scrub(shift);
+sub sanitize (@) { #{{{
+ my %params=@_;
+ return scrubber()->scrub($params{content});
} # }}}
my $_scrubber;
diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm
index eb8f9d3d3..079da7b49 100644
--- a/IkiWiki/Plugin/htmltidy.pm
+++ b/IkiWiki/Plugin/htmltidy.pm
@@ -16,7 +16,9 @@ sub import { #{{{
IkiWiki::hook(type => "sanitize", id => "tidy", call => \&sanitize);
} # }}}
-sub sanitize ($) { #{{{
+sub sanitize (@) { #{{{
+ my %params=@_;
+
my $tries=10;
while (1) {
eval {
@@ -26,14 +28,14 @@ sub sanitize ($) { #{{{
$tries--;
if ($tries < 1) {
IkiWiki::debug("failed to run tidy: $@");
- return shift;
+ return $params{content};
}
}
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
- print OUT shift;
+ print OUT $params{content};
close OUT;
local $/ = undef;
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index fe7dde14c..1cbde7104 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -144,7 +144,7 @@ sub get_inline_content ($$) { #{{{
my $file=$pagesources{$page};
my $type=pagetype($file);
if (defined $type) {
- return htmlize($type,
+ return htmlize($page, $type,
linkify($page, $destpage,
preprocess($page, $destpage,
filter($page,
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm
index 8e037f5de..2274fea72 100644
--- a/IkiWiki/Plugin/mdwn.pm
+++ b/IkiWiki/Plugin/mdwn.pm
@@ -11,8 +11,9 @@ sub import { #{{{
} # }}}
my $markdown_loaded=0;
-sub htmlize ($) { #{{{
- my $content = shift;
+sub htmlize (@) { #{{{
+ my %params=@_;
+ my $content = $params{content};
if (! $markdown_loaded) {
# Note: This hack to make markdown run as a proper perl
diff --git a/IkiWiki/Plugin/otl.pm b/IkiWiki/Plugin/otl.pm
index 314ed28ad..be339c88e 100644
--- a/IkiWiki/Plugin/otl.pm
+++ b/IkiWiki/Plugin/otl.pm
@@ -27,7 +27,9 @@ sub filter (@) { #{{{
return $params{content};
} # }}}
-sub htmlize ($) { #{{{
+sub htmlize (@) { #{{{
+ my %params=@_;
+
my $tries=10;
while (1) {
eval {
@@ -37,14 +39,14 @@ sub htmlize ($) { #{{{
$tries--;
if ($tries < 1) {
IkiWiki::debug("failed to run otl2html: $@");
- return shift;
+ return $params{content};
}
}
# open2 doesn't respect "use open ':utf8'"
binmode (IN, ':utf8');
binmode (OUT, ':utf8');
- print OUT shift;
+ print OUT $params{content};
close OUT;
local $/ = undef;
diff --git a/IkiWiki/Plugin/rst.pm b/IkiWiki/Plugin/rst.pm
index 6bf11fe36..08ac15e43 100644
--- a/IkiWiki/Plugin/rst.pm
+++ b/IkiWiki/Plugin/rst.pm
@@ -39,8 +39,9 @@ sub import { #{{{
IkiWiki::hook(type => "htmlize", id => "rst", call => \&htmlize);
} # }}}
-sub htmlize ($) { #{{{
- my $content=shift;
+sub htmlize (@) { #{{{
+ my %params=@_;
+ my $content=$params{content};
my $tries=10;
while (1) {
diff --git a/IkiWiki/Plugin/sidebar.pm b/IkiWiki/Plugin/sidebar.pm
index e0e81526f..0b006f110 100644
--- a/IkiWiki/Plugin/sidebar.pm
+++ b/IkiWiki/Plugin/sidebar.pm
@@ -28,7 +28,7 @@ sub sidebar_content ($) { #{{{
my $content=IkiWiki::readfile(IkiWiki::srcfile($sidebar_file));
return unless length $content;
- return IkiWiki::htmlize($sidebar_type,
+ return IkiWiki::htmlize($page, $sidebar_type,
IkiWiki::linkify($sidebar_page, $page,
IkiWiki::preprocess($sidebar_page, $page,
IkiWiki::filter($sidebar_page, $content))));
diff --git a/IkiWiki/Plugin/skeleton.pm b/IkiWiki/Plugin/skeleton.pm
index 4683b00ba..5947ebb4c 100644
--- a/IkiWiki/Plugin/skeleton.pm
+++ b/IkiWiki/Plugin/skeleton.pm
@@ -57,28 +57,28 @@ sub filter (@) { #{{{
return $params{content};
} # }}}
-sub htmlize ($) { #{{{
- my $content=shift;
+sub htmlize (@) { #{{{
+ my %params=@_;
IkiWiki::debug("skeleton plugin running as htmlize");
- return $content;
+ return $params{content};
} # }}}
-sub sanitize ($) { #{{{
- my $content=shift;
+sub sanitize (@) { #{{{
+ my %params=@_;
IkiWiki::debug("skeleton plugin running as a sanitizer");
- return $content;
+ return $params{content};
} # }}}
-sub format ($) { #{{{
- my $content=shift;
+sub format (@) { #{{{
+ my %params=@_;
IkiWiki::debug("skeleton plugin running as a formatter");
- return $content;
+ return $params{content};
} # }}}
sub pagetemplate (@) { #{{{
diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm
index c36ce2893..063e66f3b 100644
--- a/IkiWiki/Plugin/toc.pm
+++ b/IkiWiki/Plugin/toc.pm
@@ -14,7 +14,7 @@ sub import { #{{{
call => \&format);
} # }}}
-my @tocs;
+my %tocpages;
sub preprocess (@) { #{{{
my %params=@_;
@@ -23,17 +23,17 @@ sub preprocess (@) { #{{{
# It's too early to generate the toc here, so just record the
# info.
- push @tocs, \%params;
+ $tocpages{$params{destpage}}=\%params;
- return "\n[[toc $#tocs]]\n";
+ return "\n<div class=\"toc\"></div>\n";
} # }}}
-sub format ($) { #{{{
- my $content=shift;
+sub format (@) { #{{{
+ my %params=@_;
+ my $content=$params{content};
- return $content unless @tocs && $content=~/\[\[toc (\d+)\]\]/ && $#tocs >= $1;
- my $id=$1;
- my %params=%{$tocs[$id]};
+ return $content unless exists $tocpages{$params{page}};
+ %params=%{$tocpages{$params{page}}};
my $p=HTML::Parser->new(api_version => 3);
my $page="";
@@ -107,9 +107,7 @@ sub format ($) { #{{{
$index.=&$indent."</ol>\n";
}
- # Ignore cruft around the toc marker, probably <p> tags added by
- # markdown which shouldn't appear in a list anyway.
- $page=~s/\n.*\[\[toc $id\]\].*\n/$index/;
+ $page=~s/(<div class=\"toc\">)/$1\n$index/;
return $page;
}
diff --git a/IkiWiki/Plugin/wikitext.pm b/IkiWiki/Plugin/wikitext.pm
index 9fa87dafb..5c46c565c 100644
--- a/IkiWiki/Plugin/wikitext.pm
+++ b/IkiWiki/Plugin/wikitext.pm
@@ -11,8 +11,9 @@ sub import { #{{{
IkiWiki::hook(type => "htmlize", id => "wiki", call => \&htmlize);
} # }}}
-sub htmlize ($) { #{{{
- my $content = shift;
+sub htmlize (@) { #{{{
+ my %params=@_;
+ my $content = $params{content};
return Text::WikiFormat::format($content, undef, { implicit_links => 0 });
} # }}}