From: Gustav Eek Date: Mon, 20 Jan 2020 17:30:31 +0000 (+0100) Subject: Feature. Support of complex meta structures X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=0ca9a45f4eaf434c27e0065580808555a8813eb8;p=ikiwiki-pandoc.git Feature. Support of complex meta structures Add support in *unwrap_c* for support of the structure: *MetaList* with 2 x *MetaMap* with keys pointing to *MetaInlines*: --- references: - id: refone title: Ref-MetaInlines-in-MetaList - id: reftwo title: Ref-MetaInlines-in-MetaList ... Actually it sounds complex but this fix should also be needed for the simpler example of *MetaMap* with keys pointing at *MetaInlines*: --- experiment: key_first: Värde key_second: värde ... --- diff --git a/pandoc.pm b/pandoc.pm index 7c4d731..be44a06 100755 --- a/pandoc.pm +++ b/pandoc.pm @@ -773,6 +773,11 @@ sub unwrap_c { # Finds the deepest-level scalar value for 'c' in the data structure. # Lists with one element are replaced with the scalar, lists with more # than one element are returned as an arrayref containing scalars. + # + # Elements containing hash as keys are unwrapped. That is to + # support *MetaList* containing *MetaMap* with keys pointing to + # *MetaInlines*. Reference are examples of that structure. (hash unwrap) + # my $container = shift; if (ref $container eq 'ARRAY' && @$container > 1) { if (ref $container->[0] eq 'HASH' && $container->[0]->{t} =~ /^(?:Str|Space)$/) { @@ -787,6 +792,8 @@ sub unwrap_c { return; } elsif (ref $container eq 'HASH' && $container->{c}) { return unwrap_c($container->{c}); + } elsif (ref $container eq 'HASH' && keys $container->%*) { # (hash unwrap) + return {map { $_ => unwrap_c($container->{$_}) } keys $container->%*}; } elsif (ref $container) { return; } else {