X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/0d108e74d9b48ba080c128407eed3c787edec1bd..683c1ebb4c510eac5bb2c2b4e85c3f7b5ded3146:/IkiWiki/Plugin/table.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm index c5404aa85..e8df17487 100644 --- a/IkiWiki/Plugin/table.pm +++ b/IkiWiki/Plugin/table.pm @@ -3,9 +3,8 @@ package IkiWiki::Plugin::table; use warnings; use strict; - -use IkiWiki; -use IkiWiki::Plugin::mdwn; +use Encode; +use IkiWiki 2.00; sub import { #{{{ hook(type => "preprocess", id => "table", call => \&preprocess); @@ -13,8 +12,8 @@ sub import { #{{{ sub preprocess (@) { #{{{ my %params =( - format => 'auto', - header => 'yes', + format => 'auto', + header => 'yes', @_ ); @@ -29,20 +28,36 @@ sub preprocess (@) { #{{{ # first try the more simple format if (is_dsv_data($params{data})) { $params{format} = 'dsv'; - $params{sep_char}->{dsv} = '|'; } else { $params{format} = 'csv'; - $params{sep_char}->{csv} = ','; } } my @data; if (lc $params{format} eq 'csv') { - @data=split_csv($params{data}, $params{delimiter}); + @data=split_csv($params{data}, + 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; + } } elsif (lc $params{format} eq 'dsv') { - @data=split_dsv($params{data}, $params{delimiter}); + # linkify before parsing since wikilinks can contain the + # delimiter + if (! exists $params{file}) { + $params{data} = IkiWiki::linkify($params{page}, + $params{destpage}, $params{data}); + } + @data=split_dsv($params{data}, + defined $params{delimiter} ? $params{delimiter} : "|",); } else { return "[[table ".gettext("unknown data format")."]]"; @@ -60,23 +75,12 @@ sub preprocess (@) { #{{{ push @lines, defined $params{class} ? "
". - htmlize($params{page}, $params{destpage}, $_). - " | " - } @$header), - "\t\t
---|
". - htmlize($params{page}, $params{destpage}, $_). - " | " - } @$record), - "\t\t