* How to deal with nested divs in lua filter
@ 2020-10-28 6:28 jiewuza
2020-10-28 9:28 ` jiewuza
[not found] ` <m2a6w6zwxu.fsf-9Onoh4P/yGk@public.gmane.org>
0 siblings, 2 replies; 8+ messages in thread
From: jiewuza @ 2020-10-28 6:28 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
I have nested divs in my document.
I have in my lua filter:
```
function handleDiv(el)
if el.classes:includes("parent") then
return handleChild(el.content) ----- here content is {}
end
return {}
end
```
But I find the content of the parent div is empty. And it seems that
each child div triggers `handleDiv` before the parent does.
What I want is to deal with the child divs only in `handleChild` without
triggering `handleDiv`.
Is there any suggestions?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to deal with nested divs in lua filter
2020-10-28 6:28 How to deal with nested divs in lua filter jiewuza
@ 2020-10-28 9:28 ` jiewuza
[not found] ` <m2a6w6zwxu.fsf-9Onoh4P/yGk@public.gmane.org>
1 sibling, 0 replies; 8+ messages in thread
From: jiewuza @ 2020-10-28 9:28 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org> writes:
I guess I have to return nil to keep the content.
And deal with it in `handleChild`.
> I have nested divs in my document.
> I have in my lua filter:
>
> ```
> function handleDiv(el)
> if el.classes:includes("parent") then
> return handleChild(el.content) ----- here content is {}
> end
> return {}
> end
> ```
>
> But I find the content of the parent div is empty. And it seems that
> each child div triggers `handleDiv` before the parent does.
>
> What I want is to deal with the child divs only in `handleChild` without
> triggering `handleDiv`.
>
> Is there any suggestions?
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <m2a6w6zwxu.fsf-9Onoh4P/yGk@public.gmane.org>]
* Re: How to deal with nested divs in lua filter
[not found] ` <m2a6w6zwxu.fsf-9Onoh4P/yGk@public.gmane.org>
@ 2020-10-28 17:22 ` John MacFarlane
2020-10-29 5:57 ` jiewuza
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: John MacFarlane @ 2020-10-28 17:22 UTC (permalink / raw)
To: jiewuza, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
Yes, it's a bottom-up traversal of the tree, so child nodes
will be processed before the parent.
Doing top-down traversals in filters is currently tricky.
You can, of course, do it manually, with a for loop around
the blocks in Pandoc, but that's clunky.
Maybe Albert has ideas on how we could make top-down
traversals possible. (I needed one in pandoc's citation
processing and resorted to an inefficient workaround.)
jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org> writes:
> I have nested divs in my document.
> I have in my lua filter:
>
> ```
> function handleDiv(el)
> if el.classes:includes("parent") then
> return handleChild(el.content) ----- here content is {}
> end
> return {}
> end
> ```
>
> But I find the content of the parent div is empty. And it seems that
> each child div triggers `handleDiv` before the parent does.
>
> What I want is to deal with the child divs only in `handleChild` without
> triggering `handleDiv`.
>
> Is there any suggestions?
>
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2a6w6zwxu.fsf%40163.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to deal with nested divs in lua filter
2020-10-28 17:22 ` John MacFarlane
@ 2020-10-29 5:57 ` jiewuza
2020-10-29 7:48 ` jiewuza
[not found] ` <m2d012uuxk.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2 siblings, 0 replies; 8+ messages in thread
From: jiewuza @ 2020-10-29 5:57 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
Nice to know it.
Now I just keep them when it is dealing with the child nodes.
And do the process when it comes to the parent.
John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
> Yes, it's a bottom-up traversal of the tree, so child nodes
> will be processed before the parent.
>
> Doing top-down traversals in filters is currently tricky.
>
> You can, of course, do it manually, with a for loop around
> the blocks in Pandoc, but that's clunky.
>
> Maybe Albert has ideas on how we could make top-down
> traversals possible. (I needed one in pandoc's citation
> processing and resorted to an inefficient workaround.)
>
> jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org> writes:
>
>> I have nested divs in my document.
>> I have in my lua filter:
>>
>> ```
>> function handleDiv(el)
>> if el.classes:includes("parent") then
>> return handleChild(el.content) ----- here content is {}
>> end
>> return {}
>> end
>> ```
>>
>> But I find the content of the parent div is empty. And it seems that
>> each child div triggers `handleDiv` before the parent does.
>>
>> What I want is to deal with the child divs only in `handleChild` without
>> triggering `handleDiv`.
>>
>> Is there any suggestions?
>>
>> --
>> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2a6w6zwxu.fsf%40163.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to deal with nested divs in lua filter
2020-10-28 17:22 ` John MacFarlane
2020-10-29 5:57 ` jiewuza
@ 2020-10-29 7:48 ` jiewuza
[not found] ` <m2d012uuxk.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2 siblings, 0 replies; 8+ messages in thread
From: jiewuza @ 2020-10-29 7:48 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
Nice to know it.
Now I just keep the content untouched when it is dealing with the child
nodes. And do the process when it comes to the parent.
John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
> Yes, it's a bottom-up traversal of the tree, so child nodes
> will be processed before the parent.
>
> Doing top-down traversals in filters is currently tricky.
>
> You can, of course, do it manually, with a for loop around
> the blocks in Pandoc, but that's clunky.
>
> Maybe Albert has ideas on how we could make top-down
> traversals possible. (I needed one in pandoc's citation
> processing and resorted to an inefficient workaround.)
>
> jiewuza <jiewuza-9Onoh4P/yGk@public.gmane.org> writes:
>
>> I have nested divs in my document.
>> I have in my lua filter:
>>
>> ```
>> function handleDiv(el)
>> if el.classes:includes("parent") then
>> return handleChild(el.content) ----- here content is {}
>> end
>> return {}
>> end
>> ```
>>
>> But I find the content of the parent div is empty. And it seems that
>> each child div triggers `handleDiv` before the parent does.
>>
>> What I want is to deal with the child divs only in `handleChild` without
>> triggering `handleDiv`.
>>
>> Is there any suggestions?
>>
>> --
>> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2a6w6zwxu.fsf%40163.com.
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <m2d012uuxk.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>]
end of thread, other threads:[~2020-10-30 16:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 6:28 How to deal with nested divs in lua filter jiewuza
2020-10-28 9:28 ` jiewuza
[not found] ` <m2a6w6zwxu.fsf-9Onoh4P/yGk@public.gmane.org>
2020-10-28 17:22 ` John MacFarlane
2020-10-29 5:57 ` jiewuza
2020-10-29 7:48 ` jiewuza
[not found] ` <m2d012uuxk.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-30 15:36 ` Albert Krewinkel
[not found] ` <87r1pflo9a.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-10-30 16:37 ` John MacFarlane
[not found] ` <m2a6w3r7oh.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-10-30 16:50 ` Albert Krewinkel
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).