summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Eek <gustav.eek@fripost.org>2019-12-14 16:08:31 +0100
committerGustav Eek <gustav.eek@fripost.org>2020-01-06 16:25:10 +0100
commitaa735c9cfd42ef9f0db515cefdf3e147f5f76e2d (patch)
treedc9f4c55ed3ac3fea78bc5429e9bd3ea4da68e02
parent4f56301fff832189cb253ef98e62a064f82e2c54 (diff)
Feature. Plugin. 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 ...
-rwxr-xr-x.ikiwiki/IkiWiki/Plugin/pandoc.pm7
1 files changed, 7 insertions, 0 deletions
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 {