7 \[\[(!?) # directive open; 2: optional prefix
9 ( # 4: the parameters (including initial whitespace)
12 (?:[-\w]+=)? # named parameter key?
14 """.*?""" # triple-quoted value
16 "[^"]+" # single-quoted value
18 [^\s\]]+ # unquoted value
20 \s* # whitespace or end
23 *) # 0 or more parameters
24 \]\] # directive closed
27 sub handle_directive {
30 my $directive = shift;
34 return "${escape}[[${prefix}${directive}${args}]]"
36 if ($directive =~ m/^(if|more|table|template|toggleable)$/) {
37 $args =~ s{$regex}{handle_directive($1, $2, $3, $4)}eg;
39 return "[[!${directive}${args}]]"
42 sub prefix_directives {
43 $/=undef; # process whole files at once
46 s{$regex}{handle_directive($1, $2, $3, $4)}eg;
52 print STDERR "Usage: ikiwiki-transition type file ...\n";
53 print STDERR "Currently supported transition types:\n";
54 print STDERR " prefix_directives\n";
61 if ($mode eq 'prefix_directives') {
62 prefix_directives(@ARGV);