From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29075 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment_Aubert?= Newsgroups: gmane.text.pandoc Subject: Re: Passing multiple options to lua-filter from CLI Date: Fri, 20 Aug 2021 12:06:26 -0400 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000018c3c905c9ffdb88" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25990"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCM37TODUUORBHVG76EAMGQEFISHCKY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Aug 20 18:06:57 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qt1-f192.google.com ([209.85.160.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mH72m-0006U1-RQ for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 20 Aug 2021 18:06:56 +0200 Original-Received: by mail-qt1-f192.google.com with SMTP id 98-20020aed316b000000b00298da0dd56bsf5031706qtg.13 for ; Fri, 20 Aug 2021 09:06:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629475615; cv=pass; d=google.com; s=arc-20160816; b=ZiVGUUaUovT17reoq1eCy3C6/qyUy0joiUtXN7gM73QiVbfZf5wze0ImUFl9qjk/ru LCK912Q4AgtMeFBmNZ5TzLJ0rQNukZkZ8pzEzmwBImcCBHz8aBbtDq3NgjqAK+CrJS1t L/EPUQbq+5O6WdDsvrpYRcdeWcTiAiI/7d7oMsy6i+iAC4MeLSErTJEdXlrT1ydjMihG yKVtKL94eV0qx+PsrPq7GBFqOMI7VIVR9d15vymCgpOcNKBWTAzIv5LdNObL3d9Ggr6N Wfa/934H5NiS6EpfV+oZL1e1UMx5VNYafujItZL6NOQ7I/6uC9aFvljQXomxabeJSaXh D7Ig== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=xzzdlLC1mRQe3rcqdu+7Ch9ZW+W88qABkSJuYlmsBQM=; b=f2otcGTRdgbl5OtFYo2ioBclRqJXEffASB8ZWlfe5iyLhwS5feeBVFlxpNtfiDKhqX si3e2JtEWu5HDMIkoxVaEDdpPJk9/9Nm+xnRy4HNsrvi3sdC5CM0fVTJrNgqaaJ5Vzs5 H23Y4rWHNlrJVADV/MbJEXTjd+6KlFFJ/QDhSqXRmemv6UMgkVX1ujO2HE7SSod8EVSg lRXI7BKoHHfSrtSwyqBoMIbSZ+aJMLDFl4T0yp4cbXKQRTe6Il4nMSS7oOEh5zTDbrhX ewFvY90jv/wWJ/Wtk6V+lP7eRbTwurRZY06h8/91oZ0TgzMbwcnnJ7XA9bNBhTugB+TV 2/Rw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lp6UtJjw; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42b as permitted sender) smtp.mailfrom=aubert.clement-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:mime-version:references:in-reply-to:from:date:message-id :subject:to: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=xzzdlLC1mRQe3rcqdu+7Ch9ZW+W88qABkSJuYlmsBQM=; b=iwPcyUh9CG9x6r8wiFcKQf6N5qmNNo2uXT0+DLFuTGnuQz4LuZfaNkWsM5V8/7ViJ6 y99GrsEm+bT/6tyxPbgOfc0qB+/omUZ2ki4yQ6eaIsEytpBkV7U+uNKjQXXGLxCtWADD DKdY9AFNxkBdI9VtO1YLyY+SIRavu6NnI2sfPv2L16jzpBaFAyG2+oplxdZN0xTtXp5l XKxfgHdyGz/GIuHdq2lmXOpULIh82d/9aZKUuWAubjsncZtCLQKaeC6qBuk8kyaV0+Wz Af9BEpS8ezjZgkhC/xuToO1+R8tcErIDs/9Drl6ANzfElVaxqnEzCv/zAucEbOhcyHpo rkMg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :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=xzzdlLC1mRQe3rcqdu+7Ch9ZW+W88qABkSJuYlmsBQM=; b=P/Vyl4GXV4Pu8UtKvxrKLooUtImE4x1GVuRTwNxFG59CsbQbLjFoll8W5Blft5ROIU jyOsFvQ7kT7LXyX8Ke6zpLUwgl4E3nbbHV6qsVL7dABMWVR7NmIcnzJC9CFPjpkzZhl0 FNNLYhYIPFUAKiC/G189JYNXytXKwviJNKLSHo7IZoSTGzYbx6S0cce2Lc1whh2cfHbO +TA5en4DAR85IFUGvHUFt6zsSi34RCX4x2MAjQ/KzAfAwLMVshDz6yq/BXVjJjzs3dGA rfiwh+7N2PjoHD/fdtIrL/eE6ymK0eZ6yNiiTq7aeM4l2biFUr0/YLbcwl/FcYoJLDUu JImA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to: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=xzzdlLC1mRQe3rcqdu+7Ch9ZW+W88qABkSJuYlmsBQM=; b=Z2BMheV3U7OL2aESngdLyrJCtQgIO3W5YJq643xAWQqofbpPnTkBkX6B3O927YoFkW NM/cFdBm8s6P3YRBP+cUnVxIQl4EfJ9s5iymO4rSCeNre+9fBDF/SLxLCqaqjU4SztOI sUg9sdY2mJfHN9aPeUJkvIHUnesYaUF5kdIdZya6qxJBgodRRQU8uZ2TtzzMPRQRKy5k cyjez7816ZgAnEBrgn+CUnhpl+Ixw/kGpKEZMKWJiRpbWDnFNSQOLHudPJZL55t+exOu QmXCRPPFIFsQ2Tl5NzpRQ0mxtprLKZlUzKZdS+h7Q7NX1r7V8UkGVMkyBcy1Su/ktlB3 WdeQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532xih/KaOYTMeqIDgsBzH+Hm4ZJFlcbjpMpXkbaDVY+NJQbd6ZO 76HWf/dfwmLoZyCCxGQnF5U= X-Google-Smtp-Source: ABdhPJxdxPtqIVmthg5NKAtW5PqU45ivQY4YxhDWYIQJ3m6/Gjun6Q2vf3wM+/5M3Tt7pNzcCqlXKA== X-Received: by 2002:a0c:fcd1:: with SMTP id i17mr20980707qvq.13.1629475615638; Fri, 20 Aug 2021 09:06:55 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:620a:88d:: with SMTP id b13ls3825489qka.6.gmail; Fri, 20 Aug 2021 09:06:54 -0700 (PDT) X-Received: by 2002:a05:620a:b4f:: with SMTP id x15mr9589070qkg.436.1629475613957; Fri, 20 Aug 2021 09:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629475613; cv=none; d=google.com; s=arc-20160816; b=DUfR+90fTSFnuDtRIB1irYylUlt9O0nQ/YrUEhDBLLf2rCGE7zc/iC9m1mKusDxdKL 8YtrZUUkPbs9pC7LMzAu5vKH/ywdLWfv18Sl8BouLAETjwrUmiHDo1d0HcUau0ZNMTD5 okSqvXeuBuSi5DKCUrtnYG1JPi30UR7xFk0BjZEQW4JqoWOhgExJ50cxov/MkgqhNU6N 3m/vxNUuZeVThvkUZGZW+nmzwiNa6GWXU2f6Ms8Q9WRX4/CWVkaMzsucN8qKIkCqNCsY Qa8T8UcHHOsMF4lJawPjdo6xsvAr9JdEJKYQSz1Mbqs6zJUEwfM3HtXhmZdqFaPJcr0V gEYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SOlIBkNCqCVhBh6Uk3Fhpu7oEeLJZYJvFvKVC4L1KIs=; b=cGoujO/ISTHhizEulbD3kZ/hUGaJg9sYvx99GPLH6fyG/Mdk+Oqyp++ll8o9H0aHaZ zNVDZMcigAoK3itLyd9YzulIXOjcePdfOTzDTCdqBbYLqF+beGDp67jdNYaW/cBrvYPk utqUiFzS6TeN0q17ydrrXAz7JKbi75xKbfIJzx22XD2v4gwABOD79Z3oz2CRRjzVcW/H wrePSHjVzMQFi3xVfoieiMYHzJleJLw5cP+Z3av3R6F3KKa/l7IU+0eh2rOhwO0qyaGt aMcIEUwJO/Yjt9UjtfWUDpVxw0GrQIT5R3lompOzayFr7y9v/zozALeLwG9xx4Dq4AxP vuEw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lp6UtJjw; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42b as permitted sender) smtp.mailfrom=aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com. [2607:f8b0:4864:20::42b]) by gmr-mx.google.com with ESMTPS id s29si319098qtc.5.2021.08.20.09.06.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Aug 2021 09:06:53 -0700 (PDT) Received-SPF: pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42b as permitted sender) client-ip=2607:f8b0:4864:20::42b; Original-Received: by mail-pf1-x42b.google.com with SMTP id w68so8989588pfd.0 for ; Fri, 20 Aug 2021 09:06:53 -0700 (PDT) X-Received: by 2002:a05:6a00:238e:b029:35c:c5e:b82d with SMTP id f14-20020a056a00238eb029035c0c5eb82dmr20490889pfc.33.1629475613229; Fri, 20 Aug 2021 09:06:53 -0700 (PDT) In-Reply-To: X-Original-Sender: aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lp6UtJjw; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42b as permitted sender) smtp.mailfrom=aubert.clement-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:29075 Archived-At: --00000000000018c3c905c9ffdb88 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks a lot for looking into it! It does not seem to produce the desired effect on my end. Could you explain how changing return {{Meta =3D get_default_code_class}, {Code =3D add_default_code_class}, {CodeBlock =3D add_default_code_class}} into return {{Meta=3Dget_default_code_class}, {CodeBlock=3Dadd_default_code_clas= s}} (as far as I can tell, this is the only modification) is supposed to achieve the desired effect? Thanks! Le ven. 20 ao=C3=BBt 2021 =C3=A0 11:57, William Lupton a =C3=A9crit : > I think you need a two-pass filter, one to pick up the metadata and the > other to use it (this is because Meta is called nearly last). > > This works (I've re-ordered your functions and declared a local variable, > but this probably wasn't necessary). > > *% *cat default-code-class.lua > > local default_code_classes =3D {} > > > function get_default_code_class(meta) > > if meta['default-code-class'] then > > default_code_classes =3D > {pandoc.utils.stringify(meta['default-code-class'])} > > end > > end > > > function add_default_code_class(el) > > if #(el.classes) =3D=3D 0 then > > el.classes =3D default_code_classes > > return el > > end > > end > > > return {{Meta=3Dget_default_code_class}, {CodeBlock=3Dadd_default_code_cl= ass}} > > > *% *pandoc -L default-code-class.lua code.md -M default-code-class=3D"c > numberLines" > >
> > On Fri, 20 Aug 2021 at 16:29, Cl=C3=A9ment Aubert > wrote: > >> Hi, >> >> This question relates to >> https://github.com/jgm/pandoc/issues/2104#issuecomment-595983954 >> There is a lua filter containing >> >> ``` lua >> function add_default_code_class(el) >> if #(el.classes) =3D=3D 0 then >> el.classes =3D default_code_classes >> return el >> end >> end >> >> function get_default_code_class(meta) >> if meta['default-code-class'] then >> default_code_classes =3D >> {pandoc.utils.stringify(meta['default-code-class'])} >> end >> end >> ``` >> >> and I'm trying to tweak it so that two classes can be passed from the >> command-line, eg. using >> >> --lua-filter default-code-class.lua -M default-code-class=3Dc, numberLin= es >> >> but can't find a way. >> >> Thanks! >> Cl=C3=A9ment. >> >> -- >> You received this message because you are subscribed to the Google Group= s >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n >> 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/c025fcc7-ff39-4993-97f0= -3dc8a7107724n%40googlegroups.com >> >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "pandoc-discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscribe. > To unsubscribe from this group and all its topics, 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/CAEe_xxgqyK6%2BT3kmb7sNU= ckEJrS81cwm05iCvauKOA0Z3doRcg%40mail.gmail.com > > . > --=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/CAPGHSezmvUZSEApp0fGCezjUNcqSJJCMBaLGTaPUc86tSoUS0A%40mail.g= mail.com. --00000000000018c3c905c9ffdb88 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks a lot for looking into it!
It does n= ot seem to produce the desired effect on my end.

