### ----------------------------------------------------
### -- Pod::To::HTMLBody
### -- Licenses: Artistic-2.0
### -- Authors: Jeffrey Goff <drforr@pobox.com>
### -- File: t/01-tree.t
### ----------------------------------------------------
### -- Chunk 1 of 2
use v6;
use Pod::To::Tree;
use Pod::To::HTMLBody;
use Test;

subtest 'tree manipulation', {
	my $item = Node::Item.new;

	my $new-list = Node::List.new;
	$new-list.add-below( $item );

	subtest 'links from new-list', {
		nok $new-list.parent;
		nok $new-list.previous-sibling;
		nok $new-list.next-sibling;
		is $new-list.first-child, $item;
	};

	subtest 'links from item', {
		is $item.parent, $new-list;
		nok $item.previous-sibling;
		nok $item.next-sibling;
		nok $item.first-child;
	};

	my $new-item = Node::Item.new;
	$item.replace-with( $new-item );

	subtest 'new-list after replacing item', {
		nok $new-list.parent;
		nok $new-list.previous-sibling;
		nok $new-list.next-sibling;
		is $new-list.first-child, $new-item;

	};

	subtest 'new-item after being emplaced', {
		is $new-item.parent, $new-list;
		nok $new-item.previous-sibling;
		nok $new-item.next-sibling;
		nok $new-item.first-child;
	};

	my $item2 = Node::Item.new;
	$new-list.add-below( $item2 );

	subtest 'new-list after adding $item2', {
		nok $new-list.parent;
		nok $new-list.previous-sibling;
		nok $new-list.next-sibling;
		is $new-list.first-child, $new-item;
	};

	# Root <-
	#  | |   \
	#  V V   /
	# List -  <-
	#  | |      \
	#  V V      /
	# Item
	#  | |
	#  V V
	#  X X

	my $the-root = Node::Document.new;
	my $the-item = Node::Item.new;
	my $the-list = Node::List.new;
	$the-root.add-below( $the-list );
	$the-list.add-below( $the-item );

	subtest 'root', {
		nok $the-root.parent;
		nok $the-root.previous-sibling;
		nok $the-root.next-sibling;
		is $the-root.first-child, $the-list;
	};
	subtest 'list', {
		is $the-list.parent, $the-root;
		nok $the-list.previous-sibling;
		nok $the-list.next-sibling;
		is $the-list.first-child, $the-item;
	};
	subtest 'item', {
		is $the-item.parent, $the-list;
		nok $the-item.previous-sibling;
		nok $the-item.next-sibling;
		nok $the-item.first-child;
	};
};

my $pod-counter = 0;
my $root;
my $r;

subtest 'paragraphs', {

=begin pod
Lorem ipsum
=end pod

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<div>'
			'<p>' 'Lorem ipsum' '</p>'
		'</div>'
	/, 'simple paragraph';

=begin pod

someone accidentally left a space
 
between these two paragraphs

=end pod

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<p>' 'someone accidentally left a space' '</p>'
		'<p>' 'between these two paragraphs' '</p>'
	/, 'paragraph break';

=for foo
some text

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'some text' '</p>'
		'</section>'
	/, 'paragraph with body';

=for foo
some
spaced   text

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'some spaced text' '</p>'
		'</section>'
	/, 'spacing';
};

