From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30624 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: K4zuki Newsgroups: gmane.text.pandoc Subject: Re: MWE for building a table using Lua Date: Thu, 26 May 2022 03:52:21 -0700 (PDT) Message-ID: <8094d69c-8374-4662-9c5c-c099e14b19b2n@googlegroups.com> References: <11978438-43d6-4943-aaac-659d51f05f43n@googlegroups.com> <82a0d0eb-877a-47ff-8632-907322c40648n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2492_1574571854.1653562341435" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30021"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCY7J2HL3ALBBZVXXWKAMGQEXYDGPJI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu May 26 12:52:26 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f55.google.com ([209.85.160.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nuB6Q-0007cj-89 for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 26 May 2022 12:52:26 +0200 Original-Received: by mail-oa1-f55.google.com with SMTP id 586e51a60fabf-f2bdeb5298sf1010767fac.5 for ; Thu, 26 May 2022 03:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=F1OO/lHgjoaBywoU7reb7WxK+51A817V/e99svbPq/o=; b=DG3YFs0D+ulfU/cEmmWeAq3cxfzL8YDQjgxQ0DCEdEBwABfr8z8kAyx0P3VkfrVaFo zFWduISvEhbvRKOpeRWKf9gTOJ6cxhXjvEtMz0cQJmRLhRI4U/LVmtgZHDIZTLWYqE0o 4hucVMHEp0bGDmnZmaRTeGBHyIT3+zOF09QJ+/aG8I1puH7vvPXxA5CofeCIj6dwMfXq RS+BHuV0EbFlwAueLDZMDFGKJPcct594P9XwMl/i41SwuVaEDjoNdbmfd5yjhUQZXZRH CGK0gMGKaYBvgo4uORuDUAfuX2Lx8muZ1JuA9jPYAyMs/5TxPajaxIE7GKMuKlPwLTI8 FhwQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=F1OO/lHgjoaBywoU7reb7WxK+51A817V/e99svbPq/o=; b=ZOiDtnBoSv/sdEmXA4lvhQh3BvH3YY+xDwlrEpWN3iynMGOXWstZg6KgfG+WNERRAi H4ZUPY6OAmAGvxtaiJILs7d21nowsCpLlfHRV92iENEid7vGcjhnv3cFymR6XYuO30pI 55TkZyJXV29eyPNgIv8RYoL6pt4QkNDslc+9Z42+6LAYDvvxFl1dQbmq4cnp7dV/JDIE R1pvYfP35lJ0+oxP0eQpyL9kQDlNc/2zJyL/k4r+rMCyHvP5SbJSxE1CdUEU8Fo2N+wU FkE1mH5n1NOsHv9mnbvUvv4h1CieU+c1T+yYMtFcDpEerQisbS4rrsx08jDvX7opkTrF yJiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=F1OO/lHgjoaBywoU7reb7WxK+51A817V/e99svbPq/o=; b=JwiPr6I9lyghJTcauXk7mjlRe27gEv5xa5KbdIJ7ub4Rls5a7lvxaWdWMy7iszUtAy 6Tyv8zGXcrKN8QO/8YrZXbnL9PzZEBc4RP5QYUUNsPWvbxybSiI3ohkzuBsv+xV4av4v zI/9BPk4pPkotOvZSyWxLMZMTvqDr4E0AMAjNqFXt4VykXKmzy5Cp6tfR0JyZfoBOn/C UuN8MunInW36S/Co7vbxOgLsV+wD6DfY1JOQGnzFhSigo+8NE7KIEyluXP9QWYro4vsY X9JK4Pd8wIdJOzilrjfIVf5zqH0VT3ulNl5VFTx9N435DR+8QXD1Kci8Bvt99Ziyjswd +Yow== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM530vtLr+J5hQxHkRtjCFzQ/+ryVlvDyWYjF4mxOmGE8o6iiE0mrm NO3pJdfbVNetSjbqZWdJ2M4= X-Google-Smtp-Source: ABdhPJxbrQ00bjKMbEqOjRDyzfTxgDDdQyvL4mtl3qkNwHc/AvShX+pILk1TQLOmOIZRVZkJfAdSLQ== X-Received: by 2002:a05:6870:2194:b0:f1:c284:a9c5 with SMTP id l20-20020a056870219400b000f1c284a9c5mr762068oae.254.1653562345122; Thu, 26 May 2022 03:52:25 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6871:b10:b0:f1:dc54:9aa1 with SMTP id fq16-20020a0568710b1000b000f1dc549aa1ls9270356oab.1.gmail; Thu, 26 May 2022 03:52:22 -0700 (PDT) X-Received: by 2002:a05:6870:a90a:b0:f1:b878:1c77 with SMTP id eq10-20020a056870a90a00b000f1b8781c77mr826650oab.0.1653562342159; Thu, 26 May 2022 03:52:22 -0700 (PDT) In-Reply-To: X-Original-Sender: k.yamamoto.08136891-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:30624 Archived-At: ------=_Part_2492_1574571854.1653562341435 Content-Type: multipart/alternative; boundary="----=_Part_2493_615870295.1653562341435" ------=_Part_2493_615870295.1653562341435 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable hint 1 - my note about Table structure (might be inaccurate w/ 2.18): https://gist.github.com/K4zuki/04e1e1af2fcf06db1a6ea640aa8feadd=20 hint 2 - my implementation in a filter=20 (https://github.com/pandocker/pandocker-lua-filters/blob/master/lua/csv2tab= le.lua): 1. prepare a minimum table markdown text as a local variable 2. let pandoc convert the text, then extract Table object ```lua local table_template =3D [=3D=3D[ | table | |-------| | cell | Table: caption ]=3D=3D] local my_table =3D pandoc.read(table_template, "markdown").blocks[1] ``` 3. clone the object and replace the contents 2022=E5=B9=B45=E6=9C=8826=E6=97=A5=E6=9C=A8=E6=9B=9C=E6=97=A5 18:06:06 UTC+= 9 Bastien Dumont: > The constructors don't take tables as their argument, but discrete values= .=20 > I have not found the definition of the constructors in the official=20 > documentation, but you can look into this filter to see how they work:=20 > https://github.com/pandoc/lua-filters/blob/master/list-table/list-table.l= ua > > Le Thursday 26 May 2022 =C3=A0 01:53:39AM, msprev a =C3=A9crit : > > This creates the following structure -- all ok, except the table body,= =20 > which is > > empty ('[]'), and I cannot get it to appear. Any suggestions on what I'= m=20 > doing > > wrong would be gratefully received. > >=20 > > ``` > > Table > > ( "" , [] , [] ) > > (Caption Nothing []) > > [ ( AlignLeft , ColWidthDefault ) > > , ( AlignDefault , ColWidthDefault ) > > ] > > (TableHead ( "" , [] , [] ) []) > > [] > > (TableFoot ( "" , [] , [] ) []) > > ``` > > On Wednesday, May 25, 2022 at 12:48:06 PM UTC+1 msprev wrote: > >=20 > > I've been struggling to get my head around handling tables with Lua in > > pandoc 2.18. I'm trying to write a minimal working example to create a > > table as I can't seem to find one online. The code below does create a > > table, but with any empty table body and I can't figure out how to get= =20 > the > > body to appear. Can anyone help tell me what has gone wrong here? > >=20 > > BTW, I tried to call the pandoc.TableBody() constructor, but that throw= s=20 > an > > error as it doesn't seem to be defined ("attempt to call a nil value=20 > (field > > 'TableBody')") > >=20 > > ``` > > local caption =3D {long =3D {}} > > local colspecs =3D {{pandoc.AlignLeft, pandoc.ColWidthDefault}, > > {pandoc.AlignDefault, pandoc.ColWidthDefault}} > > local head =3D pandoc.TableHead() > > local cell1contents =3D { pandoc.Plain({pandoc.Str("cell1")}) } > > local cell2contents =3D { pandoc.Plain({pandoc.Str("cell2")}) } > > local cell1 =3D { alignment=3Dpandoc.AlignDefault, contents=3Dcell1cont= ents, > > col_span=3D1, row_span=3D1 } > > local cell2 =3D { alignment=3Dpandoc.AlignDefault, contents=3Dcell2cont= ents, > > col_span=3D1, row_span=3D1 } > > local row1 =3D { cells=3D{pandoc.Cell(cell1), pandoc.Cell(cell2)} } > > local rows =3D { pandoc.Row(row1) } > > local bodies =3D { body=3Drows, head=3D{}, row_head_columns=3D0 } > > local foot =3D pandoc.TableFoot() > > local mytable =3D pandoc.Table(caption, colspecs, head, bodies, foot) > > table.insert(doc.blocks, mytable) > > ``` > >=20 > > -- > > You received this message because you are subscribed to the Google Grou= ps > > "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email > > to [1]pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit [2] > https://groups.google.com/d/msgid/ > > pandoc-discuss/82a0d0eb-877a-47ff-8632-907322c40648n%40googlegroups.com= . > >=20 > > References: > >=20 > > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [2]=20 > https://groups.google.com/d/msgid/pandoc-discuss/82a0d0eb-877a-47ff-8632-= 907322c40648n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter > > --=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/8094d69c-8374-4662-9c5c-c099e14b19b2n%40googlegroups.com. ------=_Part_2493_615870295.1653562341435 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable hint 1 - my note about Table structure (might be inaccurate w/ 2.18):
&= nbsp;   https://gist.github.com/K4zuki/04e1e1af2fcf06db1a6ea640aa8fead= d 
hint 2 - my implementation in a filter (https://github.com/= pandocker/pandocker-lua-filters/blob/master/lua/csv2table.lua):
=
1. prepare a minimum table markdown text as a local variable
2. let pandoc convert the text, then extract Table object
```lua=
local table_template =3D [=3D=3D[
| table |
|-------|
|= cell |

Table: caption
]=3D=3D]

local my_table =3D pandoc= .read(table_template, "markdown").blocks[1]
```
3. = clone the object and replace the contents

2022=E5=B9=B45=E6=9C= =8826=E6=97=A5=E6=9C=A8=E6=9B=9C=E6=97=A5 18:06:06 UTC+9 Bastien Dumont:
The constructor= s don't take tables as their argument, but discrete values. I have not = found the definition of the constructors in the official documentation, but= you can look into this filter to see how they work: https://github.com/pandoc/lua-filters/blob/ma= ster/list-table/list-table.lua

Le Thursday 26 May 2022 =C3=A0 01:53:39AM, msprev a =C3=A9crit :
> This creates the following structure -- all ok, except the table b= ody, which is
> empty ('[]'), and I cannot get it to appear. Any suggestio= ns on what I'm doing
> wrong would be gratefully received.
>=20
> ```
> Table
> ( "" , [] , [] )
> (Caption Nothing [])
> [ ( AlignLeft , ColWidthDefault )
> , ( AlignDefault , ColWidthDefault )
> ]
> (TableHead ( "" , [] , [] ) [])
> []
> (TableFoot ( "" , [] , [] ) [])
> ```
> On Wednesday, May 25, 2022 at 12:48:06 PM UTC+1 msprev wrote:
>=20
> I've been struggling to get my head around handling tables= with Lua in
> pandoc 2.18. I'm trying to write a minimal working example= to create a
> table as I can't seem to find one online. The code below d= oes create a
> table, but with any empty table body and I can't figure ou= t how to get the
> body to appear. Can anyone help tell me what has gone wrong he= re?
>=20
> BTW, I tried to call the pandoc.TableBody() constructor, but t= hat throws an
> error as it doesn't seem to be defined ("attempt to c= all a nil value (field
> 'TableBody')")
>=20
> ```
> local caption =3D {long =3D {}}
> local colspecs =3D {{pandoc.AlignLeft, pandoc.ColWidthDefault}= ,
> {pandoc.AlignDefault, pandoc.ColWidthDefault}}
> local head =3D pandoc.TableHead()
> local cell1contents =3D { pandoc.Plain({pandoc.Str("cell1= ")}) }
> local cell2contents =3D { pandoc.Plain({pandoc.Str("cell2= ")}) }
> local cell1 =3D { alignment=3Dpandoc.AlignDefault, contents=3D= cell1contents,
> col_span=3D1, row_span=3D1 }
> local cell2 =3D { alignment=3Dpandoc.AlignDefault, contents=3D= cell2contents,
> col_span=3D1, row_span=3D1 }
> local row1 =3D { cells=3D{pandoc.Cell(cell1), pandoc.Cell(cell= 2)} }
> local rows =3D { pandoc.Row(row1) }
> local bodies =3D { body=3Drows, head=3D{}, row_head_columns=3D= 0 }
> local foot =3D pandoc.TableFoot()
> local mytable =3D pandoc.Table(caption, colspecs, head, bodies= , foot)
> table.insert(doc.blocks, mytable)
> ```
>=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 email
> to [1]pandoc-discus...@= googlegroups.com.
> To view this discussion on the web visit [2]https://groups.google.com/d/msgid/
> pandoc-discuss/82a0d0eb-877a-47ff-8632-907322c40648n%40googlegroups.com.
>=20
> References:
>=20
> [1] mailto:pandoc-discu= s...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> [2] https://groups= .google.com/d/msgid/pandoc-discuss/82a0d0eb-877a-47ff-8632-907322c40648n%40= googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter

--
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/8094d69c-8374-4662-9c5c-c099e14b19b2n%40googlegroups.= com.
------=_Part_2493_615870295.1653562341435-- ------=_Part_2492_1574571854.1653562341435--