Browse Source

* Text::Dokuwiki::Regexps : add 'paragraph' regex and tests

master
Alex 'AdUser' Z 10 years ago
parent
commit
ab5750283f
  1. 12
      lib/Text/Dokuwiki/Regexps.pm
  2. 17
      t/regexps-misc.t

12
lib/Text/Dokuwiki/Regexps.pm

@ -97,4 +97,16 @@ $regexps->{list} = qr/
$TAIL # one or more empty lines $TAIL # one or more empty lines
/mx; /mx;
$regexps->{paragraph} = qr/
(?<text>
(?:
^ # 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; 1;

17
t/regexps-misc.t

@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use utf8; use utf8;
use Test::More tests => 10; use Test::More tests => 14;
use Text::Dokuwiki::Regexps; use Text::Dokuwiki::Regexps;
my $rx = $Text::Dokuwiki::Regexps::regexps; my $rx = $Text::Dokuwiki::Regexps::regexps;
@ -42,4 +42,19 @@ $matched = 'Header only';
is($matches[0], $matched); is($matches[0], $matched);
is($matches[1], '-------------'); 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; exit 0;

Loading…
Cancel
Save