MojoMojo
view release on metacpan or search on metacpan
lib/MojoMojo/Formatter/Wiki.pm view on Meta::CPAN
=head1 METHODS
=head2 format_content_order
Format order can be 1-99. The Wiki formatter runs on 10.
=cut
sub format_content_order { 10 }
## list of start-end delimiter pairs
my @explicit_delims = (qw{ \[\[ \]\] \(\( \)\) });
my $explicit_separator = '\|';
my $wikiword_escape = qr{\\};
sub _explicit_start_delims {
my %delims = @explicit_delims;
return keys %delims;
}
lib/MojoMojo/Formatter/Wiki.pm view on Meta::CPAN
my $delims = join '|', _explicit_start_delims();
return qr{(?: $delims )}x; # non-capturing match
}
sub _generate_explicit_end {
my $delims = join '|', _explicit_end_delims();
return qr{(?: $delims )}x; # non-capturing match
}
sub _generate_explicit_path {
# non-greedily match characters that don't match the start-end and text delimiters
my $not_an_end_delimiter_or_separator = '(?:(?!' . (join '|', _explicit_end_delims(), $explicit_separator) . ').)'; # produces (?: (?! ]] | \)\) | \| ) .) # a character in a place where neither a ]], nor a )), nor a | is
return qr{$not_an_end_delimiter_or_separator+?};
}
sub _generate_explicit_text {
# non-greedily match characters that don't match the start-end delimiters
my $not_an_end_delimiter = '(?:(?!' . ( join '|', _explicit_end_delims() ) . ').)'; # produces (?: (?! ]] | \)\) ) .) # a character in a place where neither a ]] nor a )) starts
return qr{$not_an_end_delimiter+?};
}
my $explicit_start = _generate_explicit_start();
my $explicit_end = _generate_explicit_end();
my $explicit_path = _generate_explicit_path();
my $explicit_text = _generate_explicit_text();
( run in 0.251 second using v1.01-cache-2.11-cpan-4d50c553e7e )