- $content =~ s{(\\?)\[\[(\w+)\s+((?:(?:\w+=)?(?:""".*?"""|"[^"]+"|[^\s\]]+)\s*)*)\]\]}{$handle->($1, $2, $3)}seg;
+ $content =~ s{
+ (\\?) # 1: escape?
+ \[\[ # directive open
+ (\w+) # 2: command
+ \s+
+ ( # 3: the parameters..
+ (?:
+ (?:\w+=)? # named parameter key?
+ (?:
+ """.*?""" # triple-quoted value
+ |
+ "[^"]+" # single-quoted value
+ |
+ [^\s\]]+ # unquoted value
+ )
+ \s* # whitespace or end
+ # of directive
+ )
+ *) # 0 or more parameters
+ \]\] # directive closed
+ }{$handle->($1, $2, $3)}sexg;