head2
use experimental :rakuast;
my $ast = q:to/QAT/.AST; =begin rakudoc
The $/ variable
The $! variable
the block to the caught exception.
=end rakudoc QAT $ast = $ast.rakudoc.head; my Bool $started = False; my $snippet = RakuAST::Doc::Block.new( :type<section>, :paragraphs() ); my $level; for $ast.paragraphs.list -> $node { my $is-head = $node ~~ RakuAST::Doc::Block && $node.type eq 'head'; if $started { if $is-head { if $node.level > $level { $snippet.add-paragraph($node); next } else { last } } else { $snippet.add-paragraph($node) } } else { if $is-head { $node.add-config('xtrg',RakuAST::QuotedString.new( processors => <words val>, segments => ( RakuAST::StrLiteral.new("223"), ) )); $snippet.set-paragraphs($node); $started = True; $level = $node.level; } } } my $head = $snippet.paragraphs.head; my %h =$head.config.pairs.map({ .key => .value.DEPARSE }).hash; say %h