Nevermind, this definitely seems to be the right approach (single parameter). I guess I was just misreading the documentation, the section I was looking at was describing how to create one of these objects I think. Regardless, the lua filtering is super cool :) On Wednesday, January 9, 2019 at 7:49:45 PM UTC-8, sjm...-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org wrote: > > Thank you John, this is indeed much simpler than I was making it. > > Comparing with some of the example filters, when overriding these I should > basically always be doing `SomePandocThing(el)` where there's just one `el` > parameter? > > Thanks again! > > On Wednesday, January 9, 2019 at 12:08:33 PM UTC-8, John MacFarlane wrote: >> >> >> Try this: >> >> function Header(el) >> if FORMAT == "beamer" then >> table.insert(el.classes, "fragile") >> return el >> end >> end >> >> sjm...-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org writes: >> >> > Hello, >> > >> > I am trying to create a very simple lua filter for beamer presentations >> > that will always make sure that 'fragile' is added to a frame (to >> satisfy >> > minted, which i use for inline teletype text and code blocks). I think >> I >> > can figure out the lua specifics of figuring out how to first check the >> > list for `fragile` and if not found then add it, but where I'm stuck is >> > more basic. I can't figure out what my signature should even be here. >> > >> > if FORMAT == "beamer" or FORMAT == "latex" then >> > function Header(level, content, attr) >> > return pandoc.Header(level, content, attr) >> > -- return pandoc.RawBlock('latex', 'hahahaha') -- works hehehe >> > end >> > end >> > >> > >> > I wanted to just shadow it. So with a simple test file `test.md` >> > >> > # Section 1 >> > >> > ## This is Stuff {.fragile} >> > >> > - Look at this list >> > - Is it not nice? >> > >> > Yes it is. >> > >> > ## More Stuff {.allowframebreaks} >> > >> > 1. An ordered listing. >> > 2. Is even more nice. >> > 3. Depending on the context >> > >> > Running my simple filter gives >> > >> > pandoc -t beamer --lua-filter fragile_headers.lua test.md >> > Error running filter fragile_headers.lua: >> > [string "--[[..."]:208: Constructor for Header failed: [string >> "--[[..."]: >> > 239: attempt to index a nil value (local 'x') >> > >> > stack traceback: >> > [C]: in function 'error' >> > [string "--[[..."]:208: in function <[string "--[[..."]:203> >> > (...tail calls...) >> > >> > >> > I was going off of what I thought the signature was for Header in the >> docs >> > here: https://pandoc.org/lua-filters.html#blocks >> > >> > But it seems like `attr` is optional? >> > >> > I couldn't find any Header examples in the repo, and I'm really lost. >> I >> > feel like this is way easier than I'm making it, but what I wanted to >> do >> > was just append "fragile" in there. Then add in features like checking >> if >> > `level` is equal to 2, and don't add it if it's already there. But I >> don't >> > know how to get started. Is the `function Header` signature even >> correct? >> > >> > Thanks for any thoughts for somebody who has spent an embarrassing >> amount >> > of time trying to figure this out. >> > >> > -- >> > 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 post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/pandoc-discuss/b82d1c59-8f03-49df-ae3d-28bb92c63e57%40googlegroups.com. >> >> > For more options, visit https://groups.google.com/d/optout. >> > -- 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5f29ee8e-3481-446d-8a95-f488cedf2fae%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.