subtest 'section', {
=begin foo
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
		'</section>'
	/, 'section';

=begin foo
Some content
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'Some content' '</p>'
		'</section>'
	/, 'section wih content';

=begin foo
Some content
over two lines
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'Some content over two lines' '</p>'
		'</section>'
	/, 'section wih content over two lines';

=begin foo
paragraph one

paragraph
two
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'paragraph one' '</p>'
			'<p>' 'paragraph two' '</p>'
		'</section>'
	/, 'two paragraphs';

=begin something
    =begin somethingelse
    toot tooot!
    =end somethingelse
=end something

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
		'<section>'
			'<h1>' 'something' '</h1>'
			'<section>'
				'<h1>' 'somethingelse' '</h1>'
				'<p>' 'toot tooot!' '</p>'
			'</section>'
		'</section>'
	/, 'nested section';

=begin foo
and so,  all  of  the  villages chased
Albi,   The   Racist  Dragon, into the
very   cold   and  very  scary    cave

and it was so cold and so scary in
there,  that  Albi  began  to  cry

    =begin bar
    Dragon Tears!
    =end bar

Which, as we all know...

    =begin bar
    Turn into Jelly Beans!
    =end bar
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
			'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
			'<section>'
				'<h1>' 'bar' '</h1>'
				'<p>' 'Dragon Tears!' '</p>'
			'</section>'
			'<p>' 'Which, as we all know...' '</p>'
			'<section>'
				'<h1>' 'bar' '</h1>'
				'<p>' 'Turn into Jelly Beans!' '</p>'
			'</section>'
		'</section>'
	/, 'Mixed sections and paragraphs';

=begin something
    =begin somethingelse
    toot tooot!
    =end somethingelse
=end something

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'something' '</h1>'
			'<section>'
				'<h1>' 'somethingelse' '</h1>'
				'<p>' 'toot tooot!' '</p>'
			'</section>'
		'</section>'
	/, 'regression test';

=begin kwid

= DESCRIPTION
bla bla

foo
=end kwid

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'kwid' '</h1>'
			'<p>' '= DESCRIPTION bla bla' '</p>'
			'<p>' 'foo' '</p>'
		'</section>'
	/, 'broken meta tag';

=begin more-discussion-needed

XXX: chop(@array) should return an array of chopped strings?
XXX: chop(%has)   should return a  hash  of chopped strings?

=end more-discussion-needed

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'more-discussion-needed' '</h1>'
			'<p>' 'XXX: chop(@array) should return an array of chopped strings? XXX: chop(%has) should return a hash of chopped strings?' '</p>'
		'</section>'
	/, 'playing with line breaks';

=for foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
		'</section>'
	/, 'hanging section';

# tests without Albi would still be tests, but definitely very, very sad
# also, Albi without paragraph blocks wouldn't be the happiest dragon
# either
=begin foo
and so,  all  of  the  villages chased
Albi,   The   Racist  Dragon, into the
very   cold   and  very  scary    cave

and it was so cold and so scary in
there,  that  Albi  began  to  cry

    =for bar
    Dragon Tears!

Which, as we all know...

    =for bar
    Turn into Jelly Beans!
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
			'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
			'<section>'
				'<h1>' 'bar' '</h1>'
				'<p>' 'Dragon Tears!' '</p>'
			'</section>'
			'<p>' 'Which, as we all know...' '</p>'
			'<section>'
				'<h1>' 'bar' '</h1>'
				'<p>' 'Turn into Jelly Beans!' '</p>'
			'</section>'
		'</section>'
	/, 'nested blocks';

=foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
		'</section>'
	/, 'hanging block';

=foo some text

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'some text' '</p>'
		'</section>'
	/, 'hanging block with paragraph';

=foo some text
and some more

# Yes, 'some text' and 'and some more' are in the same paragraph block, no
# way to know if they've been broken up.
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'some text and some more' '</p>'
		'</section>'
	/, 'hanging block with multi-line paragraph';

=begin foo
and so,  all  of  the  villages chased
Albi,   The   Racist  Dragon, into the
very   cold   and  very  scary    cave

and it was so cold and so scary in
there,  that  Albi  began  to  cry

    =bold Dragon Tears!

Which, as we all know...

    =bold Turn
          into
          Jelly
          Beans!
=end foo

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'foo' '</h1>'
			'<p>' 'and so, all of the villages chased Albi, The Racist Dragon, into the very cold and very scary cave' '</p>'
			'<p>' 'and it was so cold and so scary in there, that Albi began to cry' '</p>'
			'<section>'
				'<h1>' 'bold' '</h1>'
				'<p>' 'Dragon Tears!' '</p>'
			'</section>'
			'<p>' 'Which, as we all know...' '</p>'
			'<section>'
				'<h1>' 'bold' '</h1>'
				'<p>' 'Turn into Jelly Beans!' '</p>'
			'</section>'
		'</section>'
	/, 'nested paragraphs';

=table_not
    Constants 1
    Variables 10
    Subroutines 33
    Everything else 57

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<section>'
			'<h1>' 'table_not' '</h1>'
			'<p>' 'Constants 1 Variables 10 Subroutines 33 Everything else 57' '</p>'
		'</section>'
	/, 'S26 counterexample - not a table';
};

