File: kake.t

package info (click to toggle)
libtext-wikiformat-perl 0.81-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 1,218; makefile: 2
file content (79 lines) | stat: -rw-r--r-- 1,693 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!perl

use strict;
use warnings;

use Test::More tests => 7;

use Text::WikiFormat as => 'wikiformat';

my $wikitext = "
WikiTest

code: foo bar baz

";

my %format_tags = (
    indent => "",  # same problem if I put qr// here
    blocks => { code => qr/^code: / },
	indented => { code => 0 },
);

my $cooked = wikiformat($wikitext, \%format_tags, {} );
like( $cooked, qr|<code>foo bar baz\n</code>|,
	'unindented code markers should still work' );

$wikitext = <<WIKI;

* foo
** bar

WIKI

%format_tags = (
	indent   => qr/^(?:\t+|\s{4,}|\*?(?=\*+))/,
	blocks   => { unordered => qr/^\s*\*+\s*/ },
	nests    => { unordered => 1 },
);

$cooked = wikiformat($wikitext, \%format_tags );

like( $cooked, qr/<li>foo/,               'first level of unordered list' );
like( $cooked, qr/<ul>.+?<li>bar<\/li>/s, 'second level of unordered list' );

$wikitext = <<WIKI;

: boing

WIKI

my @blocks = @{ $Text::WikiFormat::tags{blockorder} };
%format_tags = (
	blocks     => { definition => qr/^:\s*/ },
	indented   => { definition => 0 },
	definition => [ "<dl>\n", "</dl>\n", "<dt><dd>", "\n" ],
	blockorder => [ 'definition', @blocks ],
);

$cooked = wikiformat($wikitext, \%format_tags );
like( $cooked, qr/<dt><dd>boing/, 'definition list works' );

$wikitext =<<WIKITEXT;

==== Welcome ====

==== LinkInAHeader ====

==== Header with an = in ====

WIKITEXT

$ENV{SHOW} = 1;
$cooked = wikiformat($wikitext, {}, { prefix => 'wiki.pl?' });

like( $cooked, qr|<h4>Welcome</h4>|, 'headings work' );
like( $cooked,
      qr|<h4><a href="wiki.pl\?LinkInAHeader">LinkInAHeader</a></h4>|,
      '... links work in headers' );
like( $cooked, qr|<h4>Header with an = in</h4>|, '...headers may contain =' );