From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28342 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Norman Ramsey Newsgroups: gmane.text.pandoc Subject: Re: luacheck configuration for pandoc Lua filters? Date: Thu, 13 May 2021 13:03:59 -0400 Message-ID: References: <7fd5e3eb-99cd-4bce-84c4-313077e96637n@googlegroups.com> <87mtszyt2e.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b62df305c2391d25" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35560"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBC5MLC7FZABRBDFY6WCAMGQEG6WFQCY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu May 13 19:04:15 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pg1-f190.google.com ([209.85.215.190]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lhEkx-00096n-2Z for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 13 May 2021 19:04:15 +0200 Original-Received: by mail-pg1-f190.google.com with SMTP id m7-20020a6545c70000b029020f6af21c77sf17600259pgr.6 for ; Thu, 13 May 2021 10:04:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1620925454; cv=pass; d=google.com; s=arc-20160816; b=rNYrRC3Rt83Tk/htk/mIvGU1EEwBVT7QY/vmnV97In0DQR3iCWVBunuKwVwp3Aesry Vp5EZPwWFxAQeBfYG4D4f3iCuluj7U0IfhYGfO3iHhhdlmeAtipZod9s2N5V405DiCyy D9MUccKthhjgaYb4bjz2QR0kWMdTouS2hp8CFwF9gtMMiX1DftjFjnT/j8YktyIjDlQ1 zaKmjYgDd6nbyQ8qwvC0RU/+DyirTDCdhiKt4CKRfJfIXQ3JPJrNIz+9aUCEYpiS/e13 HJ5eFUhrGBpvvxtvA6qs4nAlRgVfc00na6+B66d6l0bfDWnlft5IuuqoVmxm5+8qsTBs 5muw== 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=J2xXevZeCGBR11/4zMVRFI4uB4DkEUqu4aPQh/njLzo=; b=jjc0VFQ02pKGIGKUIMErbxC9xD/puJj516fGd73Q9yqlYMNKkxnYhSe3amcYGfwxcW 634pNXcN4brAUKfBt9uDZKq1/3pJmk19czpuRiaUNwn88ptEQvAr+t5iS/TuIYzF+xBM gKD4WIt4k6SoyBGCcLxnwbCPi0TClJagop3p42XJO8Dk74Hbz0XvHch4AUELIBzwmYqA 7CsFKmjoQDIPhZHZ1EYUj9vz5BKdL7vC98UFjkI4LdLTlcrkCb8MyIT9OBfIDPvdXJen +oFT9w88zm4D2Mra5Cq4XvQXlRDD/nxhYQj/dBMjQLdMSXcVa3bHb/2T/0drp+JPSfoi y7Ug== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YMZfPKGM; spf=pass (google.com: domain of fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42a as permitted sender) smtp.mailfrom=fellswalker-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=20161025; 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=J2xXevZeCGBR11/4zMVRFI4uB4DkEUqu4aPQh/njLzo=; b=Zw6vAKQThNm3nZBB6BTwqaXPbfhYCvZtggtE8BjIRJVUGw6aPiU72manu52A8EkpBB drDKNHUNnuE+HoXYHoxl1MxGAMoG4nOvxogkgrUDKZ/TXyjwruHktdHiud2C7Qkx/m9Y Xtt7eXZ+bsB3FrVPd/RfpPFfObx74EcqFKISJPj0PW/AcOtNx0DXe6s1m3h1m7HV2JRk oqC8BsK9QuFgEmQGe7bguqeWlwpNC2k2e9PKisfSWs2eqzDpbD1qjbG2PzkapQm+GkwX l1h4FoOoc0u+0hdFy34ad07Ogkq4mfGZTuUJkxcE4a4jt32+FkMnW/mOqyye3mDCIuXh s0FA== 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=J2xXevZeCGBR11/4zMVRFI4uB4DkEUqu4aPQh/njLzo=; b=uADR/w1uOK6lhG6UbRQ4CP3QYkazSo56vkjbrJ1/5Zq6DZHLrgDuuXI4bRFVJfw0ml L6TZgzS7/ttJCSRvLEIW4YL9rVCvKubIY9pNTfEbeLQUyKE5QLHI6CFUHrOJ0lukps+j iBgYwWILiNgqhLlB8VDRCTqh+0BFxT0S9MDUmR6pjp6shpUO5LTus3rhBqWadnhkqygf 2p6mDXk08q6K50NDLe7bzEa2U62R3bOwZC0SKDrpGVb9M1bPvsmOsIwSnNGYlZigFQoa braIWYob+ocSR5Zao//ZNNJoRq/tuX8SILZnfyU+rjtGvzxfbrTAqYY7ph9R4Wuf06Q7 52hA== 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=J2xXevZeCGBR11/4zMVRFI4uB4DkEUqu4aPQh/njLzo=; b=iogLZqFmGugxyFiSiiuBM5qjZtFtwtq3dewSKG+mrVbnnGg66OlIS4s9bYKfB66sQt otegvAIVHjpKdL4w6XjDIn9GoHWah5YdECVkIYdhSekLhrUDyqp/ZffzGrTP1wZ+I2+S 6jTbkhy0bR5ymyop5DKSXm4KTTHUZiGxbRsD9xmBIczrwBq4gdW6iuONbaQB65Ef5F/a kXIu2UScVio7O0OR2/lMsEhP2xiZsJnwjl47pyhrLMYKXItXgps+U4J7g4TFP7aW1jvF Wkt+yxmVFqxRRPJeFdBgxX6w1riKZ7Db+DGTX4hHj5itrYCo7AcDolyXq0bEycGkqD6V I2kg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532/WVPP9O7nXVcaJkTznNAOU/ZkK52DlGMomIrCXf17MHWciahY fjCF9iV/KCfu8ln6D+T4yuw= X-Google-Smtp-Source: ABdhPJxqI9IhywjZKcb/0kujZXOq4fmqF0qEkynYfqWCHHxiymbtqxk20OFPHf55OrjZMiMfLl5l+w== X-Received: by 2002:a17:902:ecce:b029:ee:cf77:3b22 with SMTP id a14-20020a170902ecceb02900eecf773b22mr41079605plh.46.1620925453846; Thu, 13 May 2021 10:04:13 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:902:9a0a:: with SMTP id v10ls3429447plp.6.gmail; Thu, 13 May 2021 10:04:11 -0700 (PDT) X-Received: by 2002:a17:903:2403:b029:ee:eaf1:848d with SMTP id e3-20020a1709032403b02900eeeaf1848dmr41024159plo.63.1620925451631; Thu, 13 May 2021 10:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620925451; cv=none; d=google.com; s=arc-20160816; b=dEClTojzbp2plC2qU60TKzl11r1A4VWBJmdU8Z0FH9GJI/bn31oN+/X41FrCzSIJz2 QfaXFhf7XFczv2bjbaNGEIMi1FdBf9gZTec0FYrHBWvHs8CYNu6awsyb/cZgBXAZBcLa gA03ZHhMpz3aPn+XVYdsXCbI35P4/JnYEdN7pomVOkxInBc1HFbJ3cWzVGgLYe7xHWWc bJ6c5ZOuNGKYmYdzEBa0POpd/ygq6EQRXFogGfSyupJ1SJamCf2jC/8NAaq9fczWTSiX zbinGgxr0pBijIRBG55995zyqdxW9BrP5rIGutBSGH8kinIFHqkojHLOvzZP1QxfV6w7 YEQw== 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=Hcs6CWvGWHgp3skc/m5U0rbR6j22kxuITIGcnA8FIdE=; b=b7Pru5Smqsu28uJSgJZW42Ox9KlMXlewmfK5+FnyxOsNcYYecZUXzd7gXN/SKteMfN ms+l5Q1l6SX/fwgY2WT7rBQ/F/hxnKo7CE2Pg7HnR2lMMR8vHMQa10oyguR29GM15bdC N/2c1DRnwwCVaDcIqgx+PuwVs2hOHEDs/SdV3kTkWEoC/JzuNDaNz5AjV0KpDX0OhLqo iHiMkwyzs/xjiugEh/v19Mdh4LNyMcCE61CsTAoXfre5aj+SHe35O6aXq1o3OshAozby KPNPtvEjGgFxDOiX5osUz1POF3vFJ1KQTojHXjnKYm8a76OP/FbZi7I0Iz8JFuwKkpge g04Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YMZfPKGM; spf=pass (google.com: domain of fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42a as permitted sender) smtp.mailfrom=fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com. [2607:f8b0:4864:20::42a]) by gmr-mx.google.com with ESMTPS id n21si444129pjq.1.2021.05.13.10.04.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 May 2021 10:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42a as permitted sender) client-ip=2607:f8b0:4864:20::42a; Original-Received: by mail-pf1-x42a.google.com with SMTP id h16so9610795pfk.0 for ; Thu, 13 May 2021 10:04:11 -0700 (PDT) X-Received: by 2002:a63:cf13:: with SMTP id j19mr42297187pgg.166.1620925450955; Thu, 13 May 2021 10:04:10 -0700 (PDT) In-Reply-To: <87mtszyt2e.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YMZfPKGM; spf=pass (google.com: domain of fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::42a as permitted sender) smtp.mailfrom=fellswalker-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:28342 Archived-At: --000000000000b62df305c2391d25 Content-Type: text/plain; charset="UTF-8" Perfect! This will give me enough to go on with. On Thu, May 13, 2021 at 3:46 AM Albert Krewinkel wrote: > > Norman Ramsey writes: > > > luacheck works with one module at a time, so all I need to do is figure > out > > the _names_ of the callable objects. I could poke at metatables or could > > assume conservatively that all objects are callable. What I don't know > how > > to do is find callable names that _aren't_ materialized in the `pandoc` > > table but are available only via an `__index` metamethod. > > We don't do any metatable magic on the pandoc module itself, so > iterating over the module table should give us all objects. As BPJ > points out, some functions are actually callable tables, so we have to > check for those. Also, the three objects 'Block', 'Inline', and > 'MetaValue' are callable, but always lead to errors when called. > Therefore, the following code should print all the names we are after: > > local dont_call = pandoc.List{'Block', 'Inline', 'MetaValue'} > > for k, v in pairs(pandoc) do > if not dont_call:includes(k) and > (type(v) == 'function' or > getmetatable(v) and getmetatable(v).__call) then > print(k) > end > end > > The refactored Lua subsystem that I'm working on will do away with these > silly inconsistencies -- just testing if an object has type "function" > will be enough. > > > > On Tuesday, May 11, 2021 at 4:21:47 AM UTC-4 BP wrote: > > > >> Den tis 11 maj 2021 01:16Norman Ramsey skrev: > >> > >>> I've recently discovered `luacheck`, a fantastic static-analysis tool > for > >>> Lua programs. I'd like to use it with my Pandoc filters, but it needs > a > >>> configuration to tell it what functions in the global `pandoc` table > are OK > >>> to call. If anybody happens to have made such a configuration, please > let > >>> us know. > >> > >> > >> I guess the fact that most of the constructors in the pandoc library are > >> actually callable objects rather than functions may be a problem one > way or > >> another. > > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > > -- > 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/Uzk5WJOxDmg/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/87mtszyt2e.fsf%40zeitkraut.de > . > -- 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/CACDk%2BQFFW3WKYo70rwz63QK-oCtuDnOzBjuQVdXWkvgv4HMwrw%40mail.gmail.com. --000000000000b62df305c2391d25 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Perfect!=C2=A0 This will give me enough to go on with.
On T= hu, May 13, 2021 at 3:46 AM Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> wrote:

Norman Ramsey <fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> luacheck works with one module at a time, so all I need to do is figur= e out
> the _names_ of the callable objects.=C2=A0 I could poke at metatables = or could
> assume conservatively that all objects are callable.=C2=A0 What I don&= #39;t know how
> to do is find callable names that _aren't_ materialized in the `pa= ndoc`
> table but are available only via an `__index` metamethod.

We don't do any metatable magic on the pandoc module itself, so
iterating over the module table should give us all objects. As BPJ
points out, some functions are actually callable tables, so we have to
check for those. Also, the three objects 'Block', 'Inline',= and
'MetaValue' are callable, but always lead to errors when called. Therefore, the following code should print all the names we are after:

=C2=A0 =C2=A0 local dont_call =3D pandoc.List{'Block', 'Inline&= #39;, 'MetaValue'}

=C2=A0 =C2=A0 for k, v in pairs(pandoc) do
=C2=A0 =C2=A0 =C2=A0 if not dont_call:includes(k) and
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (type(v) =3D=3D 'function' or
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0getmetatable(v) and getmetatable(v).__cal= l) then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 print(k)
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0 end

The refactored Lua subsystem that I'm working on will do away with thes= e
silly inconsistencies -- just testing if an object has type "function&= quot;
will be enough.


> On Tuesday, May 11, 2021 at 4:21:47 AM UTC-4 BP wrote:
>
>> Den tis 11 maj 2021 01:16Norman Ramsey <fells...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
>>
>>> I've recently discovered `luacheck`, a fantastic static-an= alysis tool for
>>> Lua programs.=C2=A0 I'd like to use it with my Pandoc filt= ers, but it needs a
>>> configuration to tell it what functions in the global `pandoc`= table are OK
>>> to call.=C2=A0 If anybody happens to have made such a configur= ation, please let
>>> us know.
>>
>>
>> I guess the fact that most of the constructors in the pandoc libra= ry are
>> actually callable objects rather than functions may be a problem o= ne way or
>> another.


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

--
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://groups.google.com/d/topic/pandoc-discuss/Uzk5WJOxDmg/un= subscribe.
To unsubscribe from this group and all its topics, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87mtszy= t2e.fsf%40zeitkraut.de.

--
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/CACDk%2BQFFW3WKYo70rwz63QK-oCtuDnOzBjuQ= VdXWkvgv4HMwrw%40mail.gmail.com.
--000000000000b62df305c2391d25--