You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Test::More tests => 14;
use Text::Dokuwiki::Regexps;
my $rx = $Text::Dokuwiki::Regexps::regexps;
use re 'debugcolor';
my $text = <<'TEXT';
====== Header 1st level ======
TEXT
my $matched = 'Header 1st level';
my @matches = $text =~ m/$rx->{header}/;
is(scalar @matches, 2);
is($+{line}, '======');
is($+{header}, $matched);
is($matches[0], '======');
is($matches[1], $matched);
$text = <<'TEXT';
===== Header 2nd level =====
TEXT
$matched = 'Header 2nd level';
@matches = $text =~ m/$rx->{header}/;
is(scalar @matches, 2);
is($matches[0], '=====');
is($matches[1], $matched);
$text = "==== Header only ====";
$matched = 'Header only';
@matches = $text =~ m/$rx->{header}/;
is($matches[0], '====');
is($matches[1], $matched);
$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;