Browse Source

* Text::Dokuwiki::Regexps : tune

master
Alex 'AdUser' Z 10 years ago
parent
commit
4cc16202a9
  1. 24
      lib/Text/Dokuwiki/Regexps.pm

24
lib/Text/Dokuwiki/Regexps.pm

@ -6,7 +6,6 @@ use utf8;
my $SP = '[\ \t]'; my $SP = '[\ \t]';
my $EOL = '\r?\n'; my $EOL = '\r?\n';
my $TAIL = '(?:^\s*$)*';
our $regexps = {}; our $regexps = {};
$regexps->{header} = qr/ $regexps->{header} = qr/
@ -16,11 +15,10 @@ $regexps->{header} = qr/
(?<line> ={2,6} ) # header marks (?<line> ={2,6} ) # header marks
\s* # leading spaces \s* # leading spaces
(?<header> .+? ) # header text (?<header> .+? ) # header text
\s* # trailing spaces $SP* # trailing spaces
(?: \g{line}) # header mark (exactly same as above) (?: \g{line}? ) # header mark (exactly same as above)
(?: $EOL | $) # newline or file end (?: $EOL | $) # newline or file end
) )
$TAIL
/mx; /mx;
$regexps->{codeblock} = qr% $regexps->{codeblock} = qr%
@ -49,7 +47,6 @@ $SP? # maybe one leading space
</\g{tag}> # the same tag as in first line </\g{tag}> # the same tag as in first line
$SP* # maybe any number of trailing spaces $SP* # maybe any number of trailing spaces
(?: $EOL | $) # end of last line (?: $EOL | $) # end of last line
$TAIL # one or more empty lines
%mx; %mx;
$regexps->{table} = qr/ $regexps->{table} = qr/
@ -64,7 +61,6 @@ $regexps->{table} = qr/
(?: $EOL | $ ) # newline or file end (?: $EOL | $ ) # newline or file end
)+ # one or more such lines )+ # one or more such lines
) )
$TAIL # one or more empty lines
/mx; /mx;
$regexps->{pre} = qr/ $regexps->{pre} = qr/
@ -76,7 +72,6 @@ $regexps->{pre} = qr/
(?: $EOL | $ ) # newline or file end (?: $EOL | $ ) # newline or file end
)+ # one or more lines )+ # one or more lines
) )
$TAIL # one or more empty lines
/mx; /mx;
$regexps->{blockquote} = qr/ $regexps->{blockquote} = qr/
@ -89,7 +84,6 @@ $regexps->{blockquote} = qr/
(?: $EOL | $ ) # newline or file end (?: $EOL | $ ) # newline or file end
)+ # one or more lines )+ # one or more lines
) )
$TAIL # one or more empty lines
/mx; /mx;
$regexps->{list} = qr/ $regexps->{list} = qr/
@ -102,19 +96,25 @@ $regexps->{list} = qr/
(?: $EOL | $ ) # newline or file end (?: $EOL | $ ) # newline or file end
)+ # one or more lines )+ # one or more lines
) )
$TAIL # one or more empty lines
/mx; /mx;
$regexps->{paragraph} = qr/ $regexps->{paragraph} = qr/
(?<text> (?<text>
(?: (?:
^ # line start ^ # line start
$SP ? # optional leading space $SP? # optional leading space
.+ # at least one symbol \S.* # at least one printable symbol
(?: $EOL | $ ) # newline or file end (?: $EOL | $ ) # newline or file end
)+ # one or more lines )+ # one or more lines
) )
$TAIL # one or more empty lines
/mx; /mx;
$regexps->{emptyline} = qr{
(?:
^ # line start
(?: $SP* ) # zero or more spaces
(?: $EOL | $ ) # newline or file end
)*
}mx;
1; 1;

Loading…
Cancel
Save