public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Multiple YAML metablocks with the same key
@ 2019-10-19 10:19 Patrick Kenny
       [not found] ` <b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Kenny @ 2019-10-19 10:19 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1217 bytes --]

In the section on Metadata blocks, the manual 
<https://pandoc.org/MANUAL.html> says this:

A document may contain multiple metadata blocks. The metadata fields will 
> be combined through a left-biased union: if two metadata blocks attempt to 
> set the same field, the value from the first block will be taken.


I have two metadata blocks, all of which look something like this:

Block A
link:
  yahoo: "www.yahoo.com"


Block B
link:
  google: "www.google.com" 

So the root key is the same, bu the sub keys all have different values.  In 
this case, Pandoc only recognizes "yahoo" in this case because that's the 
first block... is my understanding correct?

I tested this and it seems to be the case, but I just want to make sure 
before I try to invent some way to combine my disparate YAML files...

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3147 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple YAML metablocks with the same key
       [not found] ` <b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-10-19 11:24   ` BPJ
       [not found]     ` <CADAJKhAmjTgOsDcWuVdnXzOEHp5=eOe6hKS_+uzGRD6DeCUurA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: BPJ @ 2019-10-19 11:24 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]

Yes, that is correct. You may be interested in my Perl script which
recursively merges data structures in a "smart" way:

1.  If both structures are hashes (mappings/dictionaries) they are merged,
with the values of identical keys merged recursively.

2.  If either structure is an array they are concatenated, with the
structure which isn't an array, if any, prepended or appended to the one
which is.

3.  In all other cases the structure "to the right" is preserved at the
expense of the other one.


