If you want to know whether something is a table capable of doing some known method you can generally do this:

``````lua
if 'table' == type(thing) then
  if 'function' == type(thing.includes) then
     io.stderr:write"A thing has a method 'includes'\n'"
  end
end
``````

In the context of Lua filters you would typically put the above code in a dummy global Pandoc function and run the "filter" with just

``````commandline
pandoc -L dummy.lua
<Ctrl-D>
``````

and if the test is successful you will see the message.

On Windows you would press <Ctrl-Z> rather than <Ctrl-D>.

--
Better --help|less than helpless

Den mån 14 dec. 2020 00:21Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
Ah thanks I wasn't sure when the methods in pandoc.List could be used. Perfect!

J

On Sunday, December 13, 2020 at 10:17:18 PM UTC Albert Krewinkel wrote:

Julien Dutant writes:

> What's the favoured method to check an element's class in Lua filters? In
> the manual a couple of examples use the following:
>
> if element.classes[1]="myclass" then
>
> But that's not robust if the element has several classes and `myclass` is
> not the first:

A convenient and robust check is `element.classes:includes 'myclass'`.

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

--
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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/eff82021-0b6e-4b66-bef9-55cc9ecc437an%40googlegroups.com.

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCwR4xNTKioAovbBti97zb%3DA7MN7AC2q5_y-cTjGb0ofA%40mail.gmail.com.