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.

57 lines
1.4 KiB

#!/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 $tree = $dw->_parse_table([ @lines ]);
is(ref $tree, 'ARRAY');
is_deeply($tree, [
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}, ':::'],
],
]);
exit 0;