### ----------------------------------------------------
### -- Pod::To::HTMLBody
### -- Licenses: Artistic-2.0
### -- Authors: Jeffrey Goff <drforr@pobox.com>
### -- File: t/01-tree.t
### ----------------------------------------------------
### -- Chunk 2 of 2
'<td>' 'The Bowler' '</td>'
				'<td>' 'Carol Pinnsler' '</td>'
				'<td>' 'Haunted bowling ball' '</td>'
			'</tr>'
		'</table>'
	'</div>'
/, 'paragraph and complex table';

# various things which caused the spectest to fail at some point


=begin pod
    =head1 This is a heading block

    This is an ordinary paragraph.
    Its text  will   be     squeezed     and
    short lines filled. It is terminated by
    the first blank line.

    This is another ordinary paragraph.
    Its     text    will  also be squeezed and
    short lines filled. It is terminated by
    the trailing directive on the next line.
        =head2 This is another heading block

        This is yet another ordinary paragraph,
        at the first virtual column set by the
        previous directive
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<h1>'
			'<p>' 'This is a heading block' '</p>'
		'</h1>'
		'<p>' 'This is an ordinary paragraph. Its text will be squeezed and short lines filled. It is terminated by the first blank line.' '</p>'
		'<p>' 'This is another ordinary paragraph. Its text will also be squeezed and short lines filled. It is terminated by the trailing directive on the next line.' '</p>'
		'<h2>'
			'<p>' 'This is another heading block' '</p>'
		'</h2>'
		'<p>' 'This is yet another ordinary paragraph, at the first virtual column set by the previous directive' '</p>'
	'</div>'
/, 'headings with indentations';

=begin pod

=for got
Inside got

    =for bidden
    Inside bidden

Outside blocks
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<section>'
			'<h1>' 'got' '</h1>'
			'<p>' 'Inside got' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'bidden' '</h1>'
			'<p>' 'Inside bidden' '</p>'
		'</section>'
		'<p>' 'Outside blocks' '</p>'
	'</div>'
/, 'nested blocks';

# mixed blocks
=begin pod
=begin one
one, delimited block
=end one
=for two
two, paragraph block
=for three
three, still a parablock

=begin four
four, another delimited one
=end four
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<section>'
			'<h1>' 'one' '</h1>'
			'<p>' 'one, delimited block' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'two' '</h1>'
			'<p>' 'two, paragraph block' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'three' '</h1>'
			'<p>' 'three, still a parablock' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'four' '</h1>'
			'<p>' 'four, another delimited one' '</p>'
		'</section>'
	'</div>'
/, 'multiple blocks';

# Without the =begin..=end directives here, each =for is its own directive.
# It might not quite be in the spirit of the test, XXX
#
=begin pod
=for pod
=for nested
=for para :nested(1)
E<a;b>E<a;b;c>
♥♥♥
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<div>' '</div>'
		'<section>'
			'<h1>' 'nested' '</h1>'
		'</section>'
		'<section>'
			'<h1>' 'para' '</h1>'
			'<p>' 'a ba b c ♥♥♥' '</p>'
		'</section>'
	'</div>'
/, 'RT #131400';

=begin pod

=got Inside
got

=bidden Inside
bidden

Outside blocks
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<section>'
			'<h1>' 'got' '</h1>'
			'<p>' 'Inside got' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'bidden' '</h1>'
			'<p>' 'Inside bidden' '</p>'
		'</section>'
		'<p>' 'Outside blocks' '</p>'
	'</div>'
/, 'multiple blocks';

# mixed blocks
=begin pod
    =begin one
    one, delimited block
    =end one
    =two two,
    paragraph block
    =for three
    three, still a parablock

    =begin four
    four, another delimited one
    =end four
    =head1 And just for the sake of having a working =head1 :)
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<section>'
			'<h1>' 'one' '</h1>'
			'<p>' 'one, delimited block' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'two' '</h1>'
			'<p>' 'two, paragraph block' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'three' '</h1>'
			'<p>' 'three, still a parablock' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'four' '</h1>'
			'<p>' 'four, another delimited one' '</p>'
		'</section>'
		'<h1>'
			'<p>' 'And just for the sake of having a working =head1 :)' '</p>'
		'</h1>'
	'</div>'
/, 'mixed contents';

=head3
Heading level 3

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<h3>'
		'<p>' 'Heading level 3' '</p>'
	 '</h3>'
/, 'heading';

=begin pod
This ordinary paragraph introduces a code block:

    $this = 1 * code('block');
    $which.is_specified(:by<indenting>);

    $which.spans(:newlines);

=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<p>' 'This ordinary paragraph introduces a code block:' '</p>'
	'<code>' "\$this = 1 * code('block');
\$which.is_specified(:by<indenting>);

