From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32631 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ThomasH Newsgroups: gmane.text.pandoc Subject: Re: Lua Filter: How to write a filter function for a Cell of a Table Date: Tue, 16 May 2023 05:59:31 -0700 (PDT) Message-ID: References: <4e77e8b9-2ca9-4da0-8c5c-c3e1cb005e50n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_7924_190485665.1684241971411" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24311"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCOJJAXZ7EPBBNH4RWRQMGQE3VBUEEA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue May 16 14:59:36 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f55.google.com ([209.85.210.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pyuH9-00063i-9h for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 16 May 2023 14:59:35 +0200 Original-Received: by mail-ot1-f55.google.com with SMTP id 46e09a7af769-6adc88ceab9sf1714905a34.2 for ; Tue, 16 May 2023 05:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1684241974; x=1686833974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=y+0nKgOclZCxabYjYVOGtiE5+o2g/WT5rRAwwIdhSGU=; b=fSRGgG00iLifIV8t3y2HBPMBEcET0fsa2CvuXWU1vO6VCsvOb9p/nF2t0FWcsccQmO MbMEtRnYXrkQqAwCCaUMpvKrtVlJm6KNuGtadRzFTCqeZMhOvhTc0f2I9imfelqF84ua lsYNCBHOrqvCbAH5LUY0I4G5ykTm9u/f9FD7B/LuyhykFb1RCeS/uSTs0duufuez9qwO 1LI8KFykSnV7nWS7XBwZI80HNnw8j9vZ8TbT258WgauBUWe5Gj3BvOTM0spMPvhbrU+2 v8m16VDtR76eLfJmpwIrlHL8G1QHjgofWoKPXqjPdYx1fRyqJPGIFMiN+uv5xa/kwCSU Hz3g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684241974; x=1686833974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=y+0nKgOclZCxabYjYVOGtiE5+o2g/WT5rRAwwIdhSGU=; b=YAUJhz7siJPOlSOC4p+FZK6ZI0vg6oczifVWeo29PBSExg65tb6QlnrfZqPkO/rTXq J/AhUV93XIh+aVClgGq5/JY8hqAkQXHd/06ePmboBF18O2SQeNhUeZdZ4FntZErOAOpR lm8Jh6qsxoUUwwfYJXParr2SxAvlftVWl5udZen/mtHy2DJ+zEDNKK8a4zAgBjJTRpwY u/GfPxshHUvZBJ1e/L32jPTn9ugp1L7cgvvjZEIG9OwvK7N8ySmJb11b8YnTzZ1y7vUd jKRXaTwpsGES23i1c+5ivZk93ix2G4yo/NR3Q8+rAY15O/IJb0U6BKNFS1KXCAh0Bqo2 99ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241974; x=1686833974; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=y+0nKgOclZCxabYjYVOGtiE5+o2g/WT5rRAwwIdhSGU=; b=Jz0IaCTn0SMpOFvh2NQZ7FofofbF1YdC0A/pq/PvNEEF9zzW9UsxdMv5D/yE5B7bRh hNMYkE+iXU8VsSsxIU3xco57KEomMp6AaWGADIqSNS51DHTZz7wjNsd3tFmkYsu2UFA8 MwtJ3QNEqc9smzm2gesBSD5VZOIeiCQp67aVP9pNGjHM9d+bAf44WlL1iQrvdVe9ahel fUGBfXqRa6/kgZ52sUNKYb4uPC8pjdabG1B+c/Fy4pM+NN7gRqFQbNTMzyvOgfiDY+z3 tLBPgiRaC8BuB9zUfzaPWHhE+dToMJuFORsvErouogMptoTPIh Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDxVDVyQM3HlEFwVwIac8lAilRn9eWnBvw4181xVlR7uqAljcp8C h+KDS1UAymxPQ7EhFU6V+eo= X-Google-Smtp-Source: ACHHUZ6RGLHUTEDaa82JKKBVO+gD3BNWdP3L+3RccJWFQN7HKGLYXae/PtMSrMEceZxQfL1vRM1opQ== X-Received: by 2002:a9d:63d5:0:b0:6aa:fac6:fbe2 with SMTP id e21-20020a9d63d5000000b006aafac6fbe2mr6959469otl.2.1684241974143; Tue, 16 May 2023 05:59:34 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6871:823:b0:199:fd39:4a69 with SMTP id q35-20020a056871082300b00199fd394a69ls158465oap.2.-pod-prod-gmail; Tue, 16 May 2023 05:59:32 -0700 (PDT) X-Received: by 2002:a05:6871:710:b0:196:324a:281f with SMTP id f16-20020a056871071000b00196324a281fmr10653060oap.10.1684241971979; Tue, 16 May 2023 05:59:31 -0700 (PDT) In-Reply-To: <4e77e8b9-2ca9-4da0-8c5c-c3e1cb005e50n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: therch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:32631 Archived-At: ------=_Part_7924_190485665.1684241971411 Content-Type: multipart/alternative; boundary="----=_Part_7925_2141731487.1684241971411" ------=_Part_7925_2141731487.1684241971411 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok, I implemented a solution going off of the Table filter. This is the=20 basic pattern: function Table(table) for ibody=3D1, #table.bodies do local tbody =3D table.bodies[ibody] for irow=3D1, #tbody.body do local row =3D tbody.body[irow] for icell=3D1, #row.cells do local cell =3D row.cells[icell] for iblock=3D1, #cell.contents do cell.contents[iblock] =3D=20 cell.contents[iblock]:walk(some_filter_map) -- cell blocks can be walk'ed= =20 again ... end This works, but is ugly because of all those nested loops. I wonder is there a specific reason to exempt the element components like= =20 rows and cells from the normal visitor pattern? On Monday, May 15, 2023 at 10:18:38=E2=80=AFAM UTC+2 ThomasH wrote: > I want to modify how table cells are translated. I started out like with= =20 > other AST types, e.g. > > function Cell(cell) > ... (do something with cell) > end > > This function is never called, although the input document contains a=20 > table with cells.=20 > > I assume, element components like cells are treated differently (although= =20 > they seem to appear in the AST like other AST nodes). > > What is the correct way to write filter functions for element components? > > Thanks, T. > --=20 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 e= mail 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/e6ba297b-1a4b-42cc-adaa-1b831340f8c4n%40googlegroups.com. ------=_Part_7925_2141731487.1684241971411 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok, I implemented a solution going off of the Table filter. This is th= e basic pattern:

function Table(table)
=C2= =A0 =C2=A0 for ibody=3D1, #table.bodies do
=C2=A0 =C2=A0 =C2=A0 =C2=A0= local tbody =3D table.bodies[ibody]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for i= row=3D1, #tbody.body do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 loca= l row =3D tbody.body[irow]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f= or icell=3D1, #row.cells do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 local cell =3D row.cells[icell]
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fo= r iblock=3D1, #cell.contents do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cell.contents[iblock] =3D cell.contents[ibl= ock]:walk(some_filter_map)=C2=A0 -- cell blocks can be walk'ed again
<= div>...
end

This works, but is ugly be= cause of all those nested loops.

I wonder is the= re a specific reason to exempt the element components like rows and cells f= rom the normal visitor pattern?

On Monday, May 15, 2023 at 10:18:38=E2=80= =AFAM UTC+2 ThomasH wrote:
I want to modify how table cells are translated. I start= ed out like with other AST types, e.g.

function Ce= ll(cell)
=C2=A0=C2=A0 ... (do something with cell)
end<= /div>

This function is never called, although the input = document contains a table with cells.

I assum= e, element components like cells are treated differently (although they see= m to appear in the AST like other AST nodes).

What= is the correct way to write filter functions for element components?
=

Thanks, T.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/e6ba297b-1a4b-42cc-adaa-1b831340f8c4n%40googlegroups.= com.
------=_Part_7925_2141731487.1684241971411-- ------=_Part_7924_190485665.1684241971411--