From 4cc16202a9d8f8d59cd14b656ad42807783d4cc4 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sun, 5 Jul 2015 20:48:39 +1000 Subject: [PATCH] * Text::Dokuwiki::Regexps : tune --- lib/Text/Dokuwiki/Regexps.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Text/Dokuwiki/Regexps.pm b/lib/Text/Dokuwiki/Regexps.pm index 4ae3464..730344f 100644 --- a/lib/Text/Dokuwiki/Regexps.pm +++ b/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/ (? ={2,6} ) # header marks \s* # leading spaces (?
.+? ) # 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 # 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,19 +96,25 @@ $regexps->{list} = qr/ (?: $EOL | $ ) # newline or file end )+ # one or more lines ) -$TAIL # one or more empty lines /mx; $regexps->{paragraph} = qr/ (? (?: ^ # line start - $SP ? # optional leading space - .+ # at least one symbol + $SP? # optional leading space + \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;