From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29468 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Martin Hepp Newsgroups: gmane.text.pandoc Subject: Re: Load additional meta-data from YAML file via YAML Block directive? Date: Thu, 4 Nov 2021 18:54:45 +0100 Message-ID: References: <35d6a2e0-7a32-40d9-a3bf-7fd945885d95n@googlegroups.com> <1EB7E01B-4F90-4E41-AFBB-19C1935D6038@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10056"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDDMFSFCYUDBB3N4SCGAMGQEPJYCYAA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Nov 04 18:54:56 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f64.google.com ([209.85.167.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1migwy-0002S6-Fk for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 04 Nov 2021 18:54:56 +0100 Original-Received: by mail-lf1-f64.google.com with SMTP id j16-20020a05651231d000b00402bef31189sf455814lfe.18 for ; Thu, 04 Nov 2021 10:54:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1636048496; cv=pass; d=google.com; s=arc-20160816; b=te9jwIABaLg4GAQICkpa5LmtiUu3+7icamkWFJNqOPeKFjtcjEGipPgZ3rGQCdGF6W 7c9uLGmvuMyYtidXEgM13sYwsDIdhmoFcMCvZTiDke5HcA8S9xZfq/++p3/AZTOd0GHS L+Aza5llWqFxBqx51GMylmcRpctQvn+ZkAa2r8yN1iAQMVf2PiEP0gB1eY8lMhD3Jc1i b0JD7Tr6Vqodes4Ri5/lj8Xk6/qnUZr7Nv7qrFPYCq8+hvqaXzx4H5Ouj5cqLozRRVeO GcMtBxe8gXs0ZV0cdo6I5ZgkF68no2CX/4JVyxSGD2OYIZebiuuLjjvhdMvk9ZL0Rbu0 Snyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:message-id:in-reply-to:to :references:date:subject:mime-version:from:sender:dkim-signature :dkim-signature; bh=DS9sX7IT1ycDvS4ShxyKRHYomNt87fpxqVNtzIXblzY=; b=lThXKafNwH0ug7X3LP/mxsO6z0WCTPJ0VkU4NFunlUHWvbabWh96FiM9aLjJH6Lj2w xZtf1TSKfv6MXqHBbYaGoPSg05kNeJQgbxG3KKoJa6pszs6nKG1KU1lUzPFQdzpiI3g+ ehUEzOsSj3VFPuK3FQjQp+os7HmBlycXs6coknLP+XSi1kBgfV98JBAIi1YUsgUmjmYU 8Kmm34jiA80ylevm+5ZwtIEqGRoUXJih5Cm7SmPvqSbMuuHX4Ak4Sw4kV+IBpddcuh5o sIllJh7C4UzYFOD5n4QeIkLY6FMr8LgkRv1zpK5o/3HuCS2BXYNcrPJJWvlywtIi1MyG u/ww== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B2o+Sc8k; spf=pass (google.com: domain of mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::335 as permitted sender) smtp.mailfrom=mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:mime-version:subject:date:references:to:in-reply-to :message-id:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=DS9sX7IT1ycDvS4ShxyKRHYomNt87fpxqVNtzIXblzY=; b=OB3dvnNAnw3nfttHW0/mmHAcsifViRpD4zttOlHItj/Z1cNeEdLUXwsjbe0sGem32M q6uXKIRmBH0jt0ZMiCrdMKiAmffr/XGcHOukEhyo8hysmEyoRZa3A7WxIguY/F1Q7epn dHxJA51L6WGwmOBzeGV/NAi6vOs+0xYCNzPXHiCaPUfGdVI3nQS0uxio0qLkyK6X1HAv v5ssDHLZIpfwB5iU7LB8Cp9W8RdVR7s8UvxjTXBTcQgZ3CdK5rnm7Pr5FZvvr+vwpEK6 wkqByXLTYh7IYOL84iG5laq31OC5SOu9rKYnJqMcBcXJ4q/Hbi3YXCBFLIVIT/0VEcqW pDoQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:mime-version:subject:date:references:to:in-reply-to:message-id :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=DS9sX7IT1ycDvS4ShxyKRHYomNt87fpxqVNtzIXblzY=; b=BPnps4JeVnwu63U5W3EHiJKXLniNPuyXjntu/YB+qqtnhqS3AwJ9Kt20c4jwelMndP 9vENe94rPX4LOYywz5aS9FWT5q5jqsBMWgWqFaAYvVYrEpaqLDAiOh+cqea4lZgKKBEA MOQllIYKdM0EMux3O20oH7kq4ZVV6RbbRvcKMuchjOTkwk04ZD6Dl/oe9WAbLZLIybW7 FHMGQ4SMpyIk4lorAhFeOPjhUYN+/geRb+KY8IMqoa1VLAu8i6k43lOX1K/cNH+33+v3 WD+ZGXAH6G9CUj0kurS6KWicWvEIviAs1x8YJzi5OmavwC3Ct++VgR3NfS5UiXCiL/Tj Bd1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:mime-version:subject:date:references :to:in-reply-to:message-id:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=DS9sX7IT1ycDvS4ShxyKRHYomNt87fpxqVNtzIXblzY=; b=uWHxI97T91WYjUfnZgGtU2M4HI7pTEI69t+1y4XDpjgjpBSTJhIsX7BK60CIRKO9Ey zx/bKhP69FxL9Z7//UCzKoxUZ+y3dxXmGjet3+ee8IV2+mwUExUaqrGryRq8i2LyUJld PU3zRzZkraYPaxYIrR0WslxlfeokYxFz3WXJB7IZsFRPtv4QrG//cI9SMC48pTCiz01J kuQ/TTrf+jc1xbC65jZ8IVoc8h+4CQU/rZcv2p+PZCPWi/8FhP8R6PDiPZyWtbTtqKrz bZi3UPl6iwaFn+DdFg22192XSI2/V9p+FHbfNM6tg8UQQhk+DmlHVXzf2b6E+th2qWFW 5Hcg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533UnvnfkmoLJsRzHb8WuidqXcdfV+pB/HM9QrRKVqVkEw+P+SYh awSpwW2eU7Vzl57sdSAhViE= X-Google-Smtp-Source: ABdhPJzbEQs+QyQFVVQ5zNj/ANEw5Zzo7KUGGwhtO7EbkysvHSkQm6Yi4aewSPDTQg58BO/pEuLrvg== X-Received: by 2002:a05:6512:1304:: with SMTP id x4mr47494088lfu.591.1636048495853; Thu, 04 Nov 2021 10:54:55 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a19:c74d:: with SMTP id x74ls868501lff.3.gmail; Thu, 04 Nov 2021 10:54:53 -0700 (PDT) X-Received: by 2002:a19:ad07:: with SMTP id t7mr17779452lfc.690.1636048493018; Thu, 04 Nov 2021 10:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636048493; cv=none; d=google.com; s=arc-20160816; b=bHrRUxtZXFFCpQi4DPCEuDEmVAqBa1SgdlYVTi6XvHsvP9Yhr03H7ovDo+zmP0Htwu 5J1Ae2ygFQbadiY/1CEuLSdC6PDBlqbDHe0mLibATJsNzorUDF7hy8v+Q7PBBV0ky/x0 4TAzCiT3236PWMDAEc3xdOIuXMKS0lkUFAWw+G0w7+FKSP3O4XEDtBVTwkkWiq6q7Ufo SIF9cVNShcMaBjmU1yhmEgfQ4zBbcoTdfqLJcs4SG5WIFc5DUSsje8KrZ93tv1kdy+wc hKggzcDdkcl8+A8onSUG91MOqRI0UT6ljPPWm677uRIrSEHRLrdAyR/+Ukz4gTtXzByA 6AWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:dkim-signature; bh=lKntGls47QxJt2Radgqm0FQk6wOyWzTslJAN2VR1/ns=; b=w4Lue8Bwt2o9lmMBa9qIYRgcvUxT6nAYxcGxSbE8kSPJVOdHboI/9ytjxypIQg4Z3X hoifl/Okaf0sCwRacr6epq9iFnBQ2jVI17ou5t9Pte6SxXg+LF+5ORsP4PZbNyd4EYxx 6UaEINVWryG3I9srLqrfM0OjNLFgizt9i90z07+rhYv3njKpJZP4s3SpY2BJyRE36fUv Rt2qm+uR0Nz+mp0hYqwAVO0roVK1v1rSV4LvnJRiB1UEu8371piusNtzXzpgEnGSgOD/ KlCLb4xEs/A7phiQjaXDUbYF2K6XY4iAaQ5Va5nlBUDFk0x7LNNEm8WRumLwT+Feln8w nv+w== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B2o+Sc8k; spf=pass (google.com: domain of mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::335 as permitted sender) smtp.mailfrom=mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com. [2a00:1450:4864:20::335]) by gmr-mx.google.com with ESMTPS id e2si87791ljg.2.2021.11.04.10.54.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 10:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::335 as permitted sender) client-ip=2a00:1450:4864:20::335; Original-Received: by mail-wm1-x335.google.com with SMTP id d72-20020a1c1d4b000000b00331140f3dc8so4870292wmd.1 for ; Thu, 04 Nov 2021 10:54:52 -0700 (PDT) X-Received: by 2002:a7b:cb07:: with SMTP id u7mr24764722wmj.178.1636048492368; Thu, 04 Nov 2021 10:54:52 -0700 (PDT) Original-Received: from smtpclient.apple (dynamic-077-009-073-033.77.9.pool.telefonica.de. [77.9.73.33]) by smtp.gmail.com with ESMTPSA id g2sm5565135wrq.62.2021.11.04.10.54.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Nov 2021 10:54:48 -0700 (PDT) In-Reply-To: <1EB7E01B-4F90-4E41-AFBB-19C1935D6038-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Original-Sender: mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B2o+Sc8k; spf=pass (google.com: domain of mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::335 as permitted sender) smtp.mailfrom=mfhepp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:29468 Archived-At: (for some reasons, my original post appears as a reply to an unrelated post in the pandoc-discuss Google group ;-()), so apologies for reposting this. Dear John, Thanks! Ideally, however, one would be able to define the set of design meta-data in the actual YAML header of the document and not in a 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`. That would nicely complement the two other include filters: https://github.com/pandoc/lua-filters/tree/master/include-files https://github.com/pandoc/lua-filters/tree/master/include-code-files So for instance, one would use `include-meta` in the YAML header of the document, like so: ``` title: The title include-meta: acme-design-settings.yaml ``` And the LUA filter for `include-meta` would follow this algorithm (sketchy): ``` # pseudo-code meta = document.meta if meta.include-meta is not nil: for each filename in meta.include-meta: additional_meta = load_and_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) ``` The pseudocode is sketchy in that the recursive addition of nested meta-data is not shown. I have never used LUA before; if time permits, I will try to implement this. If anybody fluent is willing to work on this, I will be glad to contribute. Best wishes Martin > From: John MacFarlane > Subject: Re: Load additional meta-data from YAML file via YAML Block directive? > Date: 3. November 2021 at 17:14:56 CET > To: Martin Hepp , pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > > 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