From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29492 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: mfhepp Newsgroups: gmane.text.pandoc Subject: Re: Load additional meta-data from YAML file via YAML Block directive? Date: Thu, 4 Nov 2021 08:49:53 -0700 (PDT) Message-ID: <26d7de22-e65d-4596-8223-22e2666e9e93n@googlegroups.com> References: <35d6a2e0-7a32-40d9-a3bf-7fd945885d95n@googlegroups.com> <1EB7E01B-4F90-4E41-AFBB-19C1935D6038@zeitkraut.de> <87056507-2301-49C2-A061-C87ABF35F3C9@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_400_56233588.1636040993288" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="633"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDDMFSFCYUDBBI4GUWGAMGQEE5DDGKQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Nov 08 16:32:54 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f185.google.com ([209.85.167.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mk6di-000AXM-Nc for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 08 Nov 2021 16:32:54 +0100 Original-Received: by mail-oi1-f185.google.com with SMTP id s125-20020acac283000000b00299f2f36eb2sf9702512oif.22 for ; Mon, 08 Nov 2021 07:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=vmz4MUrW3DtsuMeSDcmtGUkoFQBinDvsSjlDrnPefoY=; b=c2LACQQ93j69sfjZqtWEwWgexaKScsLYn5WuFcymIkyT12otxx/Tobx8RHTVpS32Kw JAhben7YqKOQxfK1l5t5JQsboMVEeUvWET+xWOSjZEZgd+sruLbZXkrX7KQmgiDjpYYW s/rBafGqvxR1O/z3tGgyX8XiixiOYW6EjtF2kGiE10gXFdNaqhA/5204dT7WcJH6IBJP csW0ycsUo0jCoRAvMLe3T4WV3w03XvuCtfvHhVaznNhpqnBJf/Qv9+HYzJb6HfYuws72 q/uDY++pheoG3YdEbhrSxtO7hfuRQPI6e9wi47TvqWR7gzkqvzmKITd3uPq+zSAQNjYk kkgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=vmz4MUrW3DtsuMeSDcmtGUkoFQBinDvsSjlDrnPefoY=; b=VWK4HSHyAz98XfEga6DkioaWuREaR1IPs6iqX8eNuz7Y9FJnZqo24Z/ntLiuDsOCCq Z3fHCGb6SmKfkWrzJc7gUhYqL21dq4m/M9GnKLTR/hdAULWoiDjtN6uGGF77iaCmN2+f cUJAkHxGPP+sY8hIWTSlJYLls9pDUOFJ68vOkuffNKI2EZ6JiOdqolHCuV0P4RafI44Y Ro3EBPj+IhPKaOdu3hbRCETOkhXFDz9E1NRnUStjqslOm6z5ZxmrfQWDSytzIE1C3Fv9 M9IVAiMhPrGdORqEsHlMJt+dokaSDeoyOOTHK3l88mjHXrxeFKWRQC7NHQb/Ibvh5rK1 BI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=vmz4MUrW3DtsuMeSDcmtGUkoFQBinDvsSjlDrnPefoY=; b=AtTnEcOT5HjjXvanrMHciP9VQXXp7dw1QdAg3wMNwDExL5p/y9uHqL0WRmZtKqc42V 2BH5mzZ8PMFlkEHxFLvTxLqCON5ZOdyFAsmrycpwnl1aW9apFAsfKun4WcAWUeQi3LtD DqKHVSBrdqxFIQ3FWs7CMukkaEIOXJ+hPKgBotlFtKyH88/kHtxU4z1yA0Qd9+GpwHtc YkrDdF0vPQ6oBk8sEb/zlAl9x7SIXZYZNW/edC0r233/tEVu2PNNYbpaLVb+BXzQbe6R YO6Os6hYqgT1sYdWNVG1ZW72eXkASQR8KU25kgJ7JQdqa+ZVsjvg2GoIXEBrBKlfr4Ee eSnw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533KpDTgKDr8+mMjuqjzOagkEnAwHGX/UidhiFa1EJVkFYK9Sk8i DUrrJrSoFlk6DgeB3u905Oc= X-Google-Smtp-Source: ABdhPJzrEW+8BnypPkn+I4H1cxM+LQlyvLK9NX+pU42MzgL/qVasC8EFmfO74ULia+tNA0YiUPmYtQ== X-Received: by 2002:a9d:7e84:: with SMTP id m4mr544842otp.102.1636385573162; Mon, 08 Nov 2021 07:32:53 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:4599:: with SMTP id x25ls5413557ote.9.gmail; Mon, 08 Nov 2021 07:32:51 -0800 (PST) X-Received: by 2002:a05:6830:1397:: with SMTP id d23mr549853otq.68.1636385571728; Mon, 08 Nov 2021 07:32:51 -0800 (PST) Original-Received: by 2002:a05:6808:1488:b0:273:b359:c0d1 with SMTP id 5614622812f47-2a7d86cbd88msb6e; Thu, 4 Nov 2021 08:49:54 -0700 (PDT) X-Received: by 2002:a05:6830:2a8d:: with SMTP id s13mr3686501otu.26.1636040993988; Thu, 04 Nov 2021 08:49:53 -0700 (PDT) In-Reply-To: X-Original-Sender: mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:29492 Archived-At: ------=_Part_400_56233588.1636040993288 Content-Type: multipart/alternative; boundary="----=_Part_401_1460629926.1636040993288" ------=_Part_401_1460629926.1636040993288 Content-Type: text/plain; charset="UTF-8" Thanks! Ideally, however, I would be able to define the set of design meta-data in the actual YAML header of the document and not in the make script or the pandoc CLI parameters. I think the most straightforward way would be a LUA filter like `include-meta` that does something similar to `pandoc-include`. In the YAML header of the document: ``` title: The title include-meta: acme-design-settings.yaml ``` LUA filter for `include-meta`: ``` # pseudo-code if meta.include-meta is not nil: for each filename in meta.include-meta: additional_meta = parse(filename) for each entry in additional_meta: if meta[entry.key] is nil: meta[entry.key] = entry.value # recursion not shown in here, needed for nested YAML else: if len(meta[entry.key]) == 1: meta[entry.key] = list(meta[entry.key]) if len(entry.key) == 1: entry.key = list(entry.key) meta[entry.key].extend(entry.key) On Wednesday, November 3, 2021 at 5:15:42 PM UTC+1 John MacFarlane wrote: > > Another possibility is to use --defaults with a defaults file > that specifies the input file and all necessary parameters, > including metadata. > > Martin Hepp writes: > > > Dear all: > > > > I am trying to build a cleanly organized environment for deriving > slides, reports, papers, lecture notes etc. centered on Pandoc. > > > > In order to avoid redundancy and hence ease maintenance etc., it would > be good to put different groups of meta-data into different places: > > > > a) _user_ meta-data (like the default path for the BIB file, the author > name, ...) > > > > Example: my-meta-data.yaml > > --- > > author: Martin Hepp > > bibliography: my_references.json > > ... > > > > b) output format-dependent meta-data defaults (one file for e.g. Beamer > slides, one for Eisvogel reports, one for LNCS papers, ...) > > > > Example: eisvogel-defaults.yaml > > --- > > toc-own-page: true > > ... > > > > c) output format-dependent meta-data for specific renderings (e.g. logos > for multiple institutes or if a research project requires specific colors > or texts) > > > > Example: eisvogel-project1.yaml > > --- > > titlepage-text-color: "000000" > > titlepage-rule-color: "00A19B" > > titlepage-rule-height: 15 > > titlepage-background: "background-project1.pdf" > > logo: "templates/static/logo1.pdf" > > logo-width: 10cm > > ... > > > > d) document-specific meta-data in the YAML header block of the actual > document > > Example: my-report.md > > --- > > title: Pandoc is simply great > > ... > > > > < Actual content goes here> > > > > > > Now, the details from c) (like the logo path, colors, and the footer > texts) should be referenced in the document d), not repeated, like so: > > > > > > Example: my-report.md > > --- > > title: Pandoc is simply great > > include-metadata-from: eisvogel-project1.yaml > > ... > > > > I am using --metadata-file to load the various defaults in their order > of priority. But the settings from c) should be ideally set by referencing > c) in the actual document d). > > > > > > My question: Is that possible with Pandoc's included batteries? > > > > Currently, I see only two options: > > > > 1. Add the file-name of c) to the list of input files, like > > > > $ pandoc my-report.md eisvogel-project1.yaml -o my-report.pdf > --metadata-file=my-meta-data.yaml --metadata-file=eisvogel-defaults.yaml > > > > 2. Use https://github.com/DCsunset/pandoc-include, which allows > including YAML files in the YAML header block, like so > > > > --- > > title: Title > > --- > > > > !include-header header.yaml > > > > # Section > > > > Body > > > > See https://github.com/DCsunset/pandoc-include#header-include > > > > But I hesitate to add a hard dependency to #2. > > > > Thanks for your help! > > > > Best wishes > > Martin > > > > > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/87056507-2301-49C2-A061-C87ABF35F3C9%40gmail.com > . > -- 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/26d7de22-e65d-4596-8223-22e2666e9e93n%40googlegroups.com. ------=_Part_401_1460629926.1636040993288 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks! 

