public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Norman Ramsey <fellswalker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: luacheck configuration for pandoc Lua filters?
Date: Thu, 13 May 2021 13:03:59 -0400	[thread overview]
Message-ID: <CACDk+QFFW3WKYo70rwz63QK-oCtuDnOzBjuQVdXWkvgv4HMwrw@mail.gmail.com> (raw)
In-Reply-To: <87mtszyt2e.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 3225 bytes --]

Perfect!  This will give me enough to go on with.

On Thu, 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 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 <fells...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.

[-- Attachment #2: Type: text/html, Size: 4730 bytes --]

      parent reply	other threads:[~2021-05-13 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 23:16 Norman Ramsey
     [not found] ` <7fd5e3eb-99cd-4bce-84c4-313077e96637n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-05-11  8:21   ` BPJ
     [not found]     ` <CADAJKhDRBLYw8E-J_8DWjcZsfYRuOiF24=dSbcEtXyLmrTkX8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-05-12 18:36       ` Norman Ramsey
     [not found]         ` <c4190975-7e98-446a-94a3-9f3df0e344b4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-05-13  7:46           ` Albert Krewinkel
     [not found]             ` <87mtszyt2e.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2021-05-13 17:03               ` Norman Ramsey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACDk+QFFW3WKYo70rwz63QK-oCtuDnOzBjuQVdXWkvgv4HMwrw@mail.gmail.com \
    --to=fellswalker-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).