That sounds like a clever solution: it doesn't change the data model or require pandoc to marshal all the parents for possible access. I'll wait for the next release, though.

Looking at the PR, I spotted a typo on line 233 of doc/lua-filter.md: "be" should be deleted from "will be try the following filter functions".

I see that the documentation only illustrates how to not traverse footnotes. Should it also illustrate how to apply a separate filter? The walk() method is new to me.

On Dec 13, 2021, at 6:15 PM, Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> wrote:


jcr <ffi.appdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

I find in Lua filters that I sometimes would like to know whether or not
I'm in a footnote. Currently, I'm trying to move punctuation before
footnotes. Given my citation style, I know that a Cite in body text will
produce a footnote, while a Cite in a footnote will not. So I want to move
punctuation before a Cite when it's not in a footnote. Since a filter
function for Inlines will descend into footnotes as well, there doesn't
seem to be any way to tell when the Cite is in a footnote.

[...] at least in the long term, I'd like to be able to tell whether
or not I'm in a footnote.

We just committed code[^1] that will help with this: it is now possible
to let the filter traverse the document top-down (root to leaves), and
to prevent processing of all element children by using `false` as a
second return value.

To exclude footnote contents from being processed, one can now use

   traverse = 'topdown'

   function Note (n)
     return n, false
   end

If you want to apply a *separate* filter in footnotes, you can write

   traverse = 'topdown'
   function Note (n)
     return n:walk(my_footnote_filter), false
   end

You should be able to try the feature after downloading the next nightly
build, which should become available at around 09:00 UTC.

[^1]: See https://github.com/jgm/pandoc/pull/7751/files

--
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/4S38_f_-384/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/87fsqwo28w.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/F8CB6356-E282-40D0-BCB6-36D0C8FAAF1C%40gmail.com.