From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31982 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Howard Borchew Newsgroups: gmane.text.pandoc Subject: help with lua filter "Replacing placeholders with their metadata value" Date: Thu, 12 Jan 2023 08:59:35 -0800 (PST) Message-ID: <8db3a838-8431-4b75-aac1-94bc29fac675n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2974_306383575.1673542775399" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29121"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCBJHLEY5IOBB6HYQCPAMGQEW46LBEI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 12 17:59:40 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f55.google.com ([209.85.160.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pG0vU-0007Hd-17 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 12 Jan 2023 17:59:40 +0100 Original-Received: by mail-oa1-f55.google.com with SMTP id 586e51a60fabf-14c90f25682sf6728660fac.10 for ; Thu, 12 Jan 2023 08:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=GJ7PIgLkAOaUID3uJKcFDLQxqrYbM8ADoC57Vx9IUTM=; b=pQGJj9RdkE+Bp8ZgJ6tocNQbXdMVdsRIER5pK+W1cV0aQtczeXQt7yxpqSw0KWZE3D QaoQxN4o33rT/QUnQUl60miKHKRfJeibiKnujR/SxhdgwR7Y5bLbNUB5DfsldqQQvXBe S66tk30Ykxp4twTrPCYLIX4PsdseF+/7+yPZ7LEvHaSsrLw1FgZMv5tzpBQwy8ksjkUf Lu2V/zt00munW7MuHu8deUgr4XVX6w39nU+FdbN4fstVkVPKytt3OXHdS82BkTS808FU BY23FOflrJeIHIDt/iEXnuq4FH/QJV6YSQ3vjsuSYDqzrS7/w74rueAdmLI8ITGdKPfZ Ruxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=GJ7PIgLkAOaUID3uJKcFDLQxqrYbM8ADoC57Vx9IUTM=; b=Do7rzD2M2tNP94bErmxauw2KL5OXf3sZ3H5lLNYbY9y7FFVBKdAHIHHSzKeMSnsXAv fDUs+JeCnkVxqxJcsnkLpJruW2fqICBOEsUDHzbB74QmvzPxhFtKwq1QXtxFWWPs8/U8 f3rWgTD5P3XY76IYHTAQzd/fGEoT4a/sezf+oEvLJd4NjRdkssn3sDmuFDl8kiDZhQVH qsWWCsnFlbWUWiZzVWn3xyd5xjzsfLxyO7cILlYEgEIG4KYZjn6DRERsK52l7hJ6rs3z q5AjR8iyIoySQdzOqc2wK6OL0kyv8QUUs7tVAxbko+/CrKLdM6plSmTjqDPu3mSJYN4H ZsQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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:message-id:to:from:date :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=GJ7PIgLkAOaUID3uJKcFDLQxqrYbM8ADoC57Vx9IUTM=; b=5sPeUoSW2eQJGj3w4YjyiPPlw3W5CIDta9d0fuhpMy3BW4OTcos2PpxdRe9xb52Hhm 4A7epNX7KTSMB2zKRuXe1RnK7zJe3wKAMs6YXB8nSZf5akVW+XBCQT0YGkrnKUbQU9bf YVlYmcuyar5cnrS2Hm0DUW2vfhHam/hozOqToIcRVTUhrWbw0B6su2Si9yhNLEynMWBb hOseCpUd38TR2Zlu0ypyMk9FNPuLwe0CdvWnAjbpQXduLGTGYGAeDa9rKzncAz5t2WJ9 wHxPVyEbGdYjA8HsZkhd5a+k2AmP6aCq/ZgQtiHRBkXcLo6riIAr9yAkDxk5yrBAVG4a dX/A== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AFqh2kqJRO087tIzVew2tAJ0iaiVwC8pk3O30eCeH78vpkzWlcvis3li 2ko4di8rHWdfNSEHgY7RQs4= X-Google-Smtp-Source: AMrXdXulAWbXj/JloenG5FITZwJINiRvS749b1ERKOGH056FUcpG8jgg5wDnteq5guRr3f7DXOb/+w== X-Received: by 2002:a05:6870:d212:b0:14f:e2b7:244e with SMTP id g18-20020a056870d21200b0014fe2b7244emr4022929oac.243.1673542778756; Thu, 12 Jan 2023 08:59:38 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6871:40c:b0:14f:b2c0:21d1 with SMTP id d12-20020a056871040c00b0014fb2c021d1ls1135871oag.5.-pod-prod-gmail; Thu, 12 Jan 2023 08:59:36 -0800 (PST) X-Received: by 2002:a05:6870:f610:b0:15b:8862:3208 with SMTP id ek16-20020a056870f61000b0015b88623208mr1153241oab.28.1673542775944; Thu, 12 Jan 2023 08:59:35 -0800 (PST) X-Original-Sender: hborchew-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:31982 Archived-At: ------=_Part_2974_306383575.1673542775399 Content-Type: multipart/alternative; boundary="----=_Part_2975_744395668.1673542775399" ------=_Part_2975_744395668.1673542775399 Content-Type: text/plain; charset="UTF-8" Hello, There is an example lua filter in pandoc.org called: "Replacing placeholders with their metadata value" This does exactly what I need but for one exception: If I set a metadata value on the pandoc command line with --metadata=KEY[:VALUE] then the placeholder is not replaced with anything and not the command line VALUE using this example lua filter. Is there an easy fix for this? I am pasting the example from https://pandoc.org/lua-filters.html below. Thanks, Howard ---- local vars = {} function get_vars (meta) for k, v in pairs(meta) do if pandoc.utils.type(v) == 'Inlines' then vars["%" .. k .. "%"] = {table.unpack(v)} end end end function replace (el) if vars[el.text] then return pandoc.Span(vars[el.text]) else return el end end return {{Meta = get_vars}, {Str = replace}} -- 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/8db3a838-8431-4b75-aac1-94bc29fac675n%40googlegroups.com. ------=_Part_2975_744395668.1673542775399 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello,

There is an example lua filter in pandoc.org called:<= /div>
"Replacing placeholders with their metadata value"

This does exactly what I need but for one exception:
If I set a metadata value on the pandoc command line with=C2=A0--metadata= =3DKEY[:VALUE]
then the placeholder is not replaced with anything= and not the command line VALUE
using this example lua filter.

Is there an easy fix for this?

I am pasting the example from=C2=A0https://pandoc.org/lua-filters.h= tml below.

Thanks,
Howard
--= --
local vars =3D {}

function get_vars (meta)
=C2= =A0 for k, v in pairs(meta) do
=C2=A0 =C2=A0 if pandoc.utils.type(v) = =3D=3D 'Inlines' then
=C2=A0 =C2=A0 =C2=A0 vars["%" .. k .. "%"] =3D {= table.unpack(v)}
=C2=A0 =C2=A0 end
=C2=A0 end
end

function replace (el)
=C2=A0 if vars[el.text] then
=C2=A0 =C2=A0= return pandoc.Span(vars[el.text])
=C2=A0 else
=C2=A0 =C2=A0 retu= rn el
=C2=A0 end
end

return {{Meta =3D get_vars}, {Str= =3D replace}}

--
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/8db3a838-8431-4b75-aac1-94bc29fac675n%40googlegroups.= com.
------=_Part_2975_744395668.1673542775399-- ------=_Part_2974_306383575.1673542775399--