Pandoc-Elements
view release on metacpan or search on metacpan
t/metadata.t view on Meta::CPAN
is $doc->meta->{string}->content, "hello\nworld";
is $doc->meta->{string}->value, "hello\nworld";
# MetaInlines
{
my $m = MetaInlines [ Str "foo" ];
is '{"c":[{"c":"foo","t":"Str"}],"t":"MetaInlines"}',
$m->to_json, 'MetaInlines';
is $m->string, 'foo', 'MetaInlines->string';
}
# MetaBlocks
{
my $m = MetaBlocks [ Para [ Str "x" ], Para [ Str "y" ] ];
is $m->string, "x\n\ny", 'MetaBlocks->string';
}
# [meta]value
is_deeply $doc->value, {
false => 0,
true => 1,
string => "hello\nworld",
blocks => "x\n\ny",
map => {
string => "0",
list => ["a", "b", 0],
'/~' => 1
}
}, 'value';
is $doc->value('false'), 0, 'value("false")';
is $doc->value('/false'), 0, 'value("/false")';
is $doc->value('true'), 1, 'value("true")';
is $doc->value('/true'), 1, 'value("/true")';
is $doc->value('/map/string'), "0", 'value("/map/string")';
is $doc->value('/map/list/0'), "a", 'value("/map/list/0")';
is $doc->value('/map/list/2'), "0", 'value("/map/list/2")';
is $doc->value('string'), "hello\nworld", 'value("string")';
is $doc->value('/string'), "hello\nworld", 'value("/string")';
is_deeply $doc->value('/map/~1~0', boolean => 'JSON::PP'),
JSON::PP::true, 'value("/map/~1~0")';
is_deeply $doc->value('string', element => 'keep'),
$doc->meta->{string}->content, 'value("string", elements => keep)';
is_deeply $doc->value('/string', element => 'keep'),
$doc->meta->{string}->content, 'value("/string", elements => keep)';
is $doc->value('blocks'), "x\n\ny", 'value("blocks")';
is $doc->value('/blocks'), "x\n\ny", 'value("/blocks")';
is_deeply $doc->value('blocks', element => 'keep'),
$doc->meta->{blocks}->content, 'value("blocks", elements => keep)';
is_deeply $doc->value('/blocks', element => 'keep'),
$doc->meta->{blocks}->content, 'value("/blocks", elements => keep)';
foreach (qw(x map/x true/x blocks/x map/list/x map/list/3)) {
is $doc->value($_), undef, "value('$_')";
is $doc->value($_), undef, "value('/$_')";
}
my $doc = do {
local (@ARGV, $/) = ('t/documents/meta.json');
pandoc_json(<>);
};
is_deeply { map { $_ => $doc->metavalue($_) } keys %{$doc->meta} },
$doc->metavalue, 'Document->metavalue';
done_testing;
( run in 3.356 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )