From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30813 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William Lupton Newsgroups: gmane.text.pandoc Subject: Re: Printing lua tables Date: Thu, 23 Jun 2022 13:25:03 +0100 Message-ID: References: <551a3f2a8d364717bcc569baa974573a@unibe.ch> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000bfc7dd05e21c8b86" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10542"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCS4HJ6WSAHBBLFX2GKQMGQEZV6ZA3Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 23 14:25:21 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pl1-f186.google.com ([209.85.214.186]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o4Lth-0002ah-4P for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 23 Jun 2022 14:25:21 +0200 Original-Received: by mail-pl1-f186.google.com with SMTP id k11-20020a170902ce0b00b0016a15fe2627sf7845676plg.22 for ; Thu, 23 Jun 2022 05:25:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655987120; cv=pass; d=google.com; s=arc-20160816; b=jQaNznjeqxzgYHYjBEkOF7PEiVXGbEK6A84nEhnGEx46lD43boqDtALIYqyQSkdwZS 7ATwFW0wtNY0MPudeu4ISABCjk23L/Pc6K99VyKT9dNy5Q+Z10svOPiByOMzEtm2fTzR hTixg4ap4mI2k/mZ10l8rCz55Kkvs4agtH6DaBitJk4pTlXf+yg7GC7DzwLD/v9WkLkb n5oDYfRF/h5t442XoVTjfHrnBoN/0zRhXKyl97IDuYvzIieIrKUgZrAiox/20M0q5vNE IGM6By5mEOsMPOdkVr5sZBnko5J8Uq+PgAmyo4JZgNt+P/8Xj9568h/4kte1ghnnI6Jv m1TQ== 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:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature; bh=szMU/UfGanOcvGTy7pgVWBOKBkAYXeMEBwZ7wL1dYNU=; b=i68pkM728usF+nYuSbakgxRoYJplI3Yp4QlHThF8H8/MQKFCt7qlczyqbe1gIqr8WO hSGj+rb0Ze2wUien4lwUoQf5VnoiBKYtQI9GqS2lDUBn/dpkQTglM6rDvrXul07gdbs0 tPnssdfKl5OMHwmUmUlr8nWLcC9bGGSv8gOueHUIOqnE3s3aw+cIzVu5gvpAshR5D7jB A3jVrgbUqN3L2pTx7+EGRXxsWq8LcjDYr+0kIzwo+HyF5fcJ+uPCqRueWbGrWQVGyjNh Epadq6SuHDB+bRiqAuv67byq53/utr+L/mZRW8Bdqo9mTnGHxH/Ea0jR0ZZ1FCz1Yid2 YPVQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b=W65A1wYN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::632 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@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:from:date:message-id :subject:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=szMU/UfGanOcvGTy7pgVWBOKBkAYXeMEBwZ7wL1dYNU=; b=bgvd0VAA44waltqIft7lFxQu/X+M7yfXAp/3Qh7XdrzIRuzQZ8sSqrvER4HAVncUUf l/cLrp2QvTkHhRoaN4xATksRWlZK8biFl+Np/zHNidvKZLouwOnPI1vqPscoAaHn5hnR O89P5Ha0Uj83tTldzijAl7Ub122Yl3nRe3n/OfqkKqfJcfFekN/ocDds9FkidQmGa8kj ZKnhjEz2uzcF5i1KW1JohCmI53a9nRTv8Ss9QTVYy2vsjb5i+ebw+ckoMMz8v2JfF0G+ hoyO0y+cbZxxjrXjI5V+efvtQ3p0yzEApy+Ls2NsPv1pIDhYifSP0kaE47YDcPKe8ewP 5qRw== 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:from :date:message-id:subject:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=szMU/UfGanOcvGTy7pgVWBOKBkAYXeMEBwZ7wL1dYNU=; b=kOfLjI6UgfntD5QzTryAqgIYxR1CldQgK8qUG4QX3e3/FT3sx62T/6jUZ+AFlnnWCI Y0a2XGUvHlabaL90yJ8att2ivs5aucZHwYB/LFTI/Mqhsk97/jbWpRHFrLDCypfa6447 cWhShQlV6O8Ty32u5kD/6DtlI90XMR+LCqnSGa3HBcmwt6dZ+UkOheuvpbBnPMm0dXY8 FGTHgPsMiFT6SWp3Y6G+i0YRJChcBEUqulba9OOsJKBIx4cicc1rTQ8fjR0jbjsboKfA 3puUZZcPhHC/y0CUwPLX3tWK6sKsY7JWnlvgkAXMxcFV+LzDd3ciaEGJhb8l3dbisS/8 Ge5g== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora/kVCTqu2s0ZQJ8l0bKtx+9fY+R9ILkINBdPK2vfmplmpGptwb3 YRDObxfTCMV9vcg3KJTNpx0= X-Google-Smtp-Source: AGRyM1v/ZZiWVxeXkTeg5FRjuehenorDeAT3XLdx/67kVkB0gGt1THQuRgGAP+1eJOxO9JvfGaIOWA== X-Received: by 2002:aa7:8b51:0:b0:525:5132:8a84 with SMTP id i17-20020aa78b51000000b0052551328a84mr5428024pfd.45.1655987119797; Thu, 23 Jun 2022 05:25:19 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a63:6b88:0:b0:40d:260a:3c19 with SMTP id g130-20020a636b88000000b0040d260a3c19ls1903496pgc.11.gmail; Thu, 23 Jun 2022 05:25:16 -0700 (PDT) X-Received: by 2002:a63:ae03:0:b0:408:b78c:e284 with SMTP id q3-20020a63ae03000000b00408b78ce284mr7316176pgf.401.1655987116438; Thu, 23 Jun 2022 05:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655987116; cv=none; d=google.com; s=arc-20160816; b=gGOPWSXoUg+WuswnrmFnmZHG93TW9eS8tNjNg0SAJ833eckQvEN1uDqpJTu14h3qx8 7DYaePzbQQSTHyJrUwgdlBwboiW7fjrMK54vmsKAyZ5p9SD8stMDs1WyZSdUff4Faeeu e0ZEn6qPdAtz+ysGtoCvghGKV1jhyzTa7Lv3gmXOLuxaTdbRM7gg0FoJEJo0C4BWmDNa XGpGHBQMFZWfX+x7qezcF9VVnLgli3t11GCnb4mXgOJ7TbmreD49dM5GnIw5klAMJOgf r2iil5grdcP6DeBwkDLlqkodZI371UmULydquDEbLM+5RYw63jFP1kp3KupvE3coXLUQ Zetw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=v+eTQyzAAdUKw30GzsvQlZBoCb0xGFqHKGXhpBWLsms=; b=BAowalHapKDgIh6/dWCwA+NU+QjHLzqh1FuIJMBasY/E6L7mANjLMB2WHqgoAYnxE6 zMqDfsQK3kleOYcWGbnUpnhUB1v2kPkvt6X1Zu7u/TN96p52VyT5lt/kfMHLZPwVPJGY l8UNtV+pYbPdFWI2fDrM13VldEiZJcCUeiCCZ7qVcdGbaJeCITbhcs9IRlG/xQGAtlO6 shUBty65oJ4nZMq/BLAOGPOSgoBepSN9nXaCoxfYrpI2Cg9IjiMcdC5hKiv8vX320dtp 2tPAwW4caoNiakOxjwcp693nYUDVc82RmPzjS608+sjGRpn97igNPxX5iLhf/dXWjir9 0HMQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b=W65A1wYN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::632 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org Original-Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com. [2607:f8b0:4864:20::632]) by gmr-mx.google.com with ESMTPS id h1-20020a170902eec100b0016a0397a608si686509plb.7.2022.06.23.05.25.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 05:25:16 -0700 (PDT) Received-SPF: pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::632 as permitted sender) client-ip=2607:f8b0:4864:20::632; Original-Received: by mail-pl1-x632.google.com with SMTP id k7so18033076plg.7 for ; Thu, 23 Jun 2022 05:25:16 -0700 (PDT) X-Received: by 2002:a17:902:e983:b0:16a:2221:fc99 with SMTP id f3-20020a170902e98300b0016a2221fc99mr21472038plb.19.1655987115108; Thu, 23 Jun 2022 05:25:15 -0700 (PDT) In-Reply-To: X-Original-Sender: wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@broadband-forum-org.20210112.gappssmtp.com header.s=20210112 header.b=W65A1wYN; spf=pass (google.com: domain of wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org designates 2607:f8b0:4864:20::632 as permitted sender) smtp.mailfrom=wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@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:30813 Archived-At: --000000000000bfc7dd05e21c8b86 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I've created https://github.com/jgm/pandoc/issues/8146 to continue this discussion. On Tue, 7 Jun 2022 at 16:24, William Lupton wrote: > All, > > I've split this out into two functions (each currently in its own > [attached as .lua.txt] file): > > - dump(value, maxlen=3D70) that returns a possibly multi-line string > representation of a value > - output(...) that's a utility function that outputs space-separated > arguments, each passed to dump() and with a terminating newline if nee= ded > > Here's an updated example filter (it uses output() and doesn't call dump(= ) > directly): > > local output =3D require 'output' > function Pandoc(doc) > output('meta', doc.meta) > output('blocks', doc.blocks) > end > > Please feel free to do whatever you like with these functions. > > In my environment I have an additional layer in which I derive a log-leve= l > from PANDOC_STATE.{trace,verbosity} and use this in a set of logging > functions like this one (*please let me know if you'd like me to supply > these too*): > > function error(...) > if logLevel >=3D -1 then > output('(E)', ...) > end > end > > Cheers, > William > > On Tue, 7 Jun 2022 at 15:13, William Lupton > wrote: > >> I'll need to extract the reporting functions. I'll do that soon, and pos= t >> the result. This is currently working in pandoc 2.16.1 (and earlier). I >> haven't yet bitten the bullet of the move to 2.18. >> >> On Tue, 7 Jun 2022 at 14:55, John MacFarlane wrote: >> >>> >>> That looks nice. Can you share your utils.lua? >>> >>> William Lupton writes: >>> >>> > I think I've mentioned this before... but I'd be happy to contribute >>> (in a >>> > suitable form) the somewhat-pandoc-aware utility that I use for this. >>> > >>> > Given this input: >>> > >>> > *% *cat doc.md >>> > >>> > --- >>> > >>> > a: 1 >>> > >>> > b: | >>> > >>> > 2 3 4 >>> > >>> > --- >>> > >>> > >>> > # Header >>> > >>> > >>> > This is a sentence (and a paragraph). >>> > >>> > >>> > * This is a list item >>> > >>> > * And another >>> > >>> > >>> > | Right | Left | Default | Center | >>> > >>> > |------:|:-----|---------|:------:| >>> > >>> > | 12 | 12 | 12 | 12 | >>> > >>> > | 123 | 123 | 123 | 123 | >>> > >>> > | 1 | 1 | 1 | 1 | >>> > >>> > >>> > : Demonstration of pipe table syntax. >>> > >>> > and this filter: >>> > >>> > *% *cat rep.lua >>> > >>> > local utils =3D require 'utils' >>> > >>> > >>> > -- do it this way to avoid reporting MetaBlocks twice >>> > >>> > function Pandoc(doc) >>> > >>> > utils.temp('meta', doc.meta) >>> > >>> > utils.temp('blocks', doc.blocks) >>> > >>> > end >>> > >>> > this command: >>> > >>> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt >>> > >>> > generates the attached. >>> > >>> > On Tue, 7 Jun 2022 at 08:57, wrote: >>> > >>> >> Hi, >>> >> >>> >> When playing around with filters I use pprint.lua or inspect.lua to >>> >> visualize lua tables. Would it make sense to include some sort of >>> =C2=ABprint >>> >> the contents of this table=C2=BB to pandoc ? >>> >> >>> >> Best, >>> >> >>> >> Denis >>> >> >>> >> -- >>> >> --=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/CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg%2B8-cVGnhExLFnXXw%40mail= .gmail.com. --000000000000bfc7dd05e21c8b86 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've created=C2=A0https://github.com/jgm/pandoc/issues/8146 to continue= this discussion.

