aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/table.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-01-13 12:26:43 +0100
committerintrigeri <intrigeri@boum.org>2009-01-13 12:26:43 +0100
commit82197bd0eaa216b841caace38c976acc7f6ad3fa (patch)
tree450f4afafb26d17a54c4917fb20d067c24efcaf7 /IkiWiki/Plugin/table.pm
parentc8e3136d0091bd024e6dc1f3c21a10a92f2017d4 (diff)
parent7b1026b1a803e160c360ee8f4d19004b466f8b7c (diff)
downloadikiwiki-82197bd0eaa216b841caace38c976acc7f6ad3fa.tar
ikiwiki-82197bd0eaa216b841caace38c976acc7f6ad3fa.tar.gz
Merge commit 'upstream/master' into prv/po
Diffstat (limited to 'IkiWiki/Plugin/table.pm')
-rw-r--r--IkiWiki/Plugin/table.pm42
1 files changed, 28 insertions, 14 deletions
diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
index 479f3d745..96d63f455 100644
--- a/IkiWiki/Plugin/table.pm
+++ b/IkiWiki/Plugin/table.pm
@@ -8,7 +8,7 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "table", call => \&getsetup);
- hook(type => "preprocess", id => "table", call => \&preprocess);
+ hook(type => "preprocess", id => "table", call => \&preprocess, scan => 1);
}
sub getsetup () {
@@ -27,13 +27,31 @@ sub preprocess (@) {
);
if (exists $params{file}) {
- if (! $pagesources{$params{file}}) {
+ if (! exists $pagesources{$params{file}}) {
error gettext("cannot find file");
}
$params{data} = readfile(srcfile($params{file}));
add_depends($params{page}, $params{file});
}
+ if (! defined wantarray) {
+ # scan mode -- if the table uses an external file, need to
+ # scan that file too.
+ return unless exists $params{file};
+
+ IkiWiki::run_hooks(scan => sub {
+ shift->(
+ page => $params{page},
+ content => $params{data},
+ );
+ });
+
+ # Preprocess in scan-only mode.
+ IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1);
+
+ return;
+ }
+
if (lc $params{format} eq 'auto') {
# first try the more simple format
if (is_dsv_data($params{data})) {
@@ -50,22 +68,18 @@ sub preprocess (@) {
defined $params{delimiter} ? $params{delimiter} : ",",);
# linkify after parsing since html link quoting can
# confuse CSV parsing
- if (! exists $params{file}) {
- @data=map {
- [ map {
- IkiWiki::linkify($params{page},
- $params{destpage}, $_);
- } @$_ ]
- } @data;
- }
+ @data=map {
+ [ map {
+ IkiWiki::linkify($params{page},
+ $params{destpage}, $_);
+ } @$_ ]
+ } @data;
}
elsif (lc $params{format} eq 'dsv') {
# linkify before parsing since wikilinks can contain the
# delimiter
- if (! exists $params{file}) {
- $params{data} = IkiWiki::linkify($params{page},
- $params{destpage}, $params{data});
- }
+ $params{data} = IkiWiki::linkify($params{page},
+ $params{destpage}, $params{data});
@data=split_dsv($params{data},
defined $params{delimiter} ? $params{delimiter} : "|",);
}