I've figured out a workaround, but just wondering if there's a better way than diving into the metatables:

~~~
function fix_table_strings(t)
  for k, v in pairs(t) do
    if type(v) == "table" then
      local metatable = getmetatable(v)
      if metatable ~= nil and metatable.__name == "Inlines" then
        t[k] = pandoc.utils.stringify(v)
      else
        fix_table_strings(t[k])
      end
    end
  end
end
~~~

On Tuesday, May 24, 2022 at 9:30:41 AM UTC+3 Shane Liesegang wrote:
Is there a way to tell whether a given object is a pandoc.Inlines as opposed to a plain Lua table? When I call `type(obj)` on it, it just returns "table." I note that if I print it, it shows "Inlines:" instead of "table:" but is there any smarter way to determine?

I see some code in the Lua filters example repository that does this kind of check, but I don't know if it's crucial to that code or not, if something has changed recently, etc.

(My use case here is walking through my Meta object and building something that will get passed to different functions -- if it encounters a nested table of data, I need to recurse, but if it's an Inlines object, I want to stringify it.) 

--
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/0a182969-9df6-4462-aae8-28f34d5b2e37n%40googlegroups.com.