\$which.spans(:newlines);" '</code>'
/, 'indented code';

# more fancy code blocks
=begin pod
This is an ordinary paragraph

    While this is not
    This is a code block

    =head1 Mumble mumble

    Suprisingly, this is not a code block
        (with fancy indentation too)

But this is just a text. Again

=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'<div>'
		'<p>' 'This is an ordinary paragraph' '</p>'
		'<code>' 'While' .+ 'block' '</code>' # XXX look into this
		'<h1>'
			'<p>' 'Mumble mumble' '</p>'
		'</h1>'
		'<p>' 'Suprisingly, this is not a code block (with fancy indentation too)' '</p>'
		'<p>' 'But this is just a text. Again' '</p>'
	'</div>'
/, 'mixed block types';

=begin pod

Tests for the feed operators

    ==> and <==
    
=end pod

# XXX Check to see if entities need to be decoded here.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<p>' 'Tests for the feed operators' '</p>'
	'<code>' '==> and <==' '</code>'
/, 'entities';

=begin pod
Fun comes

    This is code
  Ha, what now?

 one more block of code
 just to make sure it works
  or better: maybe it'll break!
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<p>' 'Fun comes' '</p>'
	'<code>' 'This is code' '</code>'
	'<code>' 'Ha, what now?' '</code>'
	'<code>' 'one more block of code
just to make sure it works
 or better: maybe it\'ll break!' '</code>'
/, 'multi-line code block';

=begin pod

=head1 A heading

This is Pod too. Specifically, this is a simple C<para> block

    $this = pod('also');  # Specifically, a code block

=end pod

# XXX The code with '$this...' needs to be fixed.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<h1>'
			'<p>' 'A heading' '</p>'
		'</h1>'
		'<p>' 'This is Pod too. Specifically, this is a simple '
			'<code>' 'para' '</code>'
#			' block'
#		'</p>'
#		'<code>'
#			'\$this = pod(\'also\');  # Specifically, a code block'
#		'</code>'
#	'</div>'
/, 'complex code block';

=begin pod
    this is code

    =for podcast
        this is not

    this is not code either

    =begin itemization
        this is not
    =end itemization

    =begin quitem
        and this is not
    =end quitem

    =begin item
        and this is!
    =end item
=end pod

# Note that <li> <code/> </li> is intentional here because of the indent.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<code>' 'this is code' '</code>'
		'<section>'
			'<h1>' 'podcast' '</h1>'
			'<p>' 'this is not' '</p>'
		'</section>'
		'<p>' 'this is not code either' '</p>'
		'<section>'
			'<h1>' 'itemization' '</h1>'
			'<p>' 'this is not' '</p>'
		'</section>'
		'<section>'
			'<h1>' 'quitem' '</h1>'
			'<p>' 'and this is not' '</p>'
		'</section>'
		'<li>' '<code>' 'and this is!' '</code>' '</li>'
	'</div>'
/, 'mixed code and one hidden in an item';

=begin code
    foo foo
    =begin code
    =end code
=end code

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'<code>'
		'foo foo
    =begin code
    =end code'
	'</code>'
/, 'embedded pseudo-pod';

=begin pod
=for comment
foo foo
bla bla    bla

This isn't a comment
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'<div>'
		'<!--' 'foo foo' 'bla bla    bla' '-->'
		'<p>' 'This isn\'t a comment' '</p>'
	'</div>'
/, 'paragraph comment';

=comment
This file is deliberately specified in Perl 6 Pod format

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'<!--'
		'This file is deliberately specified in Perl 6 Pod format'
	'-->'
/, 'S26 counterexample - hanging comment';

# this happens to break hilighting in some editors,
# so I put it at the end
=begin comment
foo foo
=begin invalid pod
=as many invalid pod as we want
===yay!
=end comment

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'<!--'
		'foo foo'
		'=begin invalid pod'
		'=as many invalid pod as we want'
		'===yay!'
	'-->'
/, 'delimited comment';

# XXX Those items are :numbered in S26, but we're waiting with block
# configuration until we're inside Rakudo, otherwise we'll have to
# pretty much implement Pair parsing in gsocmess only to get rid of
# it later.

=begin pod
Let's consider two common proverbs:

=begin item
I<The rain in Spain falls mainly on the plain.>

This is a common myth and an unconscionable slur on the Spanish
people, the majority of whom are extremely attractive.
=end item

=begin item
I<The early bird gets the worm.>

In deciding whether to become an early riser, it is worth
considering whether you would actually enjoy annelids
for breakfast.
=end item

