From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29073 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William Lupton Newsgroups: gmane.text.pandoc Subject: Re: Passing multiple options to lua-filter from CLI Date: Fri, 20 Aug 2021 16:57:10 +0100 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fb803505c9ffb83b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12401"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBYVB76EAMGQEKRIF66I-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Aug 20 17:57:25 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f188.google.com ([209.85.208.188]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mH6tZ-0002wJ-A2 for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 20 Aug 2021 17:57:25 +0200 Original-Received: by mail-lj1-f188.google.com with SMTP id k11-20020a2e92cb0000b02901b84fac891dsf3349770ljh.6 for ; Fri, 20 Aug 2021 08:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629475044; cv=pass; d=google.com; s=arc-20160816; b=1H9+8kXmdZ79qOwMgfl1iLd95V1mbPnITVfmtciZSz5pzgqE6JM+6lqNJPNMKiBKnT 6Sb8qXdnctPGo3yg8nguQOuaUnfUmwxGUeNRvOy6fFFTIRAs50htdD3+oBXM9/wSsyxu vv4meD79rIVNZeMVZHn7+2pVoE0u5rt0bWYgrKoa7J2K1IWiiJzmgM6Ug6fMJjv921p4 uZOLjpsq7sHUGRHrgIoo0Q/2B727zlk3VQnYHW2eBU7ecbXfxsniKIy25klr/MRuBqfu JyXf9roaEP0lPs8GGLf5e5xcFxip90EKdOMp36Dd2QUQ+O+IciBBEL8l5a2ybDyY6ZQn 9lMQ== 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; bh=9U7QEG6Cm9kcMtM4KVHNQ8Mf0Z8ubl4j1CY5DTr87Qk=; b=mEV0oFSqTmdR0hoKxrJE2EtQ5INR5XeGphiv6vUTpKfQAy35hN7D6yxpvPAkgyLJ0Q rcy9x6fcdiAQdPY19LOIrXs+hHFoStwelSYhjmoIp0pnn2FZL/E/SETJoeAU8+zfb2aa GrGo4Lx0zBLhrBfqBgPgB5AkRCQ0PRJVHS6ORCc2/rSe4A/O6gF9eDcA9/59ob6YuC42 4+P9lxjhhCKciUVzpCcTBzwVM8+bAI+paicWvhshXXIYtY+rjeBX768MaoSx/kg08fNq MoYY3xxFjVH9obWqo1ogawBXsWA7Xg45QntNn+dTdqCcuZoDrkspFuQ9A0oBFJ9HBWLy jbBA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20150623.gappssmtp.com header.s=20150623 header.b=kxQvxv4q; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::633 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org 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=9U7QEG6Cm9kcMtM4KVHNQ8Mf0Z8ubl4j1CY5DTr87Qk=; b=jEA5pr9yPbfGlmhAmcm/WC6kqLZw9LzupBq9pWDMYMGdAFTycJYkTgSNvOIgNHEx9O NIA0v9ULYth4TkrzKRdpUQ7/Opxto9wdxxQa9i07Yr9SI/5c4qyGdxAeuQ6yX5+aI0Rn Bf0Xb+yTnYwdpeyyBIvgFrkUxt5aqZ5Nr+kRO3y+f958qEhMq/3KAlyvct8hvP77OrnJ 1WVfR2yn6oBFls0h6ZpLgjHvXbH9FV3FmA0mPQlLQuN/3vxxri9OPpB/NpyApIlpezxs 7wZWo3eWdEkCZXosoTbHE6dE6hTm3+aBWfH6My0Je6TLgiz+FxIrRuFqRuBkwcYawLHo JJQA== 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=9U7QEG6Cm9kcMtM4KVHNQ8Mf0Z8ubl4j1CY5DTr87Qk=; b=mVdzWb7ipL7NP8nK7I6d0DwxfIyUAweV1l4Fv2y1jK/zMuidp6Wx4TvYPV6ZdrmQZM 24O5GNoMFTKQ/amnhryf/IUZ6G9YIH+5aDYmZaVS5v8p9+lwZhsXBlPT2Pq7CQWaNoqM 6jhwR1mt7z5/Dif1ZMutqN3R5tTho3u8UPjeVa7ma1PhaU6qosuZT0RJj53+sG5a7tN2 ZNNqew3J1SYiP/UV57pFvg/JYBhkx0OA7LBfiUt2bj5Z7VuRm2uvjoPt5sqwQPBOhSuZ 24ivwNw7pMwiRevkPwYk5P368KCgD59tN2bgcebCO24axFzRrvlHUzeOJhBfzy/gVXUW KqIw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532RgOOR8jssDngHNQrzoO6p0uVQFHjqsxrZVsS7FTV0/uzjRF/B 7xBntKJ6Fri8bF7IGpIWVFo= X-Google-Smtp-Source: ABdhPJyOBsvc5HePrT4xi2wp7SbhVzyiov+k5CPt+xpgUrwJ9GFWVUlezVtH+pcrr6QqfN42Kfxs2A== X-Received: by 2002:a05:6512:1686:: with SMTP id bu6mr15503139lfb.168.1629475044418; Fri, 20 Aug 2021 08:57:24 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6512:c13:: with SMTP id z19ls623077lfu.0.gmail; Fri, 20 Aug 2021 08:57:21 -0700 (PDT) X-Received: by 2002:ac2:4db1:: with SMTP id h17mr15245749lfe.472.1629475041727; Fri, 20 Aug 2021 08:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629475041; cv=none; d=google.com; s=arc-20160816; b=LA0tzkZ1EFqRm3QVKME0T4zm3ym63Z1eSLLYxVbAyyAESUfJuxS7wdhAx4DEMhWn4c tCP4y24YvZHmeAA/7d4NgcKVb6V7pfz+kzXRrmBZpNYk5156sS84RKO0hVLA57So/ICL Pa6Qk5AjscoXx2jAN9T2GPq+tt4Ghg+u6GJSrr4DaTGxN1uksJdMLKuUOzUaTchkwziI S+t5PbOXNvNEBMOGLCWtBO6zTUA1288Fdma8fJ8suErVN9zv+vRmT+uJC169aWyjA+O3 kTXVL0VhT336xuKk0RueOFC3hBXsLHV9c9K9Y3eaHqBqdlOiL0GcO4lIWKgJUjzuWveo yVlQ== 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=HnKiCeAkNOnlpK03L7/bkOtB1oMSlVkDKv25TyAQAOc=; b=VMJf/J+i68WUTQZoACIy9QVXRAmLzs+qHafLlDZVl5h5nR5/z6Dr7fsGScZXgJkYx8 tLaJJRNhyLieRd71omgs85qGxRqUwmV7TUJVU12e1rAzEoVHfKcGalRBtmNFUYHV4pk/ dVukK2tY1MZxcKvUqSgeGJd92CL5dypwtaPMjmIEergPOnYw3/JhVb1wkvBXSmuUV0Rk t8+AXhxSNZdd4gfE49jM0ztHsyWgsFvKVGA/JQE9xFo2ngMlJbBQH67m/JN/OYbbaZJj BjCmmVY5n/ubEaG5bHwsYvnYfxYBZssBMHCSYDApaCXMcTzRYJjUbbuZapbfzvpP6ddS MC2g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20150623.gappssmtp.com header.s=20150623 header.b=kxQvxv4q; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::633 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org Original-Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com. [2a00:1450:4864:20::633]) by gmr-mx.google.com with ESMTPS id t8si505185lfc.11.2021.08.20.08.57.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Aug 2021 08:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::633 as permitted sender) client-ip=2a00:1450:4864:20::633; Original-Received: by mail-ej1-x633.google.com with SMTP id bt14so21195664ejb.3 for ; Fri, 20 Aug 2021 08:57:21 -0700 (PDT) X-Received: by 2002:a17:906:a28d:: with SMTP id i13mr21628272ejz.535.1629475040878; Fri, 20 Aug 2021 08:57:20 -0700 (PDT) In-Reply-To: X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20150623.gappssmtp.com header.s=20150623 header.b=kxQvxv4q; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2a00:1450:4864:20::633 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@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:29073 Archived-At: --000000000000fb803505c9ffb83b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_clas= s}} *% *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, numberLine= s > > but can't find a way. > > Thanks! > Cl=C3=A9ment. > > -- > 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/c025fcc7-ff39-4993-97f0-= 3dc8a7107724n%40googlegroups.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/CAEe_xxgqyK6%2BT3kmb7sNUckEJrS81cwm05iCvauKOA0Z3doRcg%40mail= .gmail.com. --000000000000fb803505c9ffb83b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think you need a two-pass filter, one to pick up the met= adata and the other to use it (this is because Meta is called nearly last).=

