### ----------------------------------------------------
### -- Rakuast::RakuDoc::Render
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth
### -- File: xt/090-S-V-C-codes.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

use RakuDoc::Render;

plan 4;

my $ast;
my $rv;
my RakuDoc::Processor $rdp .= new(:test);
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    The emergency signal is: S<
    dot dot dot   dash dash dash   dot dot dot>.
    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, /
    'The emergency signal is:' .+
    '<markup-S>' .+? 'content' .+
    '｢' \v
    'dot dot dot'  \s**3 'dash dash dash' \s**3   'dot dot dot｣'  .+
    '</markup-S>' .+ '.'
    /, 'S-markup with extra spaces';
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    The emergency signal is: B<
    dot dot dot   dash dash dash   dot dot dot>.
    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, /
    'The emergency signal is:' .+?
    '<markup-B>' .+?
    'content' .+?
    '｢ dot dot dot dash dash dash dot dot dot｣' .+?
     '</markup-B>' .+ '.'
    /, 'B-markup removes extra spaces inside text';
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    The B<V< V<> >> markup instruction disarms other codes
    such as V< I<>, C<>, B<>, and M<> >.
    =end rakudoc
    QAST

$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, /
    'The ' .+?
    'markup-B' .+?
    'content' .+?
    'markup-V' .+? 'content' .+ 'V<>' .+ '</markup-V' .+
    '</markup-B' .+
    'disarms' .+
    'markup-V' .+? 'content' .+ 'I<>, C<>, B<>, and M<>'
    /, 'markup-V test';
$ast = Q:to/QAST/.AST;
    =begin rakudoc
    =config C :allow< B I U >
    =config V :allow< K L X >
    Some C<text with B<markup> and K<markup> > back to normal.
    Some V<text with B<markup> and K<markup> > back to normal.
    =end rakudoc
    QAST
$rv = $rdp.render( $ast, :pre-finalised );
like $rv.body.Str, /
    'Some '
    '<markup-C>' .+? 'content' .+ 'text with ' .+?
    'markup-B' .+? 'content' .+? 'markup' .+ '/markup-B' .+
    'K<markup>' .+ '/markup-C' .+ 'back to normal' .+
    'Some '
    '<markup-V>' .+? 'content' .+ 'text with' .+
    'B<markup> and ' .+
    'markup-K' .+? 'content' .+ 'markup' .+ '/markup-K' .+
    '/markup-V' .+ 'back to'
    /, 'Verbatim/code with config works';
done-testing;


