From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31058 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Huntsinger Newsgroups: gmane.text.pandoc Subject: Re: How to convert nested tables? | longtable vs tabular Date: Thu, 21 Jul 2022 13:38:37 -0700 (PDT) Message-ID: <274c5feb-0e57-4290-ae73-85c22e6b6710n@googlegroups.com> References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_354_959085780.1658435917907" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34705"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCFYNC6M64FBBTX25GLAMGQED7HA7EI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Jul 22 12:34:58 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-yw1-f191.google.com ([209.85.128.191]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oEpzl-0008mY-R5 for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 22 Jul 2022 12:34:58 +0200 Original-Received: by mail-yw1-f191.google.com with SMTP id 00721157ae682-31e60b8bb07sf36367707b3.1 for ; Fri, 22 Jul 2022 03:34:57 -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=iL2o0HpZ4tvi7UkQbvVEh8UGwoRIFqY9Sgv+gBmMmFw=; b=hlCeOG3/4gTdd+NiFRWiLvZQuYYbrvrD21/qWA9vIHInLLw7psZ4boVkD63xrJz8wN t082YPxQcxgS8QwFcNBZZJehrAsdfcgJbUB3NF5WAOGhsq6sP8WyclkSuDriA9ZJZewM 5FJvXwbgx3V7vPIPHNr0PW2yIpfOjgq/9+P3nnYhZYbHGiKkrMHNYSUo3AAg0I1FCRdj eQYmIJDL4WS6lYQ1IPxDPkOd9GO9yt/NF6RVo/SenLfe3TL1e8cPjkENrL5aPfEtx5QE LbhMvaRlZvs8yRflMgx2Bd0lDZmSVLxFjYjWvGYjtxzKQBikoTLNP+HdddOBqafH+YTD 53Pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=berkeley.edu; s=google; 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=iL2o0HpZ4tvi7UkQbvVEh8UGwoRIFqY9Sgv+gBmMmFw=; b=GlidVAaNA9Ktg8B1DgoALI5Ss1erGVuF5YpdTIkQgem+yyOuEauagDXCGqxgEC7anX dsbQgmY//+MqHImmsJHaoWtTG+LJsvwG/1dVUDZS5Z6yoppjQwQzSmS7nLUVIHSBTjzY gQEmZwxFpNHVtzBebJeB5/8D47BvsvuoQfJrH5OEk1QAicUTfGQaRKnP2SlkkP+Vx34n /f9gbzM/zIQF1x1gAKQnTHo30mN57pLPXfym9ljikPakO2336+qCPwTBobVkXMMAKxWq nTN/aql9F1yGdd6JnQ+xfhSNFirw680D69V2nd9GSZ7VMJJbSHi6dgaj+7ETyuoP1Q3w POHw== 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:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=iL2o0HpZ4tvi7UkQbvVEh8UGwoRIFqY9Sgv+gBmMmFw=; b=DdR9suok24OXxShz6jOVR5dcGY3jwaEjt6dWMmQYFVHcDbzUPrEsbLO+sONwjUBNWP 4/c82APUSp2gNLsybMNzjItpZyRblgz0hoUfNjaYp0PjKY6eUdfQalplzhRDq3PLXhl+ GnNBMqY3iWBGJSolgZjKR3IRDBk1bejM+M8eR4cDYIGJ9K5pCUvcjt++g9gN4j8DIE+z QL9lCMrw2DsADk3BdJVPi5kT4aLC2DhXCWd5gGKsLZ9JsSDqvgngvwsamenuDZTbJsuf R3WaP3QN3awjd9l+qACPSXCNhkesMbEXFryXQhtENo09gxuBLJV61fFkA63BHDUt3c3h R05A== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora+14ZJ3lyyYNXB3QDh8ZLfwl8rPf3TrYsEh+N1BQCoaLGWYXD/B +1sGDU4M7AOgNfbx2jex8qI= X-Google-Smtp-Source: AGRyM1uPbgzlq8ZP7ufpL6l3vkhGKAXMwM75pZih7grZgPxzXdKJMSfBaysNFIyDxro4oQsFNsZIhg== X-Received: by 2002:a25:640c:0:b0:670:91a0:57e3 with SMTP id y12-20020a25640c000000b0067091a057e3mr2389533ybb.204.1658486096622; Fri, 22 Jul 2022 03:34:56 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a25:a4ea:0:b0:66e:b68f:f446 with SMTP id g97-20020a25a4ea000000b0066eb68ff446ls3020363ybi.7.-pod-prod-gmail; Fri, 22 Jul 2022 03:34:53 -0700 (PDT) X-Received: by 2002:a5b:508:0:b0:66e:db78:cc3f with SMTP id o8-20020a5b0508000000b0066edb78cc3fmr2436019ybp.299.1658486093896; Fri, 22 Jul 2022 03:34:53 -0700 (PDT) Original-Received: by 2002:a81:b16:0:b0:31c:8cc0:995 with SMTP id 00721157ae682-31e9b06c4cfms7b3; Thu, 21 Jul 2022 13:38:39 -0700 (PDT) X-Received: by 2002:a25:c010:0:b0:66e:c03e:d6fb with SMTP id c16-20020a25c010000000b0066ec03ed6fbmr352585ybf.370.1658435918584; Thu, 21 Jul 2022 13:38:38 -0700 (PDT) In-Reply-To: X-Original-Sender: rhuntsinger-TVLZxgkOlNX2fBVCVOL8/A@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:31058 Archived-At: ------=_Part_354_959085780.1658435917907 Content-Type: multipart/alternative; boundary="----=_Part_355_166631269.1658435917907" ------=_Part_355_166631269.1658435917907 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I've come to better solution for getting Jupyter-displayable tables to=20 LaTex. Use kable to create an HTML representation and use kable again to=20 create a LaTex representation. Build a =E2=80=9Cmimebundle=E2=80=9D list wi= th these two=20 representations as elements. Use IRdisplay=E2=80=99s publish_mimebundle fun= ction to=20 display. The HTML representation will be rendered when running Jupyter; the= =20 LaTex representation will be copied as-is by pandoc when converting from=20 Jupyter-format to LaTeX-format. x =3D data.frame(a=3Dc(1,2,3), b=3Dc(10,20,30), c=3Dc(100,200,300)) x.html =3D kable(x, format=3D=E2=80=9Chtml=E2=80=9D, escape=3DFALSE, align= =3Drep(=E2=80=9Cr=E2=80=9D, ncol(x)),=20 caption=3D=E2=80=9CThis is from HTML=E2=80=9D, row.names=3DFALSE,=20 table.attr=3D=E2=80=9Cstyle=3D"white-space: nowrap;"=E2=80=9D) x.latex =3D kable_styling(latex_options=3Dc(=E2=80=9Chold_position=E2=80=9D= ), kable(x, format=3D=E2=80=9Clatex=E2=80=9D, escape=3DFALSE, align=3Drep(=E2= =80=9Cr=E2=80=9D, ncol(x)),=20 caption=3D=E2=80=9CThis is from LaTex=E2=80=9D, row.names=3DFALSE)) mbx =3D list(data=3Dlist(=E2=80=9Ctext/html=E2=80=9D=3Das.character(x.html)= ,=20 =E2=80=9Ctext/latex=E2=80=9D=3Das.character(x.latex)), metadata=3DNULL) publish_mimebundle(mbx$data, mbx$metadata) On Thursday, July 21, 2022 at 1:33:34 AM UTC-7 wlu...-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org= =20 wrote: > > Last time I looked Pandoc's AST couldn't represent nested tables anyway= . > > Surely a table cell 's=20 > contents is a list of blocks (which can include tables). What about this= =20 > markdown example (butchered from two of the examples in the manual)? > > +---------------+---------------+--------------------+ > | Fruit | Price | Advantages | > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ > | Bananas | $1.34 | - built-in wrapper | > | | | - bright color | > +---------------+---------------+--------------------+ > | Oranges | $2.10 | - cures scurvy | > | | | - tasty | > +---------------+---------------+--------------------+ > | Apple (pi) | $3.14 | | One | Two | | > | | | |-----+-------| | > | | | | my | table | | > | | | | is | nice | | > +---------------+---------------+--------------------+ > > [image: Screenshot 2022-07-20 at 23.36.36.png] > > On Wed, 20 Jul 2022 at 22:37, BPJ wrote: > =20 > >> Den tis 19 juli 2022 22:33Richard Huntsinger =20 >> skrev: >> >>> I=E2=80=99ve successfully converted Jupyter HTML-format simple tables t= o=20 >>> LaTex-format tables using pandoc.read(raw.text, =E2=80=98html=E2=80=99)= .blocks in a lua=20 >>> filter. The resulting LaTex is \begin(longtable} =E2=80=A6 That=E2=80= =99s okay for simple=20 >>> tables, but longtable does not support nested tables, which I do need. >>> >>> How to convert to LaTex tabular tables (which supports nested tables)= =20 >>> rather than to longtable tables (which does not)? Or is there some oth= er=20 >>> solution to converting nested tables?=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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit=20 >>> https://groups.google.com/d/msgid/pandoc-discuss/a477931c-2479-47f4-9cf= 7-d5880a429a38n%40googlegroups.com=20 >>> >>> . >>> >> --=20 >> You received this message because you are subscribed to the Google Group= s=20 >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n=20 >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit=20 >> https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhDM2Q0S_fSQx3kpFg= 0kv4r2gYqR-rSHEE%3DCWhry37jM-A%40mail.gmail.com=20 >> >> . >> > --=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/274c5feb-0e57-4290-ae73-85c22e6b6710n%40googlegroups.com. ------=_Part_355_166631269.1658435917907 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I've come to better solution for getting Jupyter-displayable tables to L= aTex. Use kable to create an HTML representation and use kable again to cre= ate a LaTex representation. Build a =E2=80=9Cmimebundle=E2=80=9D list with = these two representations as elements. Use IRdisplay=E2=80=99s publish_mime= bundle function to display. The HTML representation will be rendered when r= unning Jupyter; the LaTex representation will be copied as-is by pandoc whe= n converting from Jupyter-format to LaTeX-format.

x =3D data.frame(a= =3Dc(1,2,3), b=3Dc(10,20,30), c=3Dc(100,200,300))
x.html =3D kable(x, fo= rmat=3D=E2=80=9Chtml=E2=80=9D, escape=3DFALSE, align=3Drep(=E2=80=9Cr=E2=80= =9D, ncol(x)), caption=3D=E2=80=9CThis is from HTML=E2=80=9D, row.names=3DF= ALSE, table.attr=3D=E2=80=9Cstyle=3D"white-space: nowrap;"=E2=80=9D)
x.l= atex =3D kable_styling(latex_options=3Dc(=E2=80=9Chold_position=E2=80=9D),<= br>kable(x, format=3D=E2=80=9Clatex=E2=80=9D, escape=3DFALSE, align=3Drep(= =E2=80=9Cr=E2=80=9D, ncol(x)), caption=3D=E2=80=9CThis is from LaTex=E2=80= =9D, row.names=3DFALSE))
mbx =3D list(data=3Dlist(=E2=80=9Ctext/html=E2= =80=9D=3Das.character(x.html), =E2=80=9Ctext/latex=E2=80=9D=3Das.character(= x.latex)), metadata=3DNULL)
publish_mimebundle(mbx$data, mbx$metadata)

On = Thursday, July 21, 2022 at 1:33:34 AM UTC-7 wlu...-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org wrot= e:
> Last time I looked Pandoc's AST couldn&#= 39;t represent nested tables anyway.

=
Surely a table cell's contents is a lis= t of blocks (which can include tables). What about this markdown example (b= utchered from two of the examples in the manual)?
+---------------+----= -----------+--------------------+
| Fruit =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = Price =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Advantages =C2=A0 =C2=A0 =C2=A0 =C2=A0 = |
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+
| Bananas =C2=A0 =C2=A0 =C2=A0 | $1.34 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 | - built-in wrapper |
| =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 | - bright= color =C2=A0 =C2=A0 |
+---------------+---------------+----------------= ----+
| Oranges =C2=A0 =C2=A0 =C2=A0 | $2.10 =C2=A0 =C2=A0 =C2=A0 =C2=A0= | - cures scurvy =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 =C2=A0 | - tasty = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
+---------------+------------= ---+--------------------+
| Apple (pi)=C2=A0 =C2=A0 | $3.14 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | | One | Two =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 =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 =C2=A0 =C2=A0 =C2=A0= | | my =C2=A0| table | =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 =C2=A0 | | is= =C2=A0| nice =C2=A0| =C2=A0 =C2=A0|
+---------------+---------------+--= ------------------+


3D"Screensh=

O= n Wed, 20 Jul 2022 at 22:37, BPJ <b...-J3H7GcXPSITLoDKTGw+V6w@public.gmane.org> wrote:
=C2=A0
<= div dir=3D"ltr">
Den tis 19 juli 2022 22:33Richard Huntsinger <rhunt...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> skrev:

I=E2=80=99ve successfully = converted Jupyter HTML-format simple tables to LaTex-format tables using pandoc.read(raw.text, =E2=80=98html=E2=80=99).= blocks in a lua filter.=C2=A0 The resulting LaTex is \begin(longtable} =E2=80=A6=C2=A0 That=E2=80=99s okay for simple tables, but longtable does not support nested tables, which I do need.

How to convert to LaTex tabular tables (which supports nested tables) rather than to longtable tables (which does not)?=C2=A0 Or is there= some other solution to converting nested tables?=C2=A0

--
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-discus= ...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a= 477931c-2479-47f4-9cf7-d5880a429a38n%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 pandoc-discus...@googleg= roups.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/274c5feb-0e57-4290-ae73-85c22e6b6710n%40googlegroups.= com.
------=_Part_355_166631269.1658435917907-- ------=_Part_354_959085780.1658435917907--