subtest 'table', {
#`(
=table
+-----+----+---+
|   a | b  | c |
+-----+----+---+
| foo | 52 | Y |
| bar | 17 | N |
|  dz | 9  | Y |
+-----+----+---+

	# Check out the raw pod if you don't believe me, this is a set of single
	# rows.
	#
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
			'<tr>' '<td>' '| a | b | c |'    '</td>' '</tr>'
			'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
			'<tr>' '<td>' '| foo | 52 | Y |' '</td>' '</tr>'
			'<tr>' '<td>' '| bar | 17 | N |' '</td>' '</tr>'
			'<tr>' '<td>' '| dz | 9 | Y |'   '</td>' '</tr>'
			'<tr>' '<td>' '+-----+----+---+' '</td>' '</tr>'
		'</table>'
	/, 'RT #124403 - incorrect table parse';
)

#`(
=begin table
a | b | c
l | m | n
x | y
=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'a' '</td>'
				'<td>' 'b' '</td>'
				'<td>' 'c' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'l' '</td>'
				'<td>' 'm' '</td>'
				'<td>' 'n' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'x' '</td>'
				'<td>' 'y' '</td>'
			'</tr>'
		'</table>'
	/, 'RT #129862 short row';
)

#`(
=table
    X   O
   ===========
        X   O
   ===========
            X

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'X' '</td>'
				'<td>' 'O' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '</td>'
				'<td>' 'X' '</td>'
				'<td>' 'O' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '</td>'
				'<td>' '</td>'
				'<td>' 'X' '</td>'
			'</tr>'
		'</table>'
	/, 'RT #132341 rows, also #129862';
)

#`(
# XXX The 'Z<..>' aren't being parsed by Perl...
# also tests fix for RT #129862
=begin table
a | b | c
l | m | n
x | y      Z<a comment> Z<another comment>
=end table

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<table>'
		'<tr>'
			'<td>' 'a' '</td>'
			'<td>' 'b' '</td>'
			'<td>' 'c' '</td>'
		'</tr>'
		'<tr>'
			'<td>' 'l' '</td>'
			'<td>' 'm' '</td>'
			'<td>' 'n' '</td>'
		'</tr>'
		'<tr>'
			'<td>' 'x' '</td>'
			'<td>' 'y Z<a comment> Z<another comment>' '</td>'
		'</tr>'
	'</table>'
/, 'RT #132348 allow inline Z<> comments';
)

=begin table
a
=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'a' '</td>'
			'</tr>'
		'</table>'
	/, 'single-column table';

=begin table
b
-
a
=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'b' '</td>'
			'</th>'
			'<tr>'
				'<td>' 'a' '</td>'
			'</tr>'
		'</table>'
	/, 'single-column table with header';

#`(
# need to handle table cells with char column separators as data
# example table from <https://docs.perl6.org/language/regexes>
# WITHOUT the escaped characters (results in an extra, unwanted, incorrect column)
=begin table

    Operator  |  Meaning
    ==========+=========
     +        |  set union
     |        |  set union
     &        |  set intersection
     -        |  set difference (first minus second)
     ^        |  symmetric set intersection / XOR