On Tue, 7 Jun 2022 at 16:24, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> wr= ote:
All,

I've split this ou= t into two functions (each currently in its own [attached as .lua.txt] file= ):
  • dump(value, maxlen=3D70) tha= t returns a possibly multi-line string representation of a value
  • output(...) that's a utility function tha= t outputs space-separated arguments, each passed to dump() and with a termi= nating newline if needed
Here's an updated example filter= (it uses output() and doesn't call dump() directly):

local output =3D require 'output'
function= Pandoc(doc)
=C2=A0 =C2=A0 output('meta', doc.meta)
=C2=A0 = =C2=A0 output('blocks', doc.blocks)
end

PANDOC_STATE.{trace,ver= bosity} and use this in a set of logging functions like this one (please let me know if you'd like me to supply these too):

function error(...)
=C2= =A0 =C2=A0 if logLevel >=3D -1 then
=C2=A0 =C2=A0 =C2=A0 =C2=A0 outpu= t('(E)', ...)
=C2=A0 =C2=A0 end
end


=
Cheers,
William

On Tue, 7 Jun 2022 at 15:13, William Lu= pton <w= lupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> wrote:
I'll need to extract the rep= orting functions. I'll do that soon, and post the result. This is curre= ntly working in pandoc 2.16.1 (and earlier). I haven't yet bitten the b= ullet of the move to 2.18.

On Tue, 7 Jun 2022 at 14:55, John MacFarlane <= jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org&= gt; wrote:

That looks nice.=C2=A0 Can you share your utils.lua?

William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:

> I think I've mentioned this before... but I'd be happy to cont= ribute (in a
> suitable form) the somewhat-pandoc-aware utility that I use for this.<= br> >
> Given this input:
>
> *% *cat doc.md
>
> ---
>
> a: 1
>
> b: |
>
>=C2=A0 =C2=A02 3 4
>
> ---
>
>
> # Header
>
>
> This is a sentence (and a paragraph).
>
>
> * This is a list item
>
> * And another
>
>
> | Right | Left | Default | Center |
>
> |------:|:-----|---------|:------:|
>
> |=C2=A0 =C2=A012=C2=A0 |=C2=A0 12=C2=A0 |=C2=A0 =C2=A0 12=C2=A0 =C2=A0= |=C2=A0 =C2=A0 12=C2=A0 |
>
> |=C2=A0 123=C2=A0 |=C2=A0 123 |=C2=A0 =C2=A0123=C2=A0 =C2=A0|=C2=A0 = =C2=A0123=C2=A0 |
>
> |=C2=A0 =C2=A0 1=C2=A0 |=C2=A0 =C2=A0 1 |=C2=A0 =C2=A0 =C2=A01=C2=A0 = =C2=A0|=C2=A0 =C2=A0 =C2=A01=C2=A0 |
>
>
> : Demonstration of pipe table syntax.
>
> and this filter:
>
> *% *cat rep.lua
>
> local utils =3D require 'utils'
>
>
> -- do it this way to avoid reporting MetaBlocks twice
>
> function Pandoc(doc)
>
>=C2=A0 =C2=A0 =C2=A0utils.temp('meta', doc.meta)
>
>=C2=A0 =C2=A0 =C2=A0utils.temp('blocks', doc.blocks)
>
> end
>
> this command:
>
> pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>
> generates the attached.
>
> On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>
>> Hi,
>>
>> When playing around with filters I use pprint.lua or inspect.lua t= o
>> visualize lua tables. Would it make sense to include some sort of = =C2=ABprint
>> the contents of this table=C2=BB to pandoc ?
>>
>> Best,
>>
>> Denis
>>
>> --

--
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://group= s.google.com/d/msgid/pandoc-discuss/CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg%2B8= -cVGnhExLFnXXw%40mail.gmail.com.
--000000000000bfc7dd05e21c8b86--