From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32900 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sylvain Hubert Newsgroups: gmane.text.pandoc Subject: Re: How to wrap code blocks within new tables? Date: Sat, 1 Jul 2023 02:01:46 -0700 (PDT) Message-ID: References: <4f0c1e08-60a7-4c97-9a7e-c3367ae32483n@googlegroups.com> <326e3767-e3b2-2bd3-5d60-340b2f1295bb@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_11312_1767880178.1688202106290" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37856"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDX6LT7YRQIBB7GW76SAMGQEZGE54WY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jul 01 11:01:52 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oi1-f192.google.com ([209.85.167.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qFWUK-0009du-FS for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 01 Jul 2023 11:01:52 +0200 Original-Received: by mail-oi1-f192.google.com with SMTP id 5614622812f47-3a1bcdd0966sf3153988b6e.2 for ; Sat, 01 Jul 2023 02:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1688202111; x=1690794111; 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=tF0FGra5Y+hh8Zaj9u4kkmjRMxVuxaQ5C+iQzBP5jj4=; b=rOeoOZ4RIrZFl1sk7H1FHTXtY484VV4HhNJAjZcXOqLieGP/Ycbz+EJqwNlUHP9ldC S1Ho9vI8Supt3eXt4cvtwBRFTKUuXj8e6YOGlPtENzbl6MLb4r43HkCbD7Avs2v/UAih 50N7ise4H9NjKPrdOMgbzFga4lNbFLBgmpHb/mFWhszaAGaJZP7pgOEHAyCEcAq/tWkH 1ZY4N36m3y2gXFe3gji8zBibsMVUBbj37XLZUGJC82kumXcyDFK8sXINj9PkteVbs7fr ZPxzWCjQ4nfOWFU901gIg9wQfHF3dndJ8x5eoVBGpOJv1Xazb7p2XLID8W+RB6Js0sTX rz8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688202111; x=1690794111; 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=tF0FGra5Y+hh8Zaj9u4kkmjRMxVuxaQ5C+iQzBP5jj4=; b=FytSyAP1p3zhyc+J5z70Xvp+N9IfFt+rZ9HYWn9qR0tI34y6GVfoE/a65v10Megvtt uJvq7wZSn5RstNCSVDXCyVFS/8K+mbn11R72k2XiQgY0fNSmTZFugSbEF5G9bmHloE+A l5CyUq/nHhnkHg5QD8XH9PcXHwSBJAp7v//I7HHGASaVzzdBOHnLBQkQdZSIaR8oS7vU bhion8045AWnbdWNvq6zmogI+EGoJR0a08fpC3JpH6jKwetlh0FIs2DmZgfSfRgCWltZ LhPV7lB1dj/6Cjw562mpoCU9FAYmCA8PtM9biYjhJfIXiF8Gk+Ca/QXgzJ8G7ScCZo6Q 4ugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688202111; x=1690794111; 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=tF0FGra5Y+hh8Zaj9u4kkmjRMxVuxaQ5C+iQzBP5jj4=; b=EPB7O8NjZEp8pwblIjeN+coA1tqCiLC/sHGQv9HJ94a0kprnZAgWb9HYrcrGCNU/Qa fvOzRB9U3b7CeqTBrPYg/lVVb6mcaoElh+nRS49Ykqp+cBigoIQlk/cQRnxuiB3mVxXz F/pg+hbvapCnkhAXLr52tC1BhuN207HftFs3bljGvcjN/WdiJNOqXhuAtMeH1Lt0QzE5 PKepubdXpZG+2DGOcqBW73COfsDwLPDakgUsIm4H5GHGSPE0hvICulyL3jU0zoq9rYz9 lDakARowyFNS68PxHW16ag0lBVZfTEFFLVfC50E1XFpyjnWqyC Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AC+VfDwUv9Bn/QaS4H6E8WlFh5bSillmNiPfR99z5PB4Uky9sftHWMx/ 8L8Mfn4/hvKEVV2mUsdf1Ik= X-Google-Smtp-Source: ACHHUZ43z1OkPquGkMYbla9OmrhGz2P5Jyjdk6MRXo9zcUrIagmgtNfmUi1UTfhUSxljqhZePx3a9w== X-Received: by 2002:a05:6808:128f:b0:39c:59e2:dd79 with SMTP id a15-20020a056808128f00b0039c59e2dd79mr7808555oiw.36.1688202111377; Sat, 01 Jul 2023 02:01:51 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a62:8782:0:b0:66a:44a0:cbaa with SMTP id i124-20020a628782000000b0066a44a0cbaals1405909pfe.2.-pod-prod-01-us; Sat, 01 Jul 2023 02:01:47 -0700 (PDT) X-Received: by 2002:a63:1803:0:b0:54f:d3ef:539b with SMTP id y3-20020a631803000000b0054fd3ef539bmr2767311pgl.12.1688202107170; Sat, 01 Jul 2023 02:01:47 -0700 (PDT) In-Reply-To: <326e3767-e3b2-2bd3-5d60-340b2f1295bb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> X-Original-Sender: champignoom-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:32900 Archived-At: ------=_Part_11312_1767880178.1688202106290 Content-Type: multipart/alternative; boundary="----=_Part_11313_1571551900.1688202106290" ------=_Part_11313_1571551900.1688202106290 Content-Type: text/plain; charset="UTF-8" It works, thanks for the help! On Saturday, 1 July 2023 at 16:48:51 UTC+8 mf wrote: > Il 01/07/23 10:09, Sylvain Hubert ha scritto: > > ok just reverse-engineered it > > folloing > https://github.com/jgm/pandoc/issues/8932#issuecomment-1614842929 : > > > > function CodeBlock(elem) > > return pandoc.Table( > > {}, > > {"AlignDefault"}, > > {}, > > {{}}, > > {{{elem}}} > > ) > > end > > > > This is the old version of tables, that now is called `SimpleTable`, see > https://pandoc.org/lua-filters.html#type-simpletable > > You can use the same syntax with current pandoc this way: > > ```lua > t = pandoc.SimpleTable( {}, { "AlignDefault" }, {}, { {} }, { { { elem } > } } ) > ``` > > and then convert it to a Table with: > > ```lua > t2 = pandoc.utils.from_simple_table(t) > ``` > > By the way, I noticed that there's no `pandoc.TableBody` constructor. > > The only way I found is through a lua table like this: > > ```lua > body = { > attr = pandoc.Attr(), > head = {}, > row_head_columns = 0, > body = { pandoc.Row( { pandoc.Cell( { elem } ) } ) } > } > ``` > > So a minimal table is made like this: > > ```lua > t = pandoc.Table( > {}, -- empty caption > { { 'AlignDefault', 0 } }, -- one column, default alignment and width > pandoc.TableHead(), -- empty table head > { body }, -- a list of one body > pandoc.TableFoot() -- empty table foot > ) > ``` > > > > On Saturday, 1 July 2023 at 15:58:34 UTC+8 Sylvain Hubert wrote: > > > > Hi all, > > > > I'm trying to create bounding boxes for code blocks by wrapping them > > inside tables. > > According to the manual, I should probably use some filter like: > > > > function CodeBlock(elem) > > return pandoc.Table(--[[... elem ...]]) > > end > > > > but pandoc.Table takes a giant syntax tree with levels of all sorts > > of nodes. > > Neither the manual nor the error message gives a useful guide of > > actually creating a table. > > > > Could anyone provide a minimal example of creating a pandoc.Table in > > a lua filter? > > > > Thanks > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > . > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/pandoc-discuss/4f0c1e08-60a7-4c97-9a7e-c3367ae32483n%40googlegroups.com > < > https://groups.google.com/d/msgid/pandoc-discuss/4f0c1e08-60a7-4c97-9a7e-c3367ae32483n%40googlegroups.com?utm_medium=email&utm_source=footer > >. > -- 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/ad7ee1d1-4fe1-4a87-9ef7-d38502db4a8en%40googlegroups.com. ------=_Part_11313_1571551900.1688202106290 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It works, thanks for the help!

On Saturday, 1 July 2023 at 16:48:51 UTC+8= mf wrote:
Il= 01/07/23 10:09, Sylvain Hubert ha scritto:
> ok just reverse-engineered it=20
> folloing=C2=A0https://github.= com/jgm/pandoc/issues/8932#issuecomment-1614842929 :
>=20
> function CodeBlock(elem)
> return pandoc.Table(
> =C2=A0 =C2=A0 =C2=A0 {},
> =C2=A0 =C2=A0 =C2=A0 {"AlignDefault"},
> =C2=A0 =C2=A0 =C2=A0 {},
> =C2=A0 =C2=A0 =C2=A0 {{}},
> =C2=A0 =C2=A0 =C2=A0 {{{elem}}}
> =C2=A0 =C2=A0 )
> end
>=20

This is the old version of tables, that now is called `SimpleTable`, se= e=20
https://pandoc.org/lua-filters.html#type-simpletable

You can use the same syntax with current pandoc this way:

```lua
t =3D pandoc.SimpleTable( {}, { "AlignDefault" }, {}, { {} },= { { { elem }=20
} } )
```

and then convert it to a Table with:

```lua
t2 =3D pandoc.utils.from_simple_table(t)
```

By the way, I noticed that there's no `pandoc.TableBody` constructo= r.

The only way I found is through a lua table like this:

```lua
body =3D {
attr =3D pandoc.Attr(),
head =3D {},
row_head_columns =3D 0,
body =3D { pandoc.Row( { pandoc.Cell( { elem } ) } ) }
}
```

So a minimal table is made like this:

```lua
t =3D pandoc.Table(
{}, -- empty caption
{ { 'AlignDefault', 0 } }, -- one column, default alignment = and width
pandoc.TableHead(), -- empty table head
{ body }, -- a list of one body
pandoc.TableFoot() -- empty table foot
)
```


> On Saturday, 1 July 2023 at 15:58:34 UTC+8 Sylvain Hubert wrote:
>=20
> Hi all,
>=20
> I'm trying to create bounding boxes for code blocks by wra= pping them
> inside tables.
> According to the manual, I should probably use some filter lik= e:
>=20
> =C2=A0 =C2=A0 function CodeBlock(elem)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return pandoc.Table(--[[... elem = ...]])
> =C2=A0 =C2=A0 end
>=20
> but pandoc.Table takes a giant syntax tree with levels of all = sorts
> of nodes.
> Neither the manual nor the error message gives a useful guide = of
> actually creating a table.
>=20
> Could anyone provide a minimal example of creating a pandoc.Ta= ble in
> a lua filter?
>=20
> Thanks
>=20
> --=20
> You received this message because you are subscribed to the Google= =20
> Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, = send=20
> an email to pandoc-disc= us...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20
> <mailto:pandoc-discu= s...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit=20
> https://groups.google.= com/d/msgid/pandoc-discuss/4f0c1e08-60a7-4c97-9a7e-c3367ae32483n%40googlegr= oups.com <https:/= /groups.google.com/d/msgid/pandoc-discuss/4f0c1e08-60a7-4c97-9a7e-c3367ae32= 483n%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 pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/ad7ee1d1-4fe1-4a87-9ef7-d38502db4a8en%40googlegroups.= com.
------=_Part_11313_1571551900.1688202106290-- ------=_Part_11312_1767880178.1688202106290--