=end table

	# XXX '&' needs to be escaped, among others probably.
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Operator' '</td>'
				'<td>' 'Meaning' '</td>'
			'</th>'
			'<tr>'
				'<td>' '+' '</td>'
				'<td>' 'set union' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '</td>'
				'<td>' '</td>'
				'<td>' 'set union' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '&' '</td>'
				'<td>' 'set intersection' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '-' '</td>'
				'<td>' 'set difference (first minus second)' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '^' '</td>'
				'<td>' 'symmetric set intersection / XOR' '</td>'
			'</tr>'
		'</table>'
	/, '#1282 header, entities and gaps';
)

#`(
# WITHOUT the escaped characters and without the non-breaking spaces
# (results in the desired table)
=begin table

    Operator  |  Meaning
    ==========+=========
    +       |  set union
    |       |  set union
    &       |  set intersection
    -       |  set difference (first minus second)
    ^       |  symmetric set intersection / XOR

=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Operator' '</td>'
				'<td>' 'Meaning' '</td>'
			'</th>'
			'<tr>'
				'<td>' '+ &' '</td>'
				'<td>' 'set union set intersection' '</td>'
				'<td>' 'set union' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '^' '</td>'
				'<td>' 'symmetric set intersection / XOR' '</td>'
			'</tr>'
		'</table>'
	/, 'escaped characters';
)

#`(
# WITH the escaped characters (results in the desired table)
=begin table

    Operator  |  Meaning
    ==========+=========
     \+        |  set union
     \|        |  set union
     &        |  set intersection
     -        |  set difference (first minus second)
     ^        |  symmetric set intersection / XOR

=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Operator' '</td>'
				'<td>' 'Meaning' '</td>'
			'</th>'
			'<tr>'
				'<td>' '\\+' '</td>'
				'<td>' 'set union' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '\\|' '</td>'
				'<td>' 'set union' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '&' '</td>'
				'<td>' 'set intersection' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '-' '</td>'
				'<td>' 'set difference (first minus second)' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '^' '</td>'
				'<td>' 'symmetric set intersection / XOR' '</td>'
			'</tr>'
		'</table>'
	/, 'escaped, and some non-breaking spaces';
)

#`(
# WITH the escaped characters but without the non-breaking spaces
# (results in the desired table)

=begin table

    Operator  |  Meaning
    ==========+=========
    \+       |  set union
    \|       |  set union
    &       |  set intersection
    -       |  set difference (first minus second)
    ^       |  symmetric set intersection / XOR

=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Operator' '</td>'
				'<td>' 'Meaning' '</td>'
			'</th>'
			'<tr>'
				'<td>' '\\+ \\| &' '</td>'
				'<td>' 'set union set union set intersection' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '^' '</td>'
				'<td>' 'symmetric set intersection / XOR' '</td>'
			'</tr>'
		'</table>'
	/, 'escaped, no non-breaking spaces';
)

=begin table
        The Shoveller   Eddie Stevens     King Arthur's singing shovel
        Blue Raja       Geoffrey Smith    Master of cutlery
        Mr Furious      Roy Orson         Ticking time bomb of fury
        The Bowler      Carol Pinnsler    Haunted bowling ball
=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'The Shoveller' '</td>'
				'<td>' 'Eddie Stevens' '</td>'
				'<td>' 'King Arthur\'s singing shovel' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Blue Raja' '</td>'
				'<td>' 'Geoffrey Smith' '</td>'
				'<td>' 'Master of cutlery' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Mr Furious' '</td>'
				'<td>' 'Roy Orson' '</td>'
				'<td>' 'Ticking time bomb of fury' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'The Bowler' '</td>'
				'<td>' 'Carol Pinnsler' '</td>'
				'<td>' 'Haunted bowling ball' '</td>'
			'</tr>'
		'</table>'
	/, 'simple table';

