diff --git a/lib/Text/Dokuwiki/Regexps.pm b/lib/Text/Dokuwiki/Regexps.pm index cc53f4d..f28ce1c 100644 --- a/lib/Text/Dokuwiki/Regexps.pm +++ b/lib/Text/Dokuwiki/Regexps.pm @@ -97,4 +97,16 @@ $regexps->{list} = qr/ $TAIL # one or more empty lines /mx; +$regexps->{paragraph} = qr/ +(? + (?: + ^ # line start + $SP ? # optional leading space + .+ # at least one symbol + (?: $EOL | $ ) # newline or file end + )+ # one or more lines +) +$TAIL # one or more empty lines +/mx; + 1; diff --git a/t/regexps-misc.t b/t/regexps-misc.t index 8d34b6d..ccf7eaa 100644 --- a/t/regexps-misc.t +++ b/t/regexps-misc.t @@ -4,7 +4,7 @@ use strict; use warnings; use utf8; -use Test::More tests => 10; +use Test::More tests => 14; use Text::Dokuwiki::Regexps; my $rx = $Text::Dokuwiki::Regexps::regexps; @@ -42,4 +42,19 @@ $matched = 'Header only'; is($matches[0], $matched); is($matches[1], '-------------'); +$text = <<'TEXT'; + + Sample paragraph + +TEXT +$matched = " Sample paragraph\n"; +@matches = $text =~ m/$rx->{paragraph}/; +is(scalar @matches, 1); +is($matches[0], $matched); + +$text = 'Simple text line'; +@matches = $text =~ m/$rx->{paragraph}/; +is(scalar @matches, 1); +is($matches[0], $text); + exit 0;