From aa735c9cfd42ef9f0db515cefdf3e147f5f76e2d Mon Sep 17 00:00:00 2001 From: Gustav Eek Date: Sat, 14 Dec 2019 16:08:31 +0100 Subject: Feature. Plugin. Support of complex meta structures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ... --- .ikiwiki/IkiWiki/Plugin/pandoc.pm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '.ikiwiki/IkiWiki') diff --git a/.ikiwiki/IkiWiki/Plugin/pandoc.pm b/.ikiwiki/IkiWiki/Plugin/pandoc.pm index 0de38ff..005f9f8 100755 --- a/.ikiwiki/IkiWiki/Plugin/pandoc.pm +++ b/.ikiwiki/IkiWiki/Plugin/pandoc.pm @@ -952,6 +952,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)$/) { @@ -966,6 +971,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 { -- cgit v1.2.3