public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: FEEDBACK WANTED: Re: YAML metadata files' override order in a single command line
Date: Wed, 02 Oct 2019 17:04:45 -0700	[thread overview]
Message-ID: <yh480ktv8qzobm.fsf@johnmacfarlane.net> (raw)
In-Reply-To: <4998a075-0f70-4b30-7406-135d2e160b97-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


Yeah, it's true. Even though the ability to specify
--metadata-file multiple times is new, you were always
able to specify multiple YAML files when reading pandoc
markdown (since these are valid pandoc markdown files).
And changing the precedence at this point would break
too much.

Also, consistency with the way multiple YAML blocks in
a document works recommends the "first wins" strategy.

I think these are pretty strong reasons for keeping
the order as it is, even if it is a bit counterintuitive.

BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> In the manual <https://pandoc.org/MANUAL.html#metadata-blocks>:
>
>  > 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.
>
> That is, if I understand correctly: if there are two or more YAML 
> blocks, regardless of whether they are passed as separate input files or 
> embedded in other input files, and some key occurs at the top level of 
> two or more of those YAML blocks, the value from the first YAML block 
> which contains the key "wins".
>
> It *is* IMO a little counter-intuitive, i.e. I would have expected 
> right-biassed/last occurrence wins, but the question is whether it is 
> too late to change it or not.  People may well have work flows which 
> rely on the current behavior. For example I have several Makefiles with 
> rules which pass one output-format-specific and one general metadata 
> file, and the order in which they are passed assumes the current 
> behavior, with the format-specific one before the general, so that the 
> format-specific one wins in case of a clash.  I could of course reverse 
> the order of those input files as needed, but I would have to
> always leave a comment saying that the metadata files are already in
> right-biased order, and I would always have to check an existing 
> Makefile to see if it needs updating.  I *know* that I'll forget to do 
> so after a while!
>
> On 2019-10-02 20:48, John MacFarlane wrote:
>> 
>> It is as you discovered: the first one wins, currently.
>> This is somewhat arbitrary and could be changed.
>> 
>> Using foldl1 instead of foldr1 in line 230 of Text.Pandoc.App
>> would give the other behavior.
>> 
>> The change allowing multiple metadata files is not yet in
>> any released version, so it would be easy to change this.
>> I'd welcome feedback from people.
>> 
>> consistency is good, so we should also ask:
>> 
>> - which takes precedence if you do
>>    --metadata foo=1 --metadata foo=2
>>    on the command line?
>> 
>> - which takes precedence if you have two YAML metadata blocks
>>    in a markdown file, and they set the same field?
>> 
>> K4zuki <k.yamamoto.08136891-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>> 
>>> Hello,
>>>
>>> I have a question regarding multiple yaml input in one command line.
>>>
>>> I have two yaml metadata files: system/config.yaml and user/config.yaml.
>>> They have some overlaps in entries.
>>> I tested the following command with expectation that user/config.yaml
>>> overrides system/config.yaml:
>>>
>>> pandoc -s -t markdown system/config.yaml user/config.yaml
>>>
>>>
>>> but in fact system/config.yaml wins. What system/config.yaml does not have
>>> is merged as expected (and vice versa).
>>>
>>> So the question is when multiple yaml with entry overlap given in a single
>>> command line, what kind of override order is applied?
>>>
>>> Thanks && Regards,
>>> Kazuki
>> 
>
> -- 
> 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/4998a075-0f70-4b30-7406-135d2e160b97%40gmail.com.


      parent reply	other threads:[~2019-10-03  0:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02 16:59 K4zuki
     [not found] ` <2921e399-c659-4cba-9357-577c2b05aece-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-10-02 18:48   ` FEEDBACK WANTED: " John MacFarlane
     [not found]     ` <yh480keezv0yrx.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-10-02 19:45       ` BPJ
     [not found]         ` <4998a075-0f70-4b30-7406-135d2e160b97-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-10-02 21:00           ` Gareth Stockwell
2019-10-03  0:04           ` John MacFarlane [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yh480ktv8qzobm.fsf@johnmacfarlane.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).