### ----------------------------------------------------
### -- Raku::Pod::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/901-html/70-pre-html-input-output-nested.rakutest
### ----------------------------------------------------
use v6.*;
use Test;

use Pod::To::HTML2;
my $def-dir = 'xt/test-def'.IO;
my $tar-dir = 'xt/tar-dir'.IO;

bail-out "Requires $def-dir and $tar-dir" unless ($def-dir ~~ :e and $tar-dir ~~ :e);
chdir ~$tar-dir;

my $processor = Pod::To::HTML2.new(:$def-dir, :plugins() );
my $rv;
my $pn = 0;

plan 4;

=begin Html
<img style="float: right; margin: 0 0 1em 1em; width:261px" src="/images/Camelia.svg" alt="" id="home_logo"/>
Welcome to the official documentation of the <a href="https://raku.org">Raku</a>
programming language!
Besides online browsing and searching, you can also
<a href="/raku.html">view everything in one file</a> or
<a href="https://github.com/raku/doc">contribute</a>
by reporting mistakes or sending patches.

<hr/>
=end Html

$rv = $processor.render-block( $=pod[$pn++] );

like $rv, /
    '<img style="float: right; margin: 0 0 1em 1em; width:261px" src="/images/Camelia.svg" alt="" id="home_logo"/>'
    \s* ' Welcome to the official documentation of the <a href="https://raku.org">Raku</a> programming language!'
    \s* 'Besides online browsing and searching, you can also <a href="/raku.html">view everything in one file</a> or'
    \s* '<a href="https://github.com/raku/doc">contribute</a> by reporting mistakes or sending patches.<hr/>'
    /, 'html as expected';

=begin pod

=begin input
12345678901234567890
   this is   preformatted
 spaces should be maintained

and vertical spaces conserved.
=end input

=begin output
Like input
12345678901234567890
   this is   preformatted
 spaces should be maintained

and vertical spaces conserved.
=end output
=end pod

if $*RAKU.compiler.version gt v2023.04 {
    $rv = $processor.render-block( $=pod[$pn++] );
    like $rv, /
        '<pre class="pod-input">'
        '12345678901234567890'\n
        '   this is   preformatted'\n
        ' spaces should be maintained'\n
        \n
        'and vertical spaces conserved.'\n
        '</pre>'
    /, 'input seems OK';
    like $rv, /
        '<pre class="pod-output">'
        'Like input'\n
        '12345678901234567890'\n
        '   this is   preformatted'\n
        ' spaces should be maintained'\n
        \n
        'and vertical spaces conserved.'\n
        '</pre>'
    /, 'output seems OK';
}
else {
    $pn += 1;
    skip 'Input / output not implemented as classes', 2
}
=begin pod
=begin nested
This is normal text      with squashed
horizontal spaces

And paragraphs.

Templater to handle margin inset.
=end nested
=end pod

$rv = $processor.render-block( $=pod[$pn++] );

like $rv, /
    '<div class="pod-nested">'
    '<p>'
    'This is normal text with squashed horizontal spaces'
    '</p>'
    \s*
    '<p>And paragraphs.</p>'
    \s*
    '<p>Templater to handle margin inset.</p>'
    \s*
    '</div>'
/, 'nested seems OK';

done-testing


