Zubrikhin Alexey
10 years ago
2 changed files with 102 additions and 0 deletions
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env perl |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use utf8; |
||||
|
||||
use Test::More tests => 3; |
||||
use Text::Dokuwiki; |
||||
|
||||
my @lines = split /\n/, <<EOF; |
||||
* level1 item1 |
||||
* level1 item2 |
||||
- level2 item1 |
||||
- level2 item2 |
||||
* level2 item3 |
||||
* level1 item3 |
||||
- level1 of 2nd list, item1 |
||||
- level1 of 2nd list, item2 |
||||
EOF |
||||
|
||||
my $dw = Text::Dokuwiki->new; |
||||
isa_ok($dw, 'Text::Dokuwiki'); |
||||
my @lists = $dw->_parse_list([ @lines ]); |
||||
|
||||
is (scalar @lists, 2); |
||||
is_deeply(\@lists, [ |
||||
[ul => {}, |
||||
[li => {}, 'level1 item1'], |
||||
[li => {}, 'level1 item2'], |
||||
[li => {}, |
||||
[ol => {}, |
||||
[li => {}, 'level2 item1'], |
||||
[li => {}, 'level2 item2'], |
||||
], |
||||
], |
||||
[li => {}, |
||||
[ul => {}, |
||||
[li => {}, 'level2 item3'] |
||||
], |
||||
], |
||||
[li => {}, 'level1 item3'], |
||||
], |
||||
[ol => {}, |
||||
[li => {}, 'level1 of 2nd list, item1'], |
||||
[li => {}, 'level1 of 2nd list, item2'], |
||||
] |
||||
]); |
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env perl |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use utf8; |
||||
|
||||
use Test::More tests => 3; |
||||
use Text::Dokuwiki; |
||||
|
||||
my @lines = split /\n/, <<EOF; |
||||
| table ^ head1 ^ head2 ^ sum | |
||||
^ data1 |1-1 | 1-2 | 1-3| |
||||
^data2 | 2-1 | 2-222|2-3 | |
||||
| data3 ^ 3-1 || 3-2 | |
||||
^ data4 | 4-1 | 4-2 | ::: | |
||||
EOF |
||||
|
||||
my $dw = Text::Dokuwiki->new; |
||||
isa_ok($dw, 'Text::Dokuwiki'); |
||||
|
||||
my $table = $dw->_parse_table([ @lines ]); |
||||
is(ref $table, 'ARRAY'); |
||||
is_deeply($table, [ |
||||
table => {}, |
||||
[tr => {}, |
||||
[td => {align => 'center'}, 'table'], |
||||
[th => {align => 'center'}, 'head1'], |
||||
[th => {align => 'center'}, 'head2'], |
||||
[th => {align => 'center'}, 'sum'], |
||||
], |
||||
[tr => {}, |
||||
[th => {align => 'center'}, 'data1'], |
||||
[td => {align => 'left'}, '1-1'], |
||||
[td => {align => 'center'}, '1-2'], |
||||
[td => {align => 'right'}, '1-3'], |
||||
], |
||||
[tr => {}, |
||||
[th => {align => 'left'}, 'data2'], |
||||
[td => {align => 'center'}, '2-1'], |
||||
[td => {align => 'right'}, '2-222'], |
||||
[td => {align => 'left'}, '2-3'], |
||||
], |
||||
[tr => {}, |
||||
[td => {align => 'center'}, 'data3'], |
||||
[th => {align => 'center', colspan => 2}, '3-1'], |
||||
[td => {align => 'center', skip => 1}, ''], |
||||
[td => {align => 'center', rowspan => 2}, '3-2'], |
||||
], |
||||
[tr => {}, |
||||
[th => {align => 'center'}, 'data4'], |
||||
[td => {align => 'center'}, '4-1'], |
||||
[td => {align => 'center'}, '4-2'], |
||||
[td => {align => 'center', skip => 1}, ':::'], |
||||
], |
||||
]); |
Loading…
Reference in new issue