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.
58 lines
1.4 KiB
58 lines
1.4 KiB
10 years ago
|
#!/usr/bin/env perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
|
use Test::More tests => 3;
|
||
10 years ago
|
use Text::Dokuwiki::Parser;
|
||
10 years ago
|
|
||
|
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
|
||
|
|
||
10 years ago
|
my $dw = Text::Dokuwiki::Parser->new;
|
||
|
isa_ok($dw, 'Text::Dokuwiki::Parser');
|
||
10 years ago
|
|
||
10 years ago
|
my $tree = $dw->_parse_table([ @lines ]);
|
||
|
is(ref $tree, 'ARRAY');
|
||
|
is_deeply($tree, [
|
||
10 years ago
|
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}, ':::'],
|
||
|
],
|
||
|
]);
|
||
10 years ago
|
|
||
|
exit 0;
|