From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33138 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Martin Post Newsgroups: gmane.text.pandoc Subject: Re: Parse metadata in defaults files as Markdown? Date: Sat, 30 Sep 2023 02:03:16 -0700 (PDT) Message-ID: <7f96f150-6981-4163-8f6d-54de50a90c4fn@googlegroups.com> References: <87r0mgof6d.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_7904_2361443.1696064596333" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34917"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCHYFZ6CWYNBBVOI36UAMGQE2NLKVOY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Sep 30 11:03:23 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f57.google.com ([209.85.160.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qmVsf-0008he-7h for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 30 Sep 2023 11:03:21 +0200 Original-Received: by mail-oa1-f57.google.com with SMTP id 586e51a60fabf-1dc580ed1e4sf31295957fac.1 for ; Sat, 30 Sep 2023 02:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1696064600; x=1696669400; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=W/JEgI5qmJKAa6WS7rM9O0c1QntPw25WlejH28bB/1E=; b=fGoH+Dw44pLM8Ar58Juub7oibQvRFTYOEhQrvkyQ9AsAX6YwW96I2hk4Py6r1LCjqb dO2Ql9COT7xTJTLt1ddq641Ar9mtBP7MGd6TYLL2BYRLIppGeDprsO8+iFfN3jt5nBxU oJJrar1BVW4tAPADy3sqV7rV92bjx65MrsxRcc75vDCQvlR3dH/zFcPjo57mF3kuj8Qj hgefxiJ69D6gYNCweZwv9LFGB5pAW9t9dzr6Mm/I60qslsZy3U6Fq3744aJML03bY1Cm Gyt3yaF0cfwuUxYETihxyWUZCtgGylJsQsL/bbGeGACMgywdbSoSTYe8rFz7Z/WhwOCV PU0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696064600; x=1696669400; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=W/JEgI5qmJKAa6WS7rM9O0c1QntPw25WlejH28bB/1E=; b=ZLpQRhYn89AS1omDZY5EdXeHW8SQ3qgoRjp3XPenQJr7jjFrO23wP5BYrlP1RZqcRo x1qVPHblDGy5wlY/SVcZ1qXTx2LVRLRe5LDqBSG0tVtBXpoc6RBjatZT+SwFYnO4ZcNV d5ta0N9KEeRvbd1a2Sjch/hjg2lmNs/XsOPsET/v6DNn5z9CY7B9e+xHWyZ8ZvzCU9Er ncUlnM3JVbhYeR1a6NqW8/9gsVBVLsdU8Kpe/OVE+kZZ17MbPdCzks7YRh9N9Dw9mKVy UhvMNyT/W8YvjLMDLZDfe627xzRtJr4oQBv1EPmJuF9hYv92n+Ntr9NvaCRMIp5ACZOS YI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696064600; x=1696669400; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=W/JEgI5qmJKAa6WS7rM9O0c1QntPw25WlejH28bB/1E=; b=MueDWtp15Jq6HR5YXdI9AXIqlAWX4ofUzvlSBGkYOMJzX8p4dkhKKqURLrVIg233hN tF6vr7p9vW/ziAfaZRDrXeYV+9tra3Igve7V9U9VlhlNVSF7dgjm/ET3DRqBpNEa1+Xw ZR+1lX3sp79UYHZKnNGbTDwhOaYykr3/S2Ll8dFBc2B0npGsJkAnNuF+Mx7lhVY5LPZd EnoG55qS+C0dzgJ+rVeeEN81ATXfz/laZCFM3bXQpRAILX4rkGU4aBUPx7Z+Pg0UvtRT PglKa+tK6+IezaHBrK7fO1Z+c/N3iKQJxjEo1OJFhKvgK9NTZw Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YyOZIhRm1yG56yjkZPILAy1566jYywxpx+Skmd5VjtW9fBz4P/T W18P0W+a+pRtlAhPcXPCr6E= X-Google-Smtp-Source: AGHT+IEZq7b/TlcWNnq8P/+trPJAZt2Dp5b01d9d8j/mTkkWbeQF8zguMRyk1ck0ujty4D2nAREVHQ== X-Received: by 2002:a05:6870:912c:b0:1c8:bae6:527d with SMTP id o44-20020a056870912c00b001c8bae6527dmr7407371oae.55.1696064600158; Sat, 30 Sep 2023 02:03:20 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:c092:b0:1d6:cbc7:fb4c with SMTP id c18-20020a056870c09200b001d6cbc7fb4cls190214oad.1.-pod-prod-06-us; Sat, 30 Sep 2023 02:03:17 -0700 (PDT) X-Received: by 2002:a05:6870:9552:b0:1d6:3381:dfea with SMTP id v18-20020a056870955200b001d63381dfeamr2744412oal.1.1696064597090; Sat, 30 Sep 2023 02:03:17 -0700 (PDT) In-Reply-To: <87r0mgof6d.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: MartinPostBerlin-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:33138 Archived-At: ------=_Part_7904_2361443.1696064596333 Content-Type: multipart/alternative; boundary="----=_Part_7905_197622868.1696064596333" ------=_Part_7905_197622868.1696064596333 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, Albert! While this looks feasible & helpful, I have now (after= =20 many years of using Pandoc=E2=80=A6) finally =E2=80=9Cseen the light=E2=80= =9D, and I=E2=80=99ll separate=20 default files and metadata files, as it should be. =F0=9F=98=8A Albert Krewinkel schrieb am Freitag, 29. September 2023 um 23:14:28 UTC+2: > > Martin Post writes: > > > In a Pandoc document=E2=80=99s YAML metadata block, or in a Pandoc meta= data=20 > file, I can do this: > > > > variable1: __content__ > > > > =E2=80=A6and it will be rendered as content for HTML. > > > > Doing this in a Pandoc DEFAULTS file: > > > > metadata: > > variable1: __content__ > > > > =E2=80=A6will render $variable1$ as =E2=80=9C__content__=E2=80=9D > > > > So =E2=80=93 is it possible to have metadata in a defaults file interpr= eted as=20 > Markdown? > > I think the only way would be to write a Lua filter that convert strings > to Inlines. > > E.g.: > > > local strings2md > strings2md =3D function (meta) > for key, value in pairs(meta) do > if pandoc.utils.type(value) =3D=3D 'string' then > -- Convert strings to Markdown > local blocks =3D pandoc.read(value).blocks > meta[key] =3D pandoc.utils.blocks_to_inlines(blocks) > elseif pandoc.utils.type(value) =3D=3D 'List' then > -- Recurse on lists > meta[key] =3D strings2md(value) > end > end > > return meta > end > > Meta =3D strings2md > > > --=20 > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > --=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 e= mail 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/7f96f150-6981-4163-8f6d-54de50a90c4fn%40googlegroups.com. ------=_Part_7905_197622868.1696064596333 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you, Albert! While this looks feasible & helpful, I have now (aft= er many years of using Pandoc=E2=80=A6) finally =E2=80=9Cseen the light=E2= =80=9D, and I=E2=80=99ll separate default files and metadata files, as it s= hould be.=C2=A0=F0=9F=98=8A

Albert Krewinkel schrieb am Freitag, 29. Sep= tember 2023 um 23:14:28 UTC+2:

Martin Post <martinpo...@= gmail.com> writes:

> In a Pandoc document=E2=80=99s YAML metadata block, or in a Pandoc= metadata file, I can do this:
>
> variable1: __content__
>
> =E2=80=A6and it will be rendered as <strong>content</stro= ng> for HTML.
>
> Doing this in a Pandoc DEFAULTS file:
>
> metadata:
> variable1: __content__
>
> =E2=80=A6will render $variable1$ as =E2=80=9C__content__=E2=80=9D
>
> So =E2=80=93 is it possible to have metadata in a defaults file in= terpreted as Markdown?

I think the only way would be to write a Lua filter that convert string= s
to Inlines.

E.g.:


local strings2md
strings2md =3D function (meta)
for key, value in pairs(meta) do
if pandoc.utils.type(value) =3D=3D 'string' then
-- Convert strings to Markdown
local blocks =3D pandoc.read(value).blocks
meta[key] =3D pandoc.utils.blocks_to_inlines(blocks)
elseif pandoc.utils.type(value) =3D=3D 'List' then
-- Recurse on lists
meta[key] =3D strings2md(value)
end
end

return meta
end

Meta =3D strings2md


--=20
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124

--
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/7f96f150-6981-4163-8f6d-54de50a90c4fn%40googlegroups.= com.
------=_Part_7905_197622868.1696064596333-- ------=_Part_7904_2361443.1696064596333--