public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* luacheck configuration for pandoc Lua filters?
@ 2021-05-10 23:16 Norman Ramsey
       [not found] ` <7fd5e3eb-99cd-4bce-84c4-313077e96637n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Norman Ramsey @ 2021-05-10 23:16 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 722 bytes --]

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.

-- 
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/7fd5e3eb-99cd-4bce-84c4-313077e96637n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1028 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: luacheck configuration for pandoc Lua filters?
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: BPJ @ 2021-05-11  8:21 UTC (permalink / raw)
  To: pandoc-discuss

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

Den tis 11 maj 2021 01:16Norman Ramsey <fellswalker-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.


> --
> 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/7fd5e3eb-99cd-4bce-84c4-313077e96637n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/7fd5e3eb-99cd-4bce-84c4-313077e96637n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhDRBLYw8E-J_8DWjcZsfYRuOiF24%3DdSbcEtXyLmrTkX8A%40mail.gmail.com.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: luacheck configuration for pandoc Lua filters?
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: Norman Ramsey @ 2021-05-12 18:36 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2009 bytes --]

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.

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.
>
>
>> -- 
>> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/7fd5e3eb-99cd-4bce-84c4-313077e96637n%40googlegroups.com 
>> <https://groups.google.com/d/msgid/pandoc-discuss/7fd5e3eb-99cd-4bce-84c4-313077e96637n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/c4190975-7e98-446a-94a3-9f3df0e344b4n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3427 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: luacheck configuration for pandoc Lua filters?
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: Albert Krewinkel @ 2021-05-13  7:46 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: luacheck configuration for pandoc Lua filters?
       [not found]             ` <87mtszyt2e.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2021-05-13 17:03               ` Norman Ramsey
  0 siblings, 0 replies; 5+ messages in thread
From: Norman Ramsey @ 2021-05-13 17:03 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-13 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 23:16 luacheck configuration for pandoc Lua filters? 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 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).