=table
    Constants           1
    Variables           10
    Subroutines         33
    Everything else     57

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<table>'
		'<tr>'
			'<td>' 'Constants' '</td>'
			'<td>' '1' '</td>'
		'</tr>'
		'<tr>'
			'<td>' 'Variables' '</td>'
			'<td>' '10' '</td>'
		'</tr>'
		'<tr>'
			'<td>' 'Subroutines' '</td>'
			'<td>' '33' '</td>'
		'</tr>'
		'<tr>'
			'<td>' 'Everything else' '</td>'
			'<td>' '57' '</td>'
		'</tr>'
	'</table>'
/, 'simple two-column table';

=for table
    mouse    | mice
    horse    | horses
    elephant | elephants

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'mouse' '</td>'
				'<td>' 'mice' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'horse' '</td>'
				'<td>' 'horses' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'elephant' '</td>'
				'<td>' 'elephants' '</td>'
			'</tr>'
		'</table>'
	/, 'two-column table, no header';

=table
    Animal | Legs |    Eats
    =======================
    Zebra  +   4  + Cookies
    Human  +   2  +   Pizza
    Shark  +   0  +    Fish

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Animal' '</td>'
				'<td>' 'Legs' '</td>'
				'<td>' 'Eats' '</td>'
			'</th>'
			'<tr>'
				'<td>' 'Zebra' '</td>'
				'<td>' '4' '</td>'
				'<td>' 'Cookies' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Human' '</td>'
				'<td>' '2' '</td>'
				'<td>' 'Pizza' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Shark' '</td>'
				'<td>' '0' '</td>'
				'<td>' 'Fish' '</td>'
			'</tr>'
		'</table>'
	/, 'hanging table';

=table
        Superhero     | Secret          |
                      | Identity        | Superpower
        ==============|=================|================================
        The Shoveller | Eddie Stevens   | King Arthur's singing shovel

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Superhero' '</td>'
				'<td>' 'Secret Identity' '</td>'
				'<td>' 'Superpower' '</td>'
			'</th>'
			'<tr>'
				'<td>' 'The Shoveller' '</td>'
				'<td>' 'Eddie Stevens' '</td>'
				'<td>' "King Arthur's singing shovel" '</td>'
			'</tr>'
		'</table>'
	/, 'hanging table with multiline header';

=begin table

                        Secret
        Superhero       Identity          Superpower
        =============   ===============   ===================
        The Shoveller   Eddie Stevens     King Arthur's
                                          singing shovel

        Blue Raja       Geoffrey Smith    Master of cutlery

        Mr Furious      Roy Orson         Ticking time bomb
                                          of fury

        The Bowler      Carol Pinnsler    Haunted bowling ball

=end table

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<th>'
				'<td>' 'Superhero' '</td>'
				'<td>' 'Secret Identity' '</td>'
				'<td>' 'Superpower' '</td>'
			'</th>'
			'<tr>'
				'<td>' 'The Shoveller' '</td>'
				'<td>' 'Eddie Stevens' '</td>'
				'<td>' "King Arthur's singing shovel" '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Blue Raja' '</td>'
				'<td>' 'Geoffrey Smith' '</td>'
				'<td>' 'Master of cutlery' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Mr Furious' '</td>'
				'<td>' 'Roy Orson' '</td>'
				'<td>' 'Ticking time bomb of fury' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'The Bowler' '</td>'
				'<td>' 'Carol Pinnsler' '</td>'
				'<td>' 'Haunted bowling ball' '</td>'
			'</tr>'
		'</table>'
	/, 'table with == separators';

=table
    X | O |
   ---+---+---
      | X | O
   ---+---+---
      |   | X

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'X' '</td>'
				'<td>' 'O' '</td>'
				'<td>' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '</td>'
				'<td>' 'X' '</td>'
				'<td>' 'O' '</td>'
			'</tr>'
			'<tr>'
				'<td>' '</td>'
				'<td>' '</td>'
				'<td>' 'X' '</td>'
			'</tr>'
		'</table>'
	/, 'tic-tac-toe with empty squares';

