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.
88 lines
1.8 KiB
88 lines
1.8 KiB
10 years ago
|
#!/usr/bin/env perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
|
use Test::More tests => 30;
|
||
|
use Text::Dokuwiki::Regexps;
|
||
|
|
||
|
my $rx = $Text::Dokuwiki::Regexps::regexps;
|
||
|
my $text = <<'TEXT';
|
||
|
|
||
|
>> are you ok?
|
||
|
> sure!
|
||
|
> not matched
|
||
|
|
||
|
TEXT
|
||
|
|
||
|
my $matched = <<'TEXT';
|
||
|
>> are you ok?
|
||
|
> sure!
|
||
|
TEXT
|
||
|
my @matches = ($text =~ $rx->{blockquote});
|
||
|
is(scalar @matches, 1);
|
||
|
is($matches[0], $matched);
|
||
|
is($+{block}, $matched);
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
<code>
|
||
|
some code here
|
||
|
</code>
|
||
|
TEXT
|
||
|
$matched = <<'TEXT';
|
||
|
some code here
|
||
|
TEXT
|
||
|
@matches = ($text =~ $rx->{codeblock});
|
||
|
is(scalar @matches, 4);
|
||
|
is($matches[0], 'code'); # tag name
|
||
|
is($matches[1], undef); # syntax (missing)
|
||
|
is($matches[2], undef); # filename (missing)
|
||
|
is($matches[3], $matched);
|
||
|
is($+{tag}, 'code');
|
||
|
is($+{block}, $matched);
|
||
|
is($+{syntax}, undef);
|
||
|
is($+{filename}, undef);
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
<file pubkey.asc>
|
||
|
--- pgp block start ---
|
||
|
0YXRg9C5
|
||
|
--- pgp block end ---
|
||
|
</file>
|
||
|
TEXT
|
||
|
$matched = <<'TEXT';
|
||
|
--- pgp block start ---
|
||
|
0YXRg9C5
|
||
|
--- pgp block end ---
|
||
|
TEXT
|
||
|
@matches = ($text =~ $rx->{codeblock});
|
||
|
is(scalar @matches, 4);
|
||
|
is($matches[0], 'file'); # tag name
|
||
|
is($matches[1], undef); # syntax (missing)
|
||
|
is($matches[2], 'pubkey.asc'); # filename
|
||
|
is($matches[3], $matched);
|
||
|
is($+{tag}, 'file');
|
||
|
is($+{block}, $matched);
|
||
|
is($+{syntax}, undef);
|
||
|
is($+{filename}, 'pubkey.asc');
|
||
|
|
||
|
$text = <<'TEXT';
|
||
|
<code c main.c>
|
||
|
int main() { return 0; }
|
||
|
</code>
|
||
|
TEXT
|
||
|
$ matched = "int main() { return 0; }\n";
|
||
|
@matches = ($text =~ $rx->{codeblock});
|
||
|
is(scalar @matches, 4);
|
||
|
is($matches[0], 'code'); # tag name
|
||
|
is($matches[1], 'c'); # syntax
|
||
|
is($matches[2], 'main.c'); # filename
|
||
|
is($matches[3], $matched);
|
||
|
is($+{tag}, 'code');
|
||
|
is($+{block}, $matched);
|
||
|
is($+{syntax}, 'c');
|
||
|
is($+{filename}, 'main.c');
|
||
|
|
||
|
exit 0;
|