C= ould you explain how changing
return {{Meta =3D get_default_code_= class},
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {Code =3D add_default_code_class},=C2=A0 =C2=A0 =C2=A0 =C2=A0 {CodeBlock =3D add_default_code_class}}
<= /div>
into
return {{Meta=3Dget_default_code_class}, {CodeBloc= k=3Dadd_default_code_class}}
(as far as I can tell, this is the o= nly modification) is supposed to achieve the desired effect?

=
Thanks!

Le=C2=A0ven. 20 ao=C3=BBt 2021 =C3=A0=C2=A011= :57, William Lupton <wlup= ton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> a =C3=A9crit=C2=A0:
I think you need a two= -pass filter, one to pick up the metadata and the other to use it (this is = because Meta is called nearly last).

This works (I'v= e re-ordered your functions and declared a local variable, but this probabl= y wasn't necessary).

% = cat defau= lt-code-class.lua=C2=A0

local default_code_classes =3D= {}


function get_default_code_clas= s(meta)

=C2=A0 if meta[&#= 39;default-code-class'] then

=C2=A0 =C2=A0 def= ault_code_classes =3D {pandoc.utils.stringify(meta['default-code-class&= #39;])}

=C2=A0 end=

end


function add_default_code_clas= s(el)

=C2=A0 if #(el.cl= asses) =3D=3D 0 then

=C2=A0 =C2=A0 el.= classes =3D default_code_classes

=C2=A0 =C2=A0 ret= urn el

=C2=A0 end=

end


return {{Meta=3Dget_default_co= de_class}, {CodeBlock=3Dadd_default_code_class}}


<= span style=3D"font-variant-ligatures:no-common-ligatures;color:rgb(128,42,2= 5)">% pandoc -L default-code-class.lua code.md -M default-code-class=3D"= c numberLines"

<pre class=3D"c number= Lines"><code></code></pre>

=

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://g= roups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p= andoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgqyK6%2BT3= kmb7sNUckEJrS81cwm05iCvauKOA0Z3doRcg%40mail.gmail.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/CAPGHSezmvUZSEApp0fGCezjUNcqSJJCMBaLGTaPU= c86tSoUS0A%40mail.gmail.com.
--00000000000018c3c905c9ffdb88--