Den lör 19 okt. 2019 12:20Patrick Kenny <ptmkenny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> In the section on Metadata blocks, the manual
> <https://pandoc.org/MANUAL.html> says this:
>
> A document may contain multiple metadata blocks. The metadata fields will
>> be combined through a left-biased union: if two metadata blocks attempt to
>> set the same field, the value from the first block will be taken.
>
>
> I have two metadata blocks, all of which look something like this:
>
> Block A
> link:
>   yahoo: "www.yahoo.com"
>
>
> Block B
> link:
>   google: "www.google.com"
>
> So the root key is the same, bu the sub keys all have different values.
> In this case, Pandoc only recognizes "yahoo" in this case because that's
> the first block... is my understanding correct?
>
> I tested this and it seems to be the case, but I just want to make sure
> before I try to invent some way to combine my disparate YAML files...
>
> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAmjTgOsDcWuVdnXzOEHp5%3DeOe6hKS_%2BuzGRD6DeCUurA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 4602 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple YAML metablocks with the same key
       [not found]     ` <CADAJKhAmjTgOsDcWuVdnXzOEHp5=eOe6hKS_+uzGRD6DeCUurA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-10-19 17:13       ` Patrick Kenny
       [not found]         ` <8ce4df9d-4c43-40bb-a759-1cb509090ca3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Kenny @ 2019-10-19 17:13 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2704 bytes --]

Thanks, that script sounds great!  Where can I find the script?

On Saturday, October 19, 2019 at 8:24:40 PM UTC+9, BP wrote:
>
> Yes, that is correct. You may be interested in my Perl script which 
> recursively merges data structures in a "smart" way:
>
> 1.  If both structures are hashes (mappings/dictionaries) they are merged, 
> with the values of identical keys merged recursively.
>
> 2.  If either structure is an array they are concatenated, with the 
> structure which isn't an array, if any, prepended or appended to the one 
> which is.
>
> 3.  In all other cases the structure "to the right" is preserved at the 
> expense of the other one.
>
>
> Den lör 19 okt. 2019 12:20Patrick Kenny <ptmk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 
> skrev:
>
>> In the section on Metadata blocks, the manual 
>> <https://pandoc.org/MANUAL.html> says this:
>>
>> A document may contain multiple metadata blocks. The metadata fields will 
>>> be combined through a left-biased union: if two metadata blocks attempt to 
>>> set the same field, the value from the first block will be taken.
>>
>>
>> I have two metadata blocks, all of which look something like this:
>>
>> Block A
>> link:
>>   yahoo: "www.yahoo.com"
>>
>>
>> Block B
>> link:
>>   google: "www.google.com" 
>>
>> So the root key is the same, bu the sub keys all have different values.  
>> In this case, Pandoc only recognizes "yahoo" in this case because that's 
>> the first block... is my understanding correct?
>>
>> I tested this and it seems to be the case, but I just want to make sure 
>> before I try to invent some way to combine my disparate YAML files...
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "pandoc-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8ce4df9d-4c43-40bb-a759-1cb509090ca3%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 6265 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple YAML metablocks with the same key
       [not found]         ` <8ce4df9d-4c43-40bb-a759-1cb509090ca3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-10-19 17:32           ` BPJ
  0 siblings, 0 replies; 4+ messages in thread
From: BPJ @ 2019-10-19 17:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 3712 bytes --]

I'll write a bit of documentation and upload it as a gist.  It's really
just a wrapper around Hash::Merge[^1] with a special behavior for arrays,
and YAML::PP[^2] to read in YAML/JSON and dump YAML.

[^1]: https://metacpan.org/pod/Hash::Merge

[^2]: https://metacpan.org/pod/YAML::PP



Den lör 19 okt. 2019 19:14Patrick Kenny <ptmkenny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> Thanks, that script sounds great!  Where can I find the script?
>
> On Saturday, October 19, 2019 at 8:24:40 PM UTC+9, BP wrote:
>>
>> Yes, that is correct. You may be interested in my Perl script which
>> recursively merges data structures in a "smart" way:
>>
>> 1.  If both structures are hashes (mappings/dictionaries) they are
>> merged, with the values of identical keys merged recursively.
>>
>> 2.  If either structure is an array they are concatenated, with the
>> structure which isn't an array, if any, prepended or appended to the one
>> which is.
>>
>> 3.  In all other cases the structure "to the right" is preserved at the
>> expense of the other one.
>>
>>
>> Den lör 19 okt. 2019 12:20Patrick Kenny <ptmk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> In the section on Metadata blocks, the manual
>>> <https://pandoc.org/MANUAL.html> says this:
>>>
>>> A document may contain multiple metadata blocks. The metadata fields
>>>> will be combined through a left-biased union: if two metadata blocks
>>>> attempt to set the same field, the value from the first block will be taken.
>>>
>>>
>>> I have two metadata blocks, all of which look something like this:
>>>
>>> Block A
>>> link:
>>>   yahoo: "www.yahoo.com"
>>>
>>>
>>> Block B
>>> link:
>>>   google: "www.google.com"
>>>
>>> So the root key is the same, bu the sub keys all have different values.
>>> In this case, Pandoc only recognizes "yahoo" in this case because that's
>>> the first block... is my understanding correct?
>>>
>>> I tested this and it seems to be the case, but I just want to make sure
>>> before I try to invent some way to combine my disparate YAML files...
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pandoc-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pandoc-discuss/b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/8ce4df9d-4c43-40bb-a759-1cb509090ca3%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/8ce4df9d-4c43-40bb-a759-1cb509090ca3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCP2ans78imd77m0XAPamP9XPJprAsDhHWO5chQbxymvw%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 6539 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-19 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-19 10:19 Multiple YAML metablocks with the same key Patrick Kenny
     [not found] ` <b5cc6a0f-cac7-4e0a-860c-b3ef2878cd0f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-19 11:24   ` BPJ
     [not found]     ` <CADAJKhAmjTgOsDcWuVdnXzOEHp5=eOe6hKS_+uzGRD6DeCUurA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-10-19 17:13       ` Patrick Kenny
     [not found]         ` <8ce4df9d-4c43-40bb-a759-1cb509090ca3-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-19 17:32           ` BPJ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).