# test for:
#   RT #126740 - Pod::Block::Table node caption property is not populated properly
# Note that the caption property is just one of the table's %config key/value
# pairs so any tests for other config keys in a single table are usually the same as testing
# multiple tables, each for one caption test.
=begin table :caption<foo> :bar(0)

foo
bar

=end table

	$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
	isa-ok $root, Node::Table;
	is $root.config.<bar>, 0;
	# XXX This is wrong. There's a .caption available, it should be used.
	is $root.config.<caption>, 'foo';
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<table>'
			'<tr>'
				'<td>' 'foo' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'bar' '</td>'
			'</tr>'
		'</table>'
	/, 'RT #126740 caption propery';
};

subtest 'item', {
=item foo

	# Isn't part of the Roast suite, but I need it to check some edge cases.
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<li>' 'foo' '</li>'
	/, 'standalone item';

=begin pod
=item foo
=item bar
=end pod

	# Isn't part of the Roast suite, but I need it to check some edge cases.
	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<div>'
			'<li>' 'foo' '</li>'
			'<li>' 'bar' '</li>'
		'</div>'
	/, 'items';

=begin pod
The seven suspects are:

=item  Happy
=item  Dopey
=item  Sleepy
=item  Bashful
=item  Sneezy
=item  Grumpy
=item  Keyser Soze
=end pod

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<div>'
			'<p>' 'The seven suspects are:' '</p>'
			'<li>' 'Happy' '</li>'
			'<li>' 'Dopey' '</li>'
			'<li>' 'Sleepy' '</li>'
			'<li>' 'Bashful' '</li>'
			'<li>' 'Sneezy' '</li>'
			'<li>' 'Grumpy' '</li>'
			'<li>' 'Keyser Soze' '</li>'
		'</div>'
	/, 'one-level list';

#`(
=begin pod
=item1  Animal
=item2     Vertebrate
=item2     Invertebrate

=item1  Phase
=item2     Solid
=item2     Liquid
=item2     Gas
=item2     Chocolate
=end pod

	like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
		'<li>' 'Animal' '</li>'
		'<ul>'
			'<li>' 'Vertebrate' '</li>'
			'<li>' 'Invertebrate' '</li>'
		'</ul>'
		'<li>' 'Phase' '</li>'
		'<ul>'
			'<li>' 'Solid' '</li>'
			'<li>' 'Liquid' '</li>'
			'<li>' 'Gas' '</li>'
			'<li>' 'Chocolate' '</li>'
		'</ul>'
	/, 'nested lists';
)

#`(
=begin pod
=comment CORRECT...
=begin item1
The choices are:
=end item1
=item2 Liberty
=item2 Death
=item2 Beer
=item2 Cake
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
1
/;
)
};

=begin pod
sample paragraph
=begin table

                        Secret
        Superhero       Identity          Superpower
        =============   ===============   ===================
        The Shoveller   Eddie Stevens     King Arthur's
                                          singing shovel

        Blue Raja       Geoffrey Smith    Master of cutlery

        Mr Furious      Roy Orson         Ticking time bomb
                                          of fury

        The Bowler      Carol Pinnsler    Haunted bowling ball

=end table

=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>' 'sample paragraph' '</p>'
		'<table>'
			'<th>'
				'<td>' 'Superhero' '</td>'
				'<td>' 'Secret Identity' '</td>'
				'<td>' 'Superpower' '</td>'
			'</th>'
			'<tr>'
				'<td>' 'The Shoveller' '</td>'
				'<td>' 'Eddie Stevens' '</td>'
				'<td>' "King Arthur's singing shovel" '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Blue Raja' '</td>'
				'<td>' 'Geoffrey Smith' '</td>'
				'<td>' 'Master of cutlery' '</td>'
			'</tr>'
			'<tr>'
				'<td>' 'Mr Furious' '</td>'
				'<td>' 'Roy Orson' '</td>'
				'<td>' 'Ticking time bomb of fury' '</td>'
			'</tr>'
			'<tr>'
				