* very simple lua Header filter to always add fragile to beamer frames
@ 2019-01-09 10:55 sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <b82d1c59-8f03-49df-ae3d-28bb92c63e57-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: sjm324-HmMyXyqgL2CVc3sceRu5cw @ 2019-01-09 10:55 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 2569 bytes --]
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-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/b82d1c59-8f03-49df-ae3d-28bb92c63e57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 15241 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: very simple lua Header filter to always add fragile to beamer frames
[not found] ` <b82d1c59-8f03-49df-ae3d-28bb92c63e57-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-01-09 20:08 ` John MacFarlane
[not found] ` <yh480kpnt5387h.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2019-01-09 20:08 UTC (permalink / raw)
To: sjm324-HmMyXyqgL2CVc3sceRu5cw, pandoc-discuss
Try this:
function Header(el)
if FORMAT == "beamer" then
table.insert(el.classes, "fragile")
return el
end
end
sjm324-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-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/b82d1c59-8f03-49df-ae3d-28bb92c63e57%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: very simple lua Header filter to always add fragile to beamer frames
[not found] ` <yh480kpnt5387h.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2019-01-10 3:49 ` sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <986fcd9e-55b5-4b05-8784-1765985dfa13-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: sjm324-HmMyXyqgL2CVc3sceRu5cw @ 2019-01-10 3:49 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 4026 bytes --]
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 <javascript:> 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...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
> > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> <javascript:>.
> > 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/986fcd9e-55b5-4b05-8784-1765985dfa13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 6935 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: very simple lua Header filter to always add fragile to beamer frames
[not found] ` <986fcd9e-55b5-4b05-8784-1765985dfa13-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-01-10 10:40 ` sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <5f29ee8e-3481-446d-8a95-f488cedf2fae-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: sjm324-HmMyXyqgL2CVc3sceRu5cw @ 2019-01-10 10:40 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 4494 bytes --]
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.
[-- Attachment #1.2: Type: text/html, Size: 6928 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: very simple lua Header filter to always add fragile to beamer frames
[not found] ` <5f29ee8e-3481-446d-8a95-f488cedf2fae-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-01-10 20:02 ` John MacFarlane
0 siblings, 0 replies; 5+ messages in thread
From: John MacFarlane @ 2019-01-10 20:02 UTC (permalink / raw)
To: sjm324-HmMyXyqgL2CVc3sceRu5cw, pandoc-discuss
sjm324-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org writes:
> 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.
Yes, I think the docs could be clearer about that
distinction!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-10 20:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09 10:55 very simple lua Header filter to always add fragile to beamer frames sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <b82d1c59-8f03-49df-ae3d-28bb92c63e57-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-09 20:08 ` John MacFarlane
[not found] ` <yh480kpnt5387h.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2019-01-10 3:49 ` sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <986fcd9e-55b5-4b05-8784-1765985dfa13-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-10 10:40 ` sjm324-HmMyXyqgL2CVc3sceRu5cw
[not found] ` <5f29ee8e-3481-446d-8a95-f488cedf2fae-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-01-10 20:02 ` John MacFarlane
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).