As you can see, folk wisdom is often of dubious value.
=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>' "Let's consider two common proverbs:" '</p>'
		'<li>'
			'<i>' 'The rain in Spain falls mainly on the plain.' '</i>'
			'This is a common myth and an unconscionable slur on the Spanish people, the majority of whom are extremely attractive.'
		'</li>'
		'<li>'
			'<i>' 'The early bird gets the worm.' '</i>'
			'In deciding whether to become an early riser, it is worth considering whether you would actually enjoy annelids for breakfast.'
		'</li>'
		'<p>' 'As you can see, folk wisdom is often of dubious value.' '</p>'
	'</div>'
/, 'compound mixed content';

# includes tests for fixes for RT bugs:
#   124403 - incorrect table parse:
#   129862 - uneven rows
#   132341 - pad rows to add empty cells to ensure all rows have same number of cells

=pod
B<I am a formatting code>

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<b>' 'I am a formatting code' '</b>'
/, 'inline bold';

=pod
I<Render unto Caesar in italic>

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<i>' 'Render unto Caesar in italic' '</i>'
/, 'inline italic';

=pod
U<Ignore this!>

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<u>' 'Ignore this!' '</u>'
/, 'inline underline';

=pod
The basic C<ln> command is: C<ln> B<R<source_file> R<target_file>>

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /:s
	'The basic'
	'<code>' 'ln' '</code>'
	'command is:'
	'<code>' 'ln' '</code>'
	'<b>'
		'<var>' 'source_file' '</var>'
		'<var>' 'target_file' '</var>'
	'</b>'
/, 'inline code and references';

=pod
L<C<b>|a>
L<C<b>|a>

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>'
			'<a href="a">' '<code>' 'b' '</code>' '</a>'
			' '
			'<a href="a">' '<code>' 'b' '</code>' '</a>'
		'</p>'
	'</div>'
/, 'links';

=begin pod

=head1 A heading

This is Pod too. Specifically, this is a simple C<para> block

    $this = pod('also');  # Specifically, a code block

=end pod

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<h1>'
			'<p>' 'A heading' '</p>'
		'</h1>'
		'<p>'
			'This is Pod too. Specifically, this is a simple '
			'<code>' 'para' '</code>'
			' block'
		'</p>'
		'<code>'
			'$this = pod(\'also\');  # Specifically, a code block'
		'</code>'
	'</div>'
/, 'mixture';

=pod V<C<boo> B<bar> asd>

# Note that V<> doesn't generate its own POD node.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>' 'C<boo> B<bar> asd' '</p>'
	'</div>'
/, 'invisible verbatim';

=pod C< infix:<+> >
=pod C<< infix:<+> >>

# XXX Needs to be translated.
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>'
			'<code>' 'infix:<+> ' '</code>'
		'</p>'
	'</div>'
/, 'inline <>';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<p>'
			'<code>' 'infix:<+> ' '</code>'
		'</p>'
	'</div>'
/, 'RT #114510 inline <<>>';

=begin pod
    =begin code :allow<B>
    =end code
=end pod

$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
isa-ok $root, 'Node::Document';
isa-ok $root.first-child, 'Node::Code';
is $root.first-child.config.<allow>, 'B';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<code>' '</code>'
	'</div>'
/, 'code with configuration';

=begin pod
    =config head2  :like<head1> :formatted<I>
=end pod

$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
isa-ok $root.first-child, 'Node::Config';
is $root.first-child.type, 'head2';
todo 'need to test config properly', 2;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
	'</div>'
/, 'bare config node';

=begin pod
    =for pod :number(42) :zebras :!sheep :feist<1 2 3 4>
=end pod

$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 2;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
	'<div>'
	'</div>'
	'</div>'
/, 'RT #127005';

=begin pod
=for DESCRIPTION :title<presentation template>
=                :author<John Brown> :pubdate(2011)
=end pod

$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 1;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<section>'
			'<h1>' 'DESCRIPTION' '</h1>'
		'</section>'
	'</div>'
/, 'RT #127005';

=begin pod
=for table :caption<Table of contents>
    foo bar
=end pod

$root = Pod::To::Tree.to-tree( $=pod[$pod-counter] );
todo 'need to test config properly', 1;
is $root.first-child.config[0],<formatted>, 'I';
like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<table>'
			'<tr>'
				'<td>' 'foo bar' '</td>'
			'</tr>'
		'</table>'
	'</div>'
/, 'captioned table';

=begin pod
    =begin code :allow<B>
    These words have some B<importance>.
    =end code
=end pod

#die $=pod[$pod-counter].perl;
$r = $=pod[$pod-counter];
#die $r;

like Pod::To::HTMLBody.render( $=pod[$pod-counter++] ), /
	'<div>'
		'<code>'
			'These words have some '
			'<b>' 'importance' '</b>'
			'.' "\n"
		'</code>'
	'</div>'
/, 'Adjective';

done-testing;

# vim: ft=perl6


