Browse Source

* Text::Dokuwiki::Regexps : tune

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

22
lib/Text/Dokuwiki/Regexps.pm

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

Loading…
Cancel
Save