- 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+)=)?(?:"""(.+)"""|"([^"]+)"|(\S+))(?:\s+|$)/g) {
- if (defined $1) {
- push @params, $1, (defined $2 ? $2 : (defined $3 ? $3 : $4));
- }
- else {
- push @params, (defined $2 ? $2 : (defined $3 ? $3 : $4)), '';
- }
- }
- 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;