From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30625 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: MWE for building a table using Lua Date: Fri, 27 May 2022 12:42:59 +0200 Message-ID: References: <11978438-43d6-4943-aaac-659d51f05f43n@googlegroups.com> <82a0d0eb-877a-47ff-8632-907322c40648n@googlegroups.com> <8094d69c-8374-4662-9c5c-c099e14b19b2n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c135c405dffbf803" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1625"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBPGWYKKAMGQEVKDIJEI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri May 27 12:43:13 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wm1-f56.google.com ([209.85.128.56]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nuXR2-0000Fg-DT for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 27 May 2022 12:43:12 +0200 Original-Received: by mail-wm1-f56.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9sf2252682wmr.0 for ; Fri, 27 May 2022 03:43:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1653648191; cv=pass; d=google.com; s=arc-20160816; b=BuELtBe4VYQmRpfTw5LLiSFltRFswUqFbLf+v3gwMorP49knOvMUI2sm6uXESOXkbd 1eFTM8INouKEpfBRUzr0VjZmouIE/wiAFXUjrWG8GzbzTxYbon1ocBwuBX/w4GkB/FLn 3H67eeOU58lkN/41Jhe1Oqm15jZ0TKEAHA2GaPoAJVW8Te1eCxbtw38wl6vDOfuQ3+ow j7ssG+Jv0/g4C2c+Uj+gRP3eDOmutnlYFJxi9iDWV4R0ZVtNp5FclYpXqFRu32rOY1gC u4qe+4msRrPh6sYZYeGp0UR8J13u8Lq1mrhqvGdk/5NixQDhFcR6qyEWm5UfPQwdMyJA UZxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:sender:dkim-signature; bh=tfhNvsNIxHo6hkf7OFONH8JBfQO/Ef00w0Wbh/1347U=; b=ZK0pX4C2kqShzAMh/7+BI+hXRFEQaxyc87DjREsZHjFhLGIUoF1Pq+fbJOC+PaA7kL 5IkAxPJ4gJihWRPLLUwMEM5JFs9SlzUwFONma/gW/WC8zpLfJwsMRAL3MRE2dt/hFu4f 2cCKeTc28M2vQgro33/Q+Sfqkm2q8aqxcI/U1dPQPTv2QZ13KFdbG5bUMSDjMGz+YoSp d8tg9zacm3qF9g9gxL2ZwFVf2vdn6eMCngL5H8ZMLmPZyvEQda6YQveCLGF6l8wFu377 ojszM1qQty7+Vhl2e0yV4+1C80Bu0eay1rfNabMoOs47I4G+H8H3XMb6Dym6/qGJI22h XPIg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.208.51 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:mime-version:references:in-reply-to:reply-to:from:date :message-id:subject:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=tfhNvsNIxHo6hkf7OFONH8JBfQO/Ef00w0Wbh/1347U=; b=T3fHYe3ZCdSGnzGFhBY4Y3JS/hk3EHG2yOwylHbgou8vBDggemNKw8DqN4E6BLFkUK ty7kXYaf4aaVFllhd7823Df6ZunQbyS3E1hS90cBpIH6bXv+MWMHOcx6P53BDooUuvqP fpgIkHBfVCwnl4Z7noTCKe1KgxADfd6Hv4ZVGeJTkY1Gqk//CUW1d7C166L9FgyDzpM/ iQHuywaxua19pKjtogJZ6GtZ//SHPLU2yscOYjQXD1OgezGBI8zgoH5pduV5l5vZP9p8 jkGU/T33x3ZwnRyfY3aIhzZ9FF+n5gcHfLi9orU+Wwxf0O0vj5zMR8NEN7tg90r+LsNI 1q1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:mime-version:references:in-reply-to :reply-to:from:date:message-id:subject:to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=tfhNvsNIxHo6hkf7OFONH8JBfQO/Ef00w0Wbh/1347U=; b=UEjhqZZp9BwA7iKRaZ8VKJZEkYH7NB3UmFygF4/jmRW5KmsNTudBW+CN66daJAKtSY D+0yWPlMI2MZx+MI0PcoBfLYFSLz0xUSwEZp0Lzd1hT0/Pohi00vs3wwRIPN4hwMJJcH hOWYnLVRloU0lMQu6sPzil3NzPlsTokhpSLZ0K7HBmomITqiPl6sC3M2sVXSDsAXXvum Em33z2H5oA58qm05GittW7Ifc0c2JaKivSXugNlxiTzLo4fdk+pGwZZh4RmfNQDj0Ebj E7z2iSWPpkIAedrglB+9rMwb2ImsqzZ97u7cBchuWaFn32aD7ExFlf9N9Xpq22br+wTe w5tw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532dkv5TcaxM+EGY8UEug6wfN0QCbxHTxwM1Q/1YG4bE0kVpAIob kersbUovw1vGN6nNG5d5PX0= X-Google-Smtp-Source: ABdhPJxfK0uCBF/W40aizhMCBhySg+cbqmoSQMurRS2oka5ve4hsYWR36Eh5m3rK5Ol9j851EaJf0g== X-Received: by 2002:adf:e0c3:0:b0:20c:5672:9577 with SMTP id m3-20020adfe0c3000000b0020c56729577mr33921406wri.466.1653648191666; Fri, 27 May 2022 03:43:11 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:1c8f:b0:397:380f:f614 with SMTP id k15-20020a05600c1c8f00b00397380ff614ls5759417wms.3.gmail; Fri, 27 May 2022 03:43:07 -0700 (PDT) X-Received: by 2002:a05:600c:2285:b0:397:86a9:b828 with SMTP id 5-20020a05600c228500b0039786a9b828mr3854971wmf.35.1653648187610; Fri, 27 May 2022 03:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653648187; cv=none; d=google.com; s=arc-20160816; b=OrRRgWIxVTJSxmgO1CqL1KY5iP0f1ZctPrhSlXtGi/18xr/8B2wDia/e0toICBqKF+ kyqJAjf/Bi7pPG370dIxfQiPBuhn+HHVr8ttE3Yc0NFyoMpuvbTh+qW3Bmxgmdg/Wu0t pKQRHvS3U6nsskvIg2pjzBvi2MuXZOBHGkEu7sSbnHIH6wtn9Z1SWlg8jHtq/0zUGtDe +rZ8a6fn10EY12+L+6S9pkUTeymtjF0HMeu+UIpeDU2IZdd6GBVtfZRaG/L7shOUZJSj E5IaB1erQNAJWkkXHYZ2mpx+Mo1ZZh+MVcRsF9JjliNWlyAB38u6Pln5FSzAhLU2gg3c sEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version; bh=WfL0RBOkcP0ETefGsT6LN78ys+QW9VigmzrhRMuKe74=; b=i/s7uWZpT7QW08+oBFNUDBkv3ewiUdXgZJXd0Rv4Ap6C3kKVWEKHEy6LipFz6DtpYb MwWS/E/8oH0gFw+UdAiT3YYdFa12t27bL0FTMmDOIrYqLwm5aze/KqBrZM6P2y97FHtF MwKlGmPv2Jr8lWutU5s8DunkLNdTkS7bRJHDnmOi9SKhuoohqezixITCDCCN+ubhearo qBSuRf1NS7PpFIQxwYvck6IRFHcxiDmCJO3sdphc3j0pI31uVrXu/g2necwKp3Oo2o0K YrzXPB7atcV8K8sSWI1mncj704YO9t2gUjfDdLQ9cdXn9u/VMOo+Q5kqN6YZfiiVKNg0 O0QQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.208.51 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Original-Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com. [209.85.208.51]) by gmr-mx.google.com with ESMTPS id g13-20020a05600c4ecd00b00396f5233248si649004wmq.0.2022.05.27.03.43.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 May 2022 03:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.208.51 as permitted sender) client-ip=209.85.208.51; Original-Received: by mail-ed1-f51.google.com with SMTP id q15so4873055edb.11 for ; Fri, 27 May 2022 03:43:07 -0700 (PDT) X-Received: by 2002:a05:6402:1910:b0:42b:5046:7f88 with SMTP id e16-20020a056402191000b0042b50467f88mr29689671edz.319.1653648186749; Fri, 27 May 2022 03:43:06 -0700 (PDT) In-Reply-To: <8094d69c-8374-4662-9c5c-c099e14b19b2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 209.85.208.51 as permitted sender) smtp.mailfrom=melroch-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:30625 Archived-At: --000000000000c135c405dffbf803 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Den tors 26 maj 2022 12:53K4zuki skrev: > hint 1 - my note about Table structure (might be inaccurate w/ 2.18): > https://gist.github.com/K4zuki/04e1e1af2fcf06db1a6ea640aa8feadd > Thanks for this! My own stab at this, which may be seriously outdated, is here: https://groups.google.com/g/pandoc-discuss/c/XE9YdlJNamU/m/oWZapmV5CwAJ I was aiming at the JSON structure because my intention was to implement support for complex tables in Perl JSON filters, which I still use from time to time because Perl has real Unicode support! As for col/row spans: doesn't the HTML reader/writer support them yet? hint 2 - my implementation in a filter ( > https://github.com/pandocker/pandocker-lua-filters/blob/master/lua/csv2ta= ble.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 > Nice trick =E2=80=94 once you have grokked the structure. > 2022=E5=B9=B45=E6=9C=8826=E6=97=A5=E6=9C=A8=E6=9B=9C=E6=97=A5 18:06:06 UT= C+9 Bastien Dumont: > >> The constructors don't take tables as their argument, but discrete >> values. I have not found the definition of the constructors in the offic= ial >> documentation, but you can look into this filter to see how they work: >> https://github.com/pandoc/lua-filters/blob/master/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 body, >> which is >> > empty ('[]'), and I cannot get it to appear. Any suggestions on what >> I'm doing >> > wrong would be gratefully received. >> > >> > ``` >> > Table >> > ( "" , [] , [] ) >> > (Caption Nothing []) >> > [ ( AlignLeft , ColWidthDefault ) >> > , ( AlignDefault , ColWidthDefault ) >> > ] >> > (TableHead ( "" , [] , [] ) []) >> > [] >> > (TableFoot ( "" , [] , [] ) []) >> > ``` >> > On Wednesday, May 25, 2022 at 12:48:06 PM UTC+1 msprev wrote: >> > >> > 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 >> the >> > body to appear. Can anyone help tell me what has gone wrong here? >> > >> > BTW, I tried to call the pandoc.TableBody() constructor, but that >> throws an >> > error as it doesn't seem to be defined ("attempt to call a nil value >> (field >> > 'TableBody')") >> > >> > ``` >> > 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=3Dcell1con= tents, >> > col_span=3D1, row_span=3D1 } >> > local cell2 =3D { alignment=3Dpandoc.AlignDefault, contents=3Dcell2con= tents, >> > 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) >> > ``` >> > >> > -- >> > 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...-/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.co= m. >> >> > >> > References: >> > >> > [1] mailto:pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >> > [2] >> https://groups.google.com/d/msgid/pandoc-discuss/82a0d0eb-877a-47ff-8632= -907322c40648n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter >> >> -- > 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/8094d69c-8374-4662-9c5c-= c099e14b19b2n%40googlegroups.com > > . > --=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/CADAJKhDw3GKsUnfBhu6bdh7mJrGmtrOeHzz2ygTuUAZX-muEUA%40mail.g= mail.com. --000000000000c135c405dffbf803 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Den tors 26 maj 2022 12:53K4zuki <k.yamamoto.08136891-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev= :
hint 1 - my note about Table stru= cture (might be inaccurate w/ 2.18):

Thanks for this! My own stab at this, which may be se= riously outdated, is here:


I was a= iming at the JSON structure because my intention was to implement support f= or complex tables in Perl JSON filters, which I still use from time to time= because Perl has real Unicode support!

As for col/row spans: doesn't the HTML reader/writer su= pport them yet?


1. prepare a m= inimum table markdown text as a local variable
2. let pandoc conv= ert the text, then extract Table object
```lua
local ta= ble_template =3D [=3D=3D[
| table |
|-------|
| cell |

Tab= le: caption
]=3D=3D]

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

Nice trick =E2=80=94 once you have grokke= d the structure.



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 discret= e values. I have not found the definition of the constructors in the offici= al documentation, but you can look into this filter to see how they work: <= a href=3D"https://github.com/pandoc/lua-filters/blob/master/list-table/list= -table.lua" rel=3D"nofollow noreferrer" target=3D"_blank">https://github.co= m/pandoc/lua-filters/blob/master/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]http= s://groups.google.com/d/msgid/
> pandoc-discuss/82a0d0eb-877a-47ff-8632-907322c40648n%40go= oglegroups.com.
>=20
> References:
>=20
> [1] mailto:pandoc-discus...@googleg= roups.com
> [2] https= ://groups.google.com/d/msgid/pandoc-discuss/82a0d0eb-877a-47ff-8632-907322c= 40648n%40googlegroups.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 pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8094d69c-8= 374-4662-9c5c-c099e14b19b2n%40googlegroups.com.

--
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/CADAJKhDw3GKsUnfBhu6bdh7mJrGmtrOeHzz2ygTu= UAZX-muEUA%40mail.gmail.com.
--000000000000c135c405dffbf803--