Ideally, however, I would be able to defin= e the set of design meta-data in the actual YAML header of the document and= not in the make script or the pandoc CLI parameters.

<= div>I think the most straightforward way would be a LUA filter like `includ= e-meta` that does something similar to `pandoc-include`.

In the YAML header of the document:

<= div>```
title: The title
include-meta: acme-design-= settings.yaml
```

LUA filter for `includ= e-meta`:

```
# pseudo-code
if = meta.include-meta is not nil:
     for each filena= me in meta.include-meta:
        additional_m= eta =3D parse(filename)
         for eac= h entry in additional_meta:
          &n= bsp;  if meta[entry.key] is nil:
       =         meta[entry.key] =3D entry.value
&nbs= p;                 # recursion not = shown in here, needed for nested YAML
       =      else:
          &nb= sp;     if len(meta[entry.key]) =3D=3D 1:
   =                 meta[entry.key] = =3D list(meta[entry.key])
          &nbs= p;         if len(entry.key) =3D=3D 1:
 =                     &nbs= p;entry.key =3D list(entry.key)
         = ;           meta[entry.key].extend(entry.key)
<= /div>

On Wednesday, November 3, 2021 at 5:15:42 PM UTC+1 John MacFarla= ne wrote:

Another possibility is to use --defaults with a defaults file
that specifies the input file and all necessary parameters,
including metadata.

Martin Hepp <mfh...@gmail= .com> writes:

> Dear all:
>
> I am trying to build a cleanly organized environment for deriving = slides, reports, papers, lecture notes etc. centered on Pandoc.
>
> In order to avoid redundancy and hence ease maintenance etc., it w= ould be good to put different groups of meta-data into different places:
>
> a) _user_ meta-data (like the default path for the BIB file, the a= uthor name, ...)
>
> Example: my-meta-data.yaml
> ---
> author: Martin Hepp
> bibliography: my_references.json
> ...
>
> b) output format-dependent meta-data defaults (one file for e.g. B= eamer slides, one for Eisvogel reports, one for LNCS papers, ...)
>
> Example: eisvogel-defaults.yaml
> ---
> toc-own-page: true
> ...
>
> c) output format-dependent meta-data for specific renderings (e.g.= logos for multiple institutes or if a research project requires specific c= olors or texts)
>
> Example: eisvogel-project1.yaml
> ---
> titlepage-text-color: "000000"
> titlepage-rule-color: "00A19B"
> titlepage-rule-height: 15
> titlepage-background: "background-project1.pdf"
> logo: "templates/static/logo1.pdf"
> logo-width: 10cm
> ...
>
> d) document-specific meta-data in the YAML header block of the act= ual document=20
> Example: my-report.md
> ---
> title: Pandoc is simply great
> ...
>
> < Actual content goes here>
>
>
> Now, the details from c) (like the logo path, colors, and the foot= er texts) should be referenced in the document d), not repeated, like so:
>
>
> Example: my-report.md
> ---
> title: Pandoc is simply great
> include-metadata-from: eisvogel-project1.yaml
> ...
>
> I am using --metadata-file to load the various defaults in their o= rder of priority. But the settings from c) should be ideally set by referen= cing c) in the actual document d).
>
>
> My question: Is that possible with Pandoc's included batteries= ?
>
> Currently, I see only two options:
>
> 1. Add the file-name of c) to the list of input files, like
>
> $ pandoc my-report.md eisvogel-project1.yaml -o my-report.pdf --me= tadata-file=3Dmy-meta-data.yaml --metadata-file=3Deisvogel-defaults.yaml
>
> 2. Use https://github.com/DCsunset/pandoc-include, which allows includ= ing YAML files in the YAML header block, like so
>
> ---
> title: Title
> ---
>
> !include-header header.yaml
>
> # Section
>
> Body
>
> See https://github.com/DCsunset/pandoc-i= nclude#header-include
>
> But I hesitate to add a hard dependency to #2.
>
> Thanks for your help!
>
> Best wishes
> Martin
>
>
>
> --=20
> 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-discus..= .@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87056507-2301-49C2-A06= 1-C87ABF35F3C9%40gmail.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/26d7de22-e65d-4596-8223-22e2666e9e93n%40googlegroups.= com.
------=_Part_401_1460629926.1636040993288-- ------=_Part_400_56233588.1636040993288--