This works (I've re-ordered your functions and decl= ared a local variable, but this probably wasn't necessary).
<= br>

% cat default-code-class.lua<= span class=3D"gmail-Apple-converted-space">=C2=A0

local default_code_classes =3D {}


function get_default_code_class(meta)

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

=C2=A0 =C2=A0 de= fault_code_classes =3D {pandoc.utils.stringify(meta['default-code-class= '])}

=C2=A0 end

end


function add_default_code_class(el)

=C2=A0 if #(el.c= lasses) =3D=3D 0 then

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

=C2=A0 =C2=A0 re= turn el

=C2=A0 end

end


return {{Meta=3Dget_default_code_class}, {CodeBlock=3Dadd_default_c= ode_class}}


% pandoc -L default-code-class.lua code.md -M default= -code-class=3D"c numberLines"

<pre class=3D"c numberLines"><code></code&= gt;</pre>


On Fri, 20 Aug 2021 at 16:29, Cl=C3=A9ment = Aubert <aubert.clement@gmail= .com> wrote:
Hi,

This question relates to
There is a lua filter containing
=
``` lua
function add_default_code_class(el)
=C2=A0 if = #(el.classes) =3D=3D 0 then
=C2=A0=C2=A0=C2=A0 el.classes =3D default_co= de_classes
=C2=A0=C2=A0=C2=A0 return el
=C2=A0 end
end

func= tion get_default_code_class(meta)
=C2=A0 if meta['default-code-class= '] then
=C2=A0=C2=A0=C2=A0 default_code_classes =3D {pandoc.utils.st= ringify(meta['default-code-class'])}
=C2=A0 end
end
```

and I'm trying to tweak it so that two classes c= an be passed from the command-line, eg. using

--lua-filter default-code-class.lua -M default-code-class=3Dc, numbe= rLines

but can't fin= d a way.

Thanks!<= /div>
Cl=C3=A9ment.

--
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 pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https= ://groups.google.com/d/msgid/pandoc-discuss/c025fcc7-ff39-4993-97f0-3dc8a71= 07724n%40googlegroups.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://group= s.google.com/d/msgid/pandoc-discuss/CAEe_xxgqyK6%2BT3kmb7sNUckEJrS81cwm05iC= vauKOA0Z3doRcg%40mail.gmail.com.
--000000000000fb803505c9ffb83b--