- unshift @ret, { url => length $path ? $path : ".", page => $config{wikiname} };
- return @ret;
-} #}}}
-
-sub preprocess ($$$;$) { #{{{
- my $page=shift; # the page the data comes from
- my $destpage=shift; # the page the data will appear in (different for inline)
- my $content=shift;
- my $onlystrip=shift || 0; # strip directives without processing
-
- my $handle=sub {
- my $escape=shift;
- my $command=shift;
- my $params=shift;
- if (length $escape) {
- return "[[$command $params]]";
- }
- elsif ($onlystrip) {
- return "";
- }
- elsif (exists $hooks{preprocess}{$command}) {
- # Note: preserve order of params, some plugins may
- # consider it significant.
- my @params;
- while ($params =~ /(?:(\w+)=)?(?:"""\n?(.+)"""|"([^"]+)"|(\S+))(?:\s+|$)/sg) {
- my $val=(defined $2 ? $2 : (defined $3 ? $3 : $4));
- chomp $val;
- if (defined $1) {
- push @params, $1, $val;
- }
- else {
- push @params, $val, '';
- }
- }
- return $hooks{preprocess}{$command}{call}->(
- @params,
- page => $page,
- destpage => $destpage,
- );
- }
- else {
- return "[[$command not processed]]";
- }
- };
-
- $content =~ s{(\\?)\[\[(\w+)\s+((?:(?:\w+=)?(?:""".+"""|"[^"]+"|[^\s\]]+)\s*)*)\]\]}{$handle->($1, $2, $3